fastvideo.workflow.workflow_base
#
Module Contents#
Classes#
Abstract base class for defining video processing workflows. |
Data#
API#
- class fastvideo.workflow.workflow_base.WorkflowBase(fastvideo_args: fastvideo.fastvideo_args.FastVideoArgs)[source]#
Bases:
abc.ABC
Abstract base class for defining video processing workflows.
A workflow serves as the top-level orchestrator that coordinates multiple pipelines and components to accomplish a specific video processing task. The workflow pattern provides several key benefits:
Separation of Concerns: Workflows separate high-level orchestration logic from low-level processing implementations in pipelines.
Modularity: Different workflows can be created for different execution modes (preprocess, inference, etc.) while sharing common pipeline components.
Configuration Management: Workflows manage the configuration and initialization of multiple related pipelines and components in a centralized manner.
Environment Setup: Workflows handle system-level setup and resource allocation before pipeline execution begins.
Lifecycle Management: Workflows control the complete lifecycle from initialization through execution to cleanup.
The workflow acts as a factory and coordinator, creating the appropriate pipelines based on configuration, setting up the execution environment, and orchestrating the overall processing flow.
Initialization
Initialize the workflow with configuration arguments.
- Parameters:
fastvideo_args β Configuration object containing all parameters needed for workflow and pipeline setup.
- add_component(component_name: str, component: Any) None [source]#
Register a component instance with the workflow.
Components are auxiliary objects that may be shared across pipelines or used for workflow-level functionality (e.g., databases, caches, external services).
- Parameters:
component_name β Unique identifier for the component.
component β The component instance to register.
- add_pipeline_config(pipeline_name: str, pipeline_config: tuple[fastvideo.pipelines.pipeline_registry.PipelineType, fastvideo.fastvideo_args.FastVideoArgs]) None [source]#
Register a pipeline configuration for later instantiation.
- Parameters:
pipeline_name β Unique identifier for the pipeline.
pipeline_config β Tuple containing the pipeline type and configuration arguments.
- get_component(component_name: str) Any [source]#
Retrieve a registered component by name.
- Parameters:
component_name β The name of the component to retrieve.
- Returns:
The component instance.
- classmethod get_workflow_cls(fastvideo_args: fastvideo.fastvideo_args.FastVideoArgs) Optional[fastvideo.workflow.workflow_base.WorkflowBase] [source]#
Factory method to get the appropriate workflow class based on execution mode.
This method acts as a workflow factory, returning the appropriate workflow class implementation based on the specified execution mode in the configuration arguments.
- Parameters:
fastvideo_args β Configuration object containing the execution mode and other parameters.
- Returns:
The appropriate workflow class for the specified execution mode, or None if no workflow is available for the given mode.
- load_pipelines() None [source]#
Create and initialize all registered pipelines.
This method instantiates pipeline objects from their configurations and makes them available as both dictionary entries and instance attributes for convenient access.
- abstract prepare_system_environment() None [source]#
Prepare the system environment for workflow execution.
Subclasses must implement this method to handle any system-level setup required before pipeline execution (e.g., GPU initialization, temporary directories, resource allocation).
- abstract register_components() None [source]#
Register workflow-specific components.
Subclasses must implement this method to register any components needed for their specific workflow (e.g., databases, external APIs, shared resources).