diff --git a/src/pypelines/__init__.py b/src/pypelines/__init__.py index f3c2e9b05298cc40fce22f222534d0f1d942f03a..ba31a3edbab453d00306e54004b4acbc9c2da172 100644 --- a/src/pypelines/__init__.py +++ b/src/pypelines/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.0.22" +__version__ = "0.0.23" from . import loggs from .pipes import * diff --git a/src/pypelines/examples.py b/src/pypelines/examples.py index 6f77e0eb61baa848d5780e2ec8cf426beb769f43..f762fcd1057d24af9ff5c61d4386df13011ccbb3 100644 --- a/src/pypelines/examples.py +++ b/src/pypelines/examples.py @@ -7,7 +7,7 @@ example_pipeline = Pipeline("example") @example_pipeline.register_pipe class treated_videos(PicklePipe): - single_step = True + # single_step = True @stepmethod() def compress(self, session, video_codec="ffmpeg", extra="", compression_rate=0.5): diff --git a/src/pypelines/pickle_backend.py b/src/pypelines/pickle_backend.py index 50b3e2e5a14b159e05084e66ff40898ab999da11..39a5f9024ca53bcf9a32786d26a6826f052b55b5 100644 --- a/src/pypelines/pickle_backend.py +++ b/src/pypelines/pickle_backend.py @@ -267,7 +267,7 @@ class PickleDiskObject(BaseDiskObject): class PicklePipe(BasePipe): - single_step = False + # single_step = False step_class = BaseStep disk_class = PickleDiskObject diff --git a/src/pypelines/pipelines.py b/src/pypelines/pipelines.py index 9e9634901912bd1e064a22fda37e77327240ec38..39d48af5235710abc5b76fb691d4197e5ee08a8e 100644 --- a/src/pypelines/pipelines.py +++ b/src/pypelines/pipelines.py @@ -10,7 +10,7 @@ if TYPE_CHECKING: class Pipeline: use_celery = False - pipes: Dict[str, BasePipe] + pipes: Dict[str, "BasePipe"] def __init__(self, name: str, conf_path=None, use_celery=False): self.pipeline_name = name @@ -27,29 +27,29 @@ class Pipeline: instance = pipe_class(self) # attaches the instance itself to the pipeline, and to the dictionnary 'pipes' of the current pipeline - if instance.single_step: - # in case it's a single_step instance (speficied by the user, not auto detected) - # then we attach the step to the pipeline directly as a pipe, for ease of use. - step = list(instance.steps.values())[0] - self.pipes[instance.pipe_name] = step - # just add steps to the step instance serving as a pipe, so that it behaves - # similarly to a pipe for some pipelines function requiring this attribute to exist. - step.steps = instance.steps - setattr(self, instance.pipe_name, step) - else: - # in case it's a pipe, we attach it in a simple manner. - self.pipes[instance.pipe_name] = instance - setattr(self, instance.pipe_name, instance) + # if instance.single_step: + # # in case it's a single_step instance (speficied by the user, not auto detected) + # # then we attach the step to the pipeline directly as a pipe, for ease of use. + # step = list(instance.steps.values())[0] + # self.pipes[instance.pipe_name] = step + # # just add steps to the step instance serving as a pipe, so that it behaves + # # similarly to a pipe for some pipelines function requiring this attribute to exist. + # step.steps = instance.steps + # setattr(self, instance.pipe_name, step) + # else: + # in case it's a pipe, we attach it in a simple manner. + self.pipes[instance.pipe_name] = instance + setattr(self, instance.pipe_name, instance) self.resolved = False return pipe_class - def resolve_instance(self, instance_name: str) -> Type["BaseStep"]: + def resolve_instance(self, instance_name: str) -> "BaseStep": pipe_name, step_name = instance_name.split(".") try: pipe = self.pipes[pipe_name] - if pipe.single_step: - return pipe + # if pipe.single_step: + # return pipe return pipe.steps[step_name] except KeyError as exc: raise KeyError(f"No instance {instance_name} has been registered to the pipeline") from exc diff --git a/src/pypelines/pipes.py b/src/pypelines/pipes.py index 1fd2d0e36638b9afa3f7a636ccf0c42461a3b6a8..9dc41a896e959dfbb4464f87a69a8cc408fa8aef 100644 --- a/src/pypelines/pipes.py +++ b/src/pypelines/pipes.py @@ -20,7 +20,7 @@ class BasePipe(metaclass=ABCMeta): default_extra = None - single_step: bool = False # a flag to tell the initializer to bind the unique step of this pipe in place + # single_step: bool = False # a flag to tell the initializer to bind the unique step of this pipe in place # of the pipe itself, to the registered pipeline. step_class: Type[BaseStep] = BaseStep disk_class: Type[BaseDiskObject] = BaseDiskObject @@ -44,11 +44,11 @@ class BasePipe(metaclass=ABCMeta): f" { _steps = }" ) - if len(_steps) > 1 and self.single_step: - raise ValueError( - f"Cannot set single_step to True if you registered more than one step inside {self.pipe_name} class." - f" { _steps = }" - ) + # if len(_steps) > 1 and self.single_step: + # raise ValueError( + # f"Cannot set single_step to True if you registered more than one step inside {self.pipe_name} class." + # f" { _steps = }" + # ) number_of_steps_with_requirements = 0 for step in _steps.values(): diff --git a/src/pypelines/steps.py b/src/pypelines/steps.py index ab95ea432b57120346c94944030af064bb9792aa..211445bce26f86de3a9f34871690e97a8307db27 100644 --- a/src/pypelines/steps.py +++ b/src/pypelines/steps.py @@ -97,9 +97,9 @@ class BaseStep: def full_name(self): return f"{self.pipe_name}.{self.step_name}" - @property - def single_step(self): - return self.pipe.single_step + # @property + # def single_step(self): + # return self.pipe.single_step def disk_step(self, session, extra=""): disk_object = self.get_disk_object(session, extra)