aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/argaze/DataFeatures.py36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/argaze/DataFeatures.py b/src/argaze/DataFeatures.py
index 62f81a6..edbf8e9 100644
--- a/src/argaze/DataFeatures.py
+++ b/src/argaze/DataFeatures.py
@@ -418,6 +418,11 @@ class PipelineStepObject():
def __enter__(self):
"""At with statement start."""
+ # Start children pipeline step objects
+ for child in self.children:
+
+ child.__enter__()
+
# Start observers
for observer_name, observer in self.__observers.items():
@@ -425,13 +430,18 @@ class PipelineStepObject():
return self
- def __exit__(self, type, value, traceback):
+ def __exit__(self, exception_type, exception_value, exception_traceback):
"""At with statement end."""
# End observers
for observer_name, observer in self.__observers.items():
- observer.__exit__(type, value, traceback)
+ observer.__exit__(exception_type, exception_value, exception_traceback)
+
+ # End children pipeline step objects
+ for child in self.children:
+
+ child.__exit__(exception_type, exception_value, exception_traceback)
@property
def name(self) -> str:
@@ -483,6 +493,11 @@ class PipelineStepObject():
working_directory: folder path where to load files when a dictionary value is a relative filepath.
"""
+ # Append working directory to the Python path
+ if working_directory is not None:
+
+ sys.path.append(working_directory)
+
# Load name
try:
@@ -660,7 +675,7 @@ class PipelineStepObject():
return tabs
@property
- def properties(self) -> list:
+ def properties(self) -> Tuple[name, any]:
"""Iterate over pipeline step properties values."""
for name, item in self.__class__.__dict__.items():
@@ -679,6 +694,20 @@ class PipelineStepObject():
yield name, getattr(self, name)
+ @property
+ def children(self) -> object:
+ """Iterate over children pipeline step objects."""
+
+ for name, item in self.__class__.__dict__.items():
+
+ if isinstance(item, property):
+
+ attr = getattr(self, name)
+
+ if PipelineStepObject in attr.__class__.__bases__:
+
+ yield attr
+
def PipelineStepMethod(method):
"""Define a decorator use into PipelineStepObject class to declare pipeline method.
@@ -694,7 +723,6 @@ def PipelineStepMethod(method):
args: Any arguments defined by PipelineStepMethod.
unwrap: Extra arguments used in wrapper function to call wrapped method directly.
"""
-
if unwrap:
return method(self, timestamp, *args)