diff --git a/src/pypelines/__init__.py b/src/pypelines/__init__.py index a1ef7741e05ee0c2a9649ddc60724b7452bcc599..f3247a520ff1602f256632a69cbd7d385cad8b65 100644 --- a/src/pypelines/__init__.py +++ b/src/pypelines/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.0.76" +__version__ = "0.0.77" from . import loggs from .pipes import * diff --git a/src/pypelines/pipes.py b/src/pypelines/pipes.py index 1f9391d0680864650fed1e6d42159b0d0dc52baf..6633b0f497d92439dab8debdb5e67794ec8bb80c 100644 --- a/src/pypelines/pipes.py +++ b/src/pypelines/pipes.py @@ -27,7 +27,7 @@ class BasePipeType(Protocol): class BasePipe(BasePipeType, metaclass=ABCMeta): - # this class must implements only the logic to link steps together. + # this class implements only the logic to link steps together. default_extra = None @@ -164,7 +164,7 @@ class BasePipe(BasePipeType, metaclass=ABCMeta): self.pipeline.resolved = False @property - def version(self): + def version(self) -> str: """Return a hash representing the versions of all steps in the object. Returns: diff --git a/src/pypelines/steps.py b/src/pypelines/steps.py index b9ab81b87390d176ae8d63de965d59d4127a83f0..cb15087d63d1c2625180e1fe4a43861060bc608d 100644 --- a/src/pypelines/steps.py +++ b/src/pypelines/steps.py @@ -1,5 +1,5 @@ -from functools import wraps, partial, update_wrapper -from .loggs import loggedmethod, NAMELENGTH +from functools import wraps, partial, update_wrapper, cache +from .loggs import loggedmethod, NAMELENGTH, getLogger, PypelineLogger from .arguments import autoload_arguments from .utils import to_snake_case @@ -212,7 +212,7 @@ class BaseStep: def __call__(self, *args, **kwargs): """Call the worker method with the given arguments and keyword arguments.""" - return self.worker(*args, **kwargs) + return loggedmethod(self.worker)(*args, **kwargs) def __repr__(self): """Return a string representation of the StepObject in the format: "<pipe_name.step_name StepObject>".""" @@ -720,7 +720,7 @@ class BaseStep: return False return True - def load_requirement(self, pipe_name, session, extra=None): + def load_requirement(self, pipe_name, session, extra=None, **kwargs) -> Any: """Load the specified requirement step for the given pipe name. Args: @@ -734,6 +734,10 @@ class BaseStep: Raises: IndexError: If the required step with the specified pipe name is not found in the requirement stack. """ + + if pipe_name in kwargs.keys(): + return kwargs[pipe_name] + try: req_step = [step for step in self.requirement_stack() if step.pipe_name == pipe_name][-1] except IndexError as e: @@ -767,6 +771,10 @@ class BaseStep: """ raise NotImplementedError + @property + def logger(self) -> PypelineLogger: + return getLogger(self.step_name[:NAMELENGTH]) + @dataclass class StepLevel: