aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2024-06-21 08:26:57 +0200
committerThéo de la Hogue2024-06-21 08:26:57 +0200
commite96f8ac8c42b3fbc22b034d3f52cf966a7662b3b (patch)
tree58836ae8cb8e24698ed6d02cb6fb01f8032ea85c
parent9ff33a028da3417505f3ef91a9d29b6f43738e05 (diff)
downloadargaze-e96f8ac8c42b3fbc22b034d3f52cf966a7662b3b.zip
argaze-e96f8ac8c42b3fbc22b034d3f52cf966a7662b3b.tar.gz
argaze-e96f8ac8c42b3fbc22b034d3f52cf966a7662b3b.tar.bz2
argaze-e96f8ac8c42b3fbc22b034d3f52cf966a7662b3b.tar.xz
Using wraps decorator to allow decorator chaining.
-rw-r--r--src/argaze/DataFeatures.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/argaze/DataFeatures.py b/src/argaze/DataFeatures.py
index 66eaba1..1bb1329 100644
--- a/src/argaze/DataFeatures.py
+++ b/src/argaze/DataFeatures.py
@@ -26,6 +26,7 @@ import sys
import threading
import time
from typing import Self
+from functools import wraps
import cv2
import matplotlib.patches as mpatches
@@ -687,8 +688,7 @@ class TimestampedImages(TimestampedObjectsList):
def PipelineStepExecutionTime(method):
"""Define a decorator use to assess pipeline step execution time and frequency."""
- logging.debug("@PipelineStepExecutionTime: assessing %s method execution time and frequency", method.__name__)
-
+ @wraps(method)
def wrapper(self, *args, **kwargs):
start = time.perf_counter()
@@ -721,6 +721,7 @@ def PipelineStepExecutionTime(method):
def PipelineStepInit(method):
"""Define a decorator use into PipelineStepObject class to wrap pipeline step __init__ method."""
+ @wraps(method)
def wrapper(self, **kwargs):
"""Wrap pipeline __init__ init method to update PipelineStepObject attributes with arguments after init call.
@@ -744,6 +745,7 @@ def PipelineStepInit(method):
def PipelineStepEnter(method):
"""Define a decorator use into PipelineStepObject class to wrap pipeline step __enter__ method."""
+ @wraps(method)
def wrapper(self):
"""Wrap pipeline step __enter__ method to call super, observers and children __enter__ method."""
@@ -761,6 +763,7 @@ def PipelineStepEnter(method):
def PipelineStepExit(method):
"""Define a decorator use into PipelineStepObject class to wrap pipeline step __exit__ method."""
+ @wraps(method)
def wrapper(self, *args):
"""Wrap pipeline step __exit__ method to call super, observers and children __exit__ method."""
@@ -776,6 +779,7 @@ def PipelineStepExit(method):
def PipelineStepAttributeSetter(method):
"""Define a decorator use into PipelineStepObject class to wrap pipeline step attribute setter."""
+ @wraps(method)
def wrapper(self, new_value, unwrap: bool = False):
"""Wrap pipeline step attribute setter to load attribute from file.
@@ -856,8 +860,7 @@ def PipelineStepAttributeSetter(method):
def PipelineStepMethod(method):
"""Define a decorator use into PipelineStepObject class to declare pipeline method."""
- logging.debug("@PipelineStepMethod: %s method notify observers and timestamped exceptions", method.__name__)
-
+ @wraps(method)
def wrapper(self, *args, timestamp: int | float = None, unwrap: bool = False, **kwargs):
"""Wrap pipeline step method to notify observers and timestamped exceptions.
@@ -918,6 +921,7 @@ def PipelineStepMethod(method):
def PipelineStepImage(method):
"""Define a decorator use into PipelineStepObject class to wrap pipeline step image method."""
+ @wraps(method)
def wrapper(self, **kwargs) -> numpy.array:
"""Wrap pipeline step image method."""
@@ -947,6 +951,7 @@ def PipelineStepImage(method):
def PipelineStepDraw(method):
"""Define a decorator use into PipelineStepObject class to wrap pipeline step draw method."""
+ @wraps(method)
def wrapper(self, image: numpy.array, **kwargs):
"""Wrap pipeline step draw method."""