From 6a7e54a0df84d7864dddfccc4eb0e7ab3c140f97 Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Thu, 21 Mar 2024 08:42:31 +0100 Subject: Fixing PipelineStepObject.children method. Adding PipelineInputProvider class. --- src/argaze/DataFeatures.py | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/argaze/DataFeatures.py b/src/argaze/DataFeatures.py index 43e7ea7..1334961 100644 --- a/src/argaze/DataFeatures.py +++ b/src/argaze/DataFeatures.py @@ -566,7 +566,7 @@ class PipelineStepObject(): filepath = os.path.join(working_directory, new_observers_value) file_format = filepath.split('.')[-1] - # Python file format + # Load module from working directory if file_format == 'py': observer_module_path = new_observers_value.split('.')[0] @@ -744,16 +744,18 @@ class PipelineStepObject(): def children(self) -> object: """Iterate over children pipeline step objects.""" - for name, item in self.__class__.__dict__.items(): + for name in dir(self): - if isinstance(item, property): + if not name.startswith('_'): attr = getattr(self, name) - if PipelineStepObject in attr.__class__.__bases__: + if isinstance(attr, PipelineStepObject) and attr != self.parent: - yield attr + print('-', name, type(attr)) + yield attr + def PipelineStepMethod(method): """Define a decorator use into PipelineStepObject class to declare pipeline method. @@ -843,4 +845,38 @@ class PipelineStepObserver(): !!! warning This method is called provided that the observed PipelineStepObject is created as a context using a with statement. """ + pass + +class PipelineInputProvider(PipelineStepObject): + """ + Define class to ... + """ + def __init__(self, **kwargs): + + # DEBUG + print('PipelineInputProvider.__init__') + + super().__init__(**kwargs) + + def attach(self, method): + + # DEBUG + print('PipelineInputProvider.attach', method) + + def __enter__(self): + """ + Define abstract __enter__ method to use device as a context. + + !!! warning + This method is called provided that the PipelineInputProvider is created as a context using a with statement. + """ + return self + + def __exit__(self, type, value, traceback): + """ + Define abstract __exit__ method to use device as a context. + + !!! warning + This method is called provided that the PipelineInputProvider is created as a context using a with statement. + """ pass \ No newline at end of file -- cgit v1.1