diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/argaze/DataFeatures.py | 17 | ||||
-rw-r--r-- | src/argaze/utils/demo_data/demo_frame_logger.py | 4 | ||||
-rw-r--r-- | src/argaze/utils/demo_data/demo_layer_logger.py | 2 |
3 files changed, 18 insertions, 5 deletions
diff --git a/src/argaze/DataFeatures.py b/src/argaze/DataFeatures.py index 6da769d..7ac6a4b 100644 --- a/src/argaze/DataFeatures.py +++ b/src/argaze/DataFeatures.py @@ -9,6 +9,8 @@ __license__ = "BSD" from typing import TypeVar, Tuple, Any import os +import sys +import traceback import importlib from inspect import getmembers, getmodule import collections @@ -679,12 +681,18 @@ def PipelineStepMethod(method): # Initialize execution time assessment start = time.perf_counter() + exception = None + result = None try: # Execute wrapped method result = method(self, timestamp, *args, **kw) + except Exception as e: + + exception = e + finally: # Measure execution time @@ -701,7 +709,12 @@ def PipelineStepMethod(method): subscription = getattr(observer, subscription_name) # Call subscription - subscription(timestamp, self) + subscription(timestamp, self, exception) + + # Raise exception + if exception is not None: + + raise exception return result @@ -711,7 +724,7 @@ class PipelineStepObserver(): """Define abstract class to observe pipeline step object use. !!! note - To subscribe to a method call, the inherited class simply needs to define 'on_<method_name>' functions with timestamp and object argument. + To subscribe to a method call, the inherited class simply needs to define 'on_<method_name>' functions with timestamp, object and traceback argument. """ def __enter__(self): diff --git a/src/argaze/utils/demo_data/demo_frame_logger.py b/src/argaze/utils/demo_data/demo_frame_logger.py index 025d4d8..64dbf96 100644 --- a/src/argaze/utils/demo_data/demo_frame_logger.py +++ b/src/argaze/utils/demo_data/demo_frame_logger.py @@ -12,7 +12,7 @@ from argaze.utils import UtilsFeatures class FixationLogger(DataFeatures.PipelineStepObserver, UtilsFeatures.FileWriter): - def on_look(self, timestamp, frame): + def on_look(self, timestamp, frame, exception): """Log fixations.""" # Log fixations @@ -29,7 +29,7 @@ class FixationLogger(DataFeatures.PipelineStepObserver, UtilsFeatures.FileWriter class ScanPathAnalysisLogger(DataFeatures.PipelineStepObserver, UtilsFeatures.FileWriter): - def on_look(self, timestamp, frame): + def on_look(self, timestamp, frame, exception): """Log scan path metrics.""" if frame.analysis_available: diff --git a/src/argaze/utils/demo_data/demo_layer_logger.py b/src/argaze/utils/demo_data/demo_layer_logger.py index 1e78375..47cf577 100644 --- a/src/argaze/utils/demo_data/demo_layer_logger.py +++ b/src/argaze/utils/demo_data/demo_layer_logger.py @@ -12,7 +12,7 @@ from argaze.utils import UtilsFeatures class AOIScanPathAnalysisLogger(DataFeatures.PipelineStepObserver, UtilsFeatures.FileWriter): - def on_look(self, timestamp, layer): + def on_look(self, timestamp, layer, exception): """Log aoi scan path metrics""" if layer.analysis_available: |