diff options
-rw-r--r-- | src/argaze/DataFeatures.py | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/src/argaze/DataFeatures.py b/src/argaze/DataFeatures.py index 703c521..e70c1b5 100644 --- a/src/argaze/DataFeatures.py +++ b/src/argaze/DataFeatures.py @@ -75,6 +75,25 @@ def get_class(class_path: str) -> object: return m +def get_class_path(o: object): + """Get 'path.to.class' class path from object. + + Parameters: + object: any object instance. + + Returns: + class_path: object 'path.to.class' class. + """ + c = o.__class__ + m = c.__module__ + + # Avoid outputs like 'builtins.str' + if m == 'builtins': + + return c.__qualname__ + + return m + '.' + c.__qualname__ + def properties(cls) -> list: """get class properties name.""" @@ -818,21 +837,11 @@ class PipelineStepObject(): child.__enter__() - # Start observers - for observer in self.observers: - - observer.__enter__() - return self def __exit__(self, exception_type, exception_value, exception_traceback): """Define default method to exit from pipeline step object context.""" - # Stop observers - for observer in self.observers: - - observer.__exit__(exception_type, exception_value, exception_traceback) - # Stop children pipeline step objects for child in self.children: @@ -1055,10 +1064,20 @@ class PipelineStepObject(): attr = getattr(self, name) + # Pipeline step object attribute if isinstance(attr, PipelineStepObject) and attr != self.parent: yield attr + # Pipeline step objects list attribute + elif isinstance(attr, list): + + for p in attr: + + if isinstance(p, PipelineStepObject): + + yield p + def PipelineStepMethod(method): """Define a decorator use into PipelineStepObject class to declare pipeline method. |