aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéo de la Hogue2024-02-19 14:43:12 +0100
committerThéo de la Hogue2024-02-19 14:43:12 +0100
commit81c0455a01f8464d5611c0cec9499010f0a5b450 (patch)
tree787324d8f6d8374b631ebaf6b5a2e4795b5d6221 /src
parent8c1d67a51a11a22f9b33aded2d96ca15d2c3da28 (diff)
downloadargaze-81c0455a01f8464d5611c0cec9499010f0a5b450.zip
argaze-81c0455a01f8464d5611c0cec9499010f0a5b450.tar.gz
argaze-81c0455a01f8464d5611c0cec9499010f0a5b450.tar.bz2
argaze-81c0455a01f8464d5611c0cec9499010f0a5b450.tar.xz
Adding children property to PipelineStepObject to iterate over all sub PipeLineStepObjects. Appending working directory to Python path.
Diffstat (limited to 'src')
-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)