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

fix(opentrons-shared-data): fix performance module not being recognized #14990

Merged
merged 4 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 17 additions & 17 deletions api/src/opentrons/util/performance_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,6 @@
)


def _handle_package_import() -> Type[SupportsTracking]:
"""Handle the import of the performance_metrics package.

If the package is not available, return a stubbed tracker.
"""
try:
from performance_metrics import RobotContextTracker

return RobotContextTracker
except ImportError:
return StubbedTracker


package_to_use = _handle_package_import()
_robot_context_tracker: SupportsTracking | None = None


class StubbedTracker(SupportsTracking):
"""A stubbed tracker that does nothing."""

Expand All @@ -58,6 +41,23 @@ def store(self) -> None:
pass


def _handle_package_import() -> Type[SupportsTracking]:
"""Handle the import of the performance_metrics package.

If the package is not available, return a stubbed tracker.
"""
try:
from performance_metrics import RobotContextTracker

return RobotContextTracker
except ImportError:
return StubbedTracker


package_to_use = _handle_package_import()
_robot_context_tracker: SupportsTracking | None = None


def _get_robot_context_tracker() -> SupportsTracking:
"""Singleton for the robot context tracker."""
global _robot_context_tracker
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Performance metrics."""
Empty file.
6 changes: 6 additions & 0 deletions shared-data/python/tests/performance/test_module_builds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from pathlib import Path
from opentrons_shared_data.performance.dev_types import RobotContextState


def test_metrics_metadata(tmp_path: Path) -> None:
RobotContextState.ANALYZING_PROTOCOL
Loading