Skip to content

Commit

Permalink
Merge branch 'main' into workflows/grid-visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
yeldarby authored Dec 20, 2024
2 parents 2e7a64d + 12de156 commit a850662
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@

from pydantic import ConfigDict, Field

from inference.core.workflows.execution_engine.entities.base import OutputDefinition
from inference.core.workflows.execution_engine.entities.base import (
OutputDefinition,
WorkflowImageData,
)
from inference.core.workflows.execution_engine.entities.types import (
IMAGE_KIND,
Selector,
StepSelector,
WorkflowImageSelector,
)
from inference.core.workflows.execution_engine.v1.entities import FlowControl
from inference.core.workflows.prototypes.block import (
Expand Down Expand Up @@ -75,6 +80,11 @@ class RateLimiterManifest(WorkflowBlockManifest):
description="Reference to steps which shall be executed if rate limit allows.",
examples=[["$steps.upload"]],
)
video_reference_image: Optional[WorkflowImageSelector] = Field(
description="Reference to a video frame to use for timestamp generation (if running faster than realtime on recorded video).",
examples=["$inputs.image"],
default=None,
)

@classmethod
def describe_outputs(cls) -> List[OutputDefinition]:
Expand All @@ -99,8 +109,18 @@ def run(
cooldown_seconds: float,
depends_on: any,
next_steps: List[StepSelector],
video_reference_image: Optional[WorkflowImageData] = None,
) -> BlockResult:
current_time = datetime.now()
try:
metadata = video_reference_image.video_metadata
current_time = datetime.fromtimestamp(
1 / metadata.fps * metadata.frame_number
)
except Exception:
# reference not passed, metadata not set, or not a video frame
pass

should_throttle = False
if self._last_executed_at is not None:
should_throttle = (
Expand Down

0 comments on commit a850662

Please sign in to comment.