aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/user_guide/gaze_analysis_pipeline/logging.md6
-rw-r--r--src/argaze/DataFeatures.py17
-rw-r--r--src/argaze/utils/demo_data/demo_frame_logger.py4
-rw-r--r--src/argaze/utils/demo_data/demo_layer_logger.py2
4 files changed, 21 insertions, 8 deletions
diff --git a/docs/user_guide/gaze_analysis_pipeline/logging.md b/docs/user_guide/gaze_analysis_pipeline/logging.md
index 2784856..fae10a6 100644
--- a/docs/user_guide/gaze_analysis_pipeline/logging.md
+++ b/docs/user_guide/gaze_analysis_pipeline/logging.md
@@ -35,7 +35,7 @@ from argaze.utils import UtilsFeatures
class ScanPathAnalysisLogger(DataFeatures.PipelineStepObserver, UtilsFeatures.FileWriter):
- def on_look(self, timestamp, ar_frame):
+ def on_look(self, timestamp, ar_frame, exception):
"""Log scan path metrics.ar_frame"""
if ar_frame.analysis_available:
@@ -75,7 +75,7 @@ from argaze.utils import UtilsFeatures
class AOIScanPathAnalysisLogger(DataFeatures.PipelineStepObserver, UtilsFeatures.FileWriter):
- def on_look(self, timestamp, ar_layer):
+ def on_look(self, timestamp, ar_layer, exception):
"""Log aoi scan path metrics."""
if ar_layer.analysis_available:
@@ -116,7 +116,7 @@ from argaze.utils import UtilsFeatures
class VideoRecorder(DataFeatures.PipelineStepObserver, UtilsFeatures.VideoWriter):
- def on_look(self, timestamp, ar_frame):
+ def on_look(self, timestamp, ar_frame, exception):
"""Record frame image into video file."""
self.write(ar_frame.image())
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: