PipelineTask: pass observers in contructor parameter

This commit is contained in:
Aleix Conchillo Flaqué
2025-02-24 17:19:30 -08:00
parent e9a0959e28
commit 6028f0f23a
8 changed files with 29 additions and 13 deletions

View File

@@ -122,6 +122,7 @@ class PipelineTask(BaseTask):
Args:
pipeline: The pipeline to execute.
params: Configuration parameters for the pipeline.
observers: List of observers for monitoring pipeline execution.
clock: Clock implementation for timing operations.
check_dangling_tasks: Whether to check for processors' tasks finishing properly.
"""
@@ -130,6 +131,7 @@ class PipelineTask(BaseTask):
self,
pipeline: BasePipeline,
params: PipelineParams = PipelineParams(),
observers: List[BaseObserver] = [],
clock: BaseClock = SystemClock(),
check_dangling_tasks: bool = True,
):
@@ -140,6 +142,16 @@ class PipelineTask(BaseTask):
self._clock = clock
self._params = params
self._check_dangling_tasks = check_dangling_tasks
if self._params.observers:
import warnings
with warnings.catch_warnings():
warnings.simplefilter("always")
warnings.warn(
"Field 'observers' is deprecated, use the 'observers' parameter instead.",
DeprecationWarning,
)
observers = self._params.observers
self._finished = False
# This queue receives frames coming from the pipeline upstream.
@@ -163,7 +175,7 @@ class PipelineTask(BaseTask):
self._task_manager = TaskManager()
self._observer = TaskObserver(observers=params.observers, task_manager=self._task_manager)
self._observer = TaskObserver(observers=observers, task_manager=self._task_manager)
@property
def id(self) -> int: