Skip to content

Commit

Permalink
runner/live: add some docs to pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
victorges committed Dec 4, 2024
1 parent 4d12035 commit 64e88a5
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions runner/app/live/pipelines/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,47 @@
from PIL import Image

class Pipeline(ABC):
"""Abstract base class for image processing pipelines.
Processes frames sequentially and supports dynamic parameter updates.
Notes:
- Methods are only called one at a time in a separate process, so no need
for any locking.
- Error handling is done by the caller, so the implementation can let
exceptions propagate for optimal error reporting.
"""

def __init__(self, **params):
"""Initialize pipeline with optional parameters.
Args:
**params: Parameters to initalize the pipeline with.
"""
pass

@abstractmethod
def process_frame(self, frame: Image.Image) -> Image.Image:
"""Process a single frame through the pipeline.
Called sequentially with each frame from the stream.
Args:
frame: Input PIL Image
Returns:
Processed PIL Image
"""
pass

@abstractmethod
def update_params(self, **params):
"""Update pipeline parameters.
Must maintain valid state on success or restore previous state on failure.
Called sequentially with process_frame so concurrency is not an issue.
Args:
**params: Implementation-specific parameters
"""
pass

0 comments on commit 64e88a5

Please sign in to comment.