Skip to content

Commit 40db9c5

Browse files
authored
fix(opentrons-shared-data): fix performance module not being recognized (#14990)
# Overview Fixes https://opentrons.atlassian.net/browse/RQA-2623 performance directory was missing an `__init__.py` # Test Plan - I added a test just to import the module and create one of the objects inside the dev_types.py. The issue is that the tests don't run against the built version of the package. I built the app and everything imports correctly - I cannot test that opentrons_shared_data is being utilized correctly on the robot until I have a built buildroot image. Because currently my robot and app have different versions (due to the dev build) so the app will not let me trigger an analysis. - I instead pushed opentrons-shared-data to my robot and verified that the performance module existed in `/usr/lib/python3.10/site-packages/opentrons_shared_data`. But I can't test that the imports actually work until I have the system image and the app together # Changelog - Added `__init__.py` to performance directory to tell python to import it as a module - Reorganized performance_helpers.py to not have an import error # Review requests - Nothing to block this fix, but what should be done to make sure this doesn't happen again? This is a weird packaging thing that doesn't show up when running dev or CI testing. - I wonder if there is a smoke test we can perform automatically just to make sure everything imports correctly? Running opentrons.simulate against the actual built package would have caught this # Risk assessment Medium, I mean I can't break it any worse than I already did
1 parent 5415917 commit 40db9c5

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

api/src/opentrons/util/performance_helpers.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,6 @@
2020
)
2121

2222

23-
def _handle_package_import() -> Type[SupportsTracking]:
24-
"""Handle the import of the performance_metrics package.
25-
26-
If the package is not available, return a stubbed tracker.
27-
"""
28-
try:
29-
from performance_metrics import RobotContextTracker
30-
31-
return RobotContextTracker
32-
except ImportError:
33-
return StubbedTracker
34-
35-
36-
package_to_use = _handle_package_import()
37-
_robot_context_tracker: SupportsTracking | None = None
38-
39-
4023
class StubbedTracker(SupportsTracking):
4124
"""A stubbed tracker that does nothing."""
4225

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

6043

44+
def _handle_package_import() -> Type[SupportsTracking]:
45+
"""Handle the import of the performance_metrics package.
46+
47+
If the package is not available, return a stubbed tracker.
48+
"""
49+
try:
50+
from performance_metrics import RobotContextTracker
51+
52+
return RobotContextTracker
53+
except ImportError:
54+
return StubbedTracker
55+
56+
57+
package_to_use = _handle_package_import()
58+
_robot_context_tracker: SupportsTracking | None = None
59+
60+
6161
def _get_robot_context_tracker() -> SupportsTracking:
6262
"""Singleton for the robot context tracker."""
6363
global _robot_context_tracker
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Performance metrics."""

shared-data/python/tests/performance/__init__.py

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from pathlib import Path
2+
from opentrons_shared_data.performance.dev_types import RobotContextState
3+
4+
5+
def test_metrics_metadata(tmp_path: Path) -> None:
6+
RobotContextState.ANALYZING_PROTOCOL

0 commit comments

Comments
 (0)