aboutsummaryrefslogtreecommitdiff
path: root/src/argaze/DataFeatures.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/argaze/DataFeatures.py')
-rw-r--r--src/argaze/DataFeatures.py53
1 files changed, 29 insertions, 24 deletions
diff --git a/src/argaze/DataFeatures.py b/src/argaze/DataFeatures.py
index e70c1b5..5e5ac08 100644
--- a/src/argaze/DataFeatures.py
+++ b/src/argaze/DataFeatures.py
@@ -664,7 +664,7 @@ def PipelineStepEnter(method):
def wrapper(self):
"""Wrap pipeline step __enter__ method to call super, observers and children __enter__ method."""
- logging.debug('%s.__enter__', type(self).__name__)
+ logging.debug('%s.__enter__', get_class_path(self))
method(self)
@@ -678,7 +678,7 @@ def PipelineStepExit(method):
def wrapper(self, *args):
"""Wrap pipeline step __exit__ method to call super, observers and children __exit__ method."""
- logging.debug('%s.__exit__', type(self).__name__)
+ logging.debug('%s.__exit__', get_class_path(self))
PipelineStepObject.__exit__(self, *args)
@@ -712,7 +712,7 @@ def PipelineStepAttributeSetter(method):
raise(PipelineStepLoadingFailed(f'Annotations are missing for {method.__name__}: {method.__annotations__}'))
- logging.debug('%s@%s.setter', type(self).__name__, method.__name__)
+ logging.debug('%s@%s.setter', get_class_path(self), method.__name__)
logging.debug('\t> set %s with %s', expected_value_type.__name__, new_value_type.__name__)
# String not expected: load value from file
@@ -811,23 +811,28 @@ class PipelineStepObject():
Define class to assess pipeline step methods execution time and observe them.
"""
+ __initialized = False
+
def __init__(self):
"""Initialize PipelineStepObject."""
- logging.debug('%s.__init__', type(self).__name__)
+ if not self.__initialized:
- # Init private attributes
- self.__name = None
- self.__observers = []
- self.__execution_times = {}
- self.__image_parameters = {}
+ logging.debug('%s.__init__', get_class_path(self))
- # Init protected attributes
- self._image_parameters = {}
- self._draw_parameters = {}
-
- # Parent attribute will be setup later by parent it self
- self.__parent = None
+ # Init private attributes
+ self.__initialized = True
+ self.__name = None
+ self.__observers = []
+ self.__execution_times = {}
+ self.__image_parameters = {}
+
+ # Init protected attributes
+ self._image_parameters = {}
+ self._draw_parameters = {}
+
+ # Parent attribute will be setup later by parent it self
+ self.__parent = None
def __enter__(self):
"""Define default method to enter into pipeline step object context."""
@@ -854,13 +859,13 @@ class PipelineStepObject():
if hasattr(self, key):
- logging.debug('%s.update_attributes > update %s with %s value', type(self).__name__, key, type(value).__name__)
+ logging.debug('%s.update_attributes > update %s with %s value', get_class_path(self), key, type(value).__name__)
setattr(self, key, value)
else:
- raise(AttributeError(f'{type(self).__name__} has not {key} attribute.'))
+ raise(AttributeError(f'{get_class_path(self)} has not {key} attribute.'))
@property
def name(self) -> str:
@@ -956,7 +961,7 @@ class PipelineStepObject():
String representation
"""
- logging.debug('%s.__str__ %s', type(self).__name__, self.name if self.name is not None else '')
+ logging.debug('%s.__str__ %s', get_class_path(self), self.name if self.name is not None else '')
tabs = self.tabulation
output = f'{Fore.GREEN}{Style.BRIGHT}{self.__class__.__module__}.{self.__class__.__name__}{Style.RESET_ALL}\n'
@@ -974,7 +979,7 @@ class PipelineStepObject():
for name, value in self.properties:
- logging.debug('%s.__str__ @property %s (%s)', type(self).__name__, name, type(value).__name__)
+ logging.debug('%s.__str__ @property %s (%s)', get_class_path(self), name, type(value).__name__)
output += f'{tabs}\t{Style.BRIGHT}{name}{Style.RESET_ALL}: '
@@ -1010,9 +1015,9 @@ class PipelineStepObject():
except TypeError as e:
- logging.error('%s.__str__ @property %s (%s)', type(self).__name__, name, type(value).__name__)
+ logging.error('%s.__str__ @property %s (%s)', get_class_path(self), name, type(value).__name__)
- output += f'{Fore.RED}{Style.BRIGHT}!!! {type(self).__name__}.{name}: {e}{Style.RESET_ALL}\n\n'
+ output += f'{Fore.RED}{Style.BRIGHT}!!! {get_class_path(self)}.{name}: {e}{Style.RESET_ALL}\n\n'
if output[-1] != '\n':
@@ -1065,7 +1070,7 @@ class PipelineStepObject():
attr = getattr(self, name)
# Pipeline step object attribute
- if isinstance(attr, PipelineStepObject) and attr != self.parent:
+ if issubclass(type(attr), PipelineStepObject) and attr != self.parent:
yield attr
@@ -1074,7 +1079,7 @@ class PipelineStepObject():
for p in attr:
- if isinstance(p, PipelineStepObject):
+ if issubclass(type(p), PipelineStepObject):
yield p
@@ -1102,7 +1107,7 @@ def PipelineStepMethod(method):
else:
- logging.error('%s.%s: %s is not a TimestampedObject subclass. You must pass a timestamp argument.', type(self).__name__, method.__name__, type(args[0]).__name__)
+ logging.error('%s.%s: %s is not a TimestampedObject subclass. You must pass a timestamp argument.', get_class_path(self), method.__name__, type(args[0]).__name__)
if unwrap: