Skip to content

Commit

Permalink
fix: everything except execution outside the wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekMaggio committed Jun 5, 2024
1 parent 1af9d2a commit 23cfdae
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions api/src/opentrons/util/performance_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,17 @@ def _get_robot_context_tracker() -> SupportsTracking:
def track_analysis(func: UnderlyingFunction) -> UnderlyingFunction:
"""Track the analysis of a protocol and store each run."""
# TODO: derek maggio (06-03-2024): generalize creating wrapper functions for tracking different states
tracker: SupportsTracking = _get_robot_context_tracker()
wrapped = tracker.track(state=RobotContextState.ANALYZING_PROTOCOL)(func)

@functools.wraps(func)
def wrapper(
*args: UnderlyingFunctionParameters.args,
**kwargs: UnderlyingFunctionParameters.kwargs
) -> UnderlyingFunctionReturn:
tracker: SupportsTracking = _get_robot_context_tracker()
try:
result = tracker.track(state=RobotContextState.ANALYZING_PROTOCOL)(func)(
*args, **kwargs
)
return wrapped(*args, **kwargs)
finally:
tracker.store()
return result

return wrapper

0 comments on commit 23cfdae

Please sign in to comment.