Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(api, performance-metrics): clean up performance-metrics tracking #15289

Merged
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: everything except execution outside the wrapper
  • Loading branch information
DerekMaggio committed Jun 5, 2024
commit 23cfdae2250d32eeceb558865af2746ff676663d
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
Loading