-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'edge' into RQA-2591-engage-axis-before-move
- Loading branch information
Showing
92 changed files
with
3,160 additions
and
1,089 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
.github/workflows/opentrons-ai-client-test-build-deploy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Run tests, build the app, and deploy it cross platform | ||
|
||
name: 'OpentronsAI client test, build, and deploy' | ||
|
||
# ToDo (kk:04/16/2024) Add build and deploy task | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'Makefile' | ||
- 'opentrons-ai-client/**/*' | ||
- 'components/**/*' | ||
- '*.js' | ||
- '*.json' | ||
- 'yarn.lock' | ||
- '.github/workflows/app-test-build-deploy.yaml' | ||
- '.github/workflows/utils.js' | ||
branches: | ||
- '**' | ||
tags: | ||
- 'v*' | ||
- 'ot3@*' | ||
pull_request: | ||
paths: | ||
- 'Makefile' | ||
- 'opentrons-ai-client/**/*' | ||
- 'components/**/*' | ||
- '*.js' | ||
- '*.json' | ||
- 'yarn.lock' | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ github.ref_name != 'edge' || github.run_id}}-${{ github.ref_type != 'tag' || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
CI: true | ||
|
||
jobs: | ||
js-unit-test: | ||
runs-on: 'ubuntu-22.04' | ||
name: 'opentrons ai frontend unit tests' | ||
timeout-minutes: 60 | ||
steps: | ||
- uses: 'actions/checkout@v3' | ||
- uses: 'actions/setup-node@v3' | ||
with: | ||
node-version: '18.19.0' | ||
- name: 'install udev' | ||
run: sudo apt-get update && sudo apt-get install libudev-dev | ||
- name: 'set complex environment variables' | ||
id: 'set-vars' | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`) | ||
buildComplexEnvVars(core, context) | ||
- name: 'cache yarn cache' | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
${{ github.workspace }}/.npm-cache/_prebuild | ||
${{ github.workspace }}/.yarn-cache | ||
key: js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | ||
- name: 'setup-js' | ||
run: | | ||
npm config set cache ${{ github.workspace }}/.npm-cache | ||
yarn config set cache-folder ${{ github.workspace }}/.yarn-cache | ||
make setup-js | ||
- name: 'test frontend packages' | ||
run: | | ||
make -C opentrons-ai-client test-cov | ||
- name: 'Upload coverage report' | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
files: ./coverage/lcov.info | ||
flags: opentrons-ai-client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
"""Performance helpers for tracking robot context.""" | ||
|
||
from pathlib import Path | ||
from opentrons_shared_data.performance.dev_types import ( | ||
SupportsTracking, | ||
F, | ||
RobotContextState, | ||
) | ||
from opentrons_shared_data.robot.dev_types import RobotTypeEnum | ||
from typing import Callable, Type | ||
from opentrons.config import ( | ||
feature_flags as ff, | ||
get_performance_metrics_data_dir, | ||
robot_configs, | ||
) | ||
|
||
|
||
_should_track = ff.enable_performance_metrics( | ||
RobotTypeEnum.robot_literal_to_enum(robot_configs.load().model) | ||
) | ||
|
||
|
||
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.""" | ||
|
||
def __init__(self, storage_location: Path, should_track: bool) -> None: | ||
"""Initialize the stubbed tracker.""" | ||
pass | ||
|
||
def track(self, state: RobotContextState) -> Callable[[F], F]: | ||
"""Return the function unchanged.""" | ||
|
||
def inner_decorator(func: F) -> F: | ||
"""Return the function unchanged.""" | ||
return func | ||
|
||
return inner_decorator | ||
|
||
def store(self) -> None: | ||
"""Do nothing.""" | ||
pass | ||
|
||
|
||
def _get_robot_context_tracker() -> SupportsTracking: | ||
"""Singleton for the robot context tracker.""" | ||
global _robot_context_tracker | ||
if _robot_context_tracker is None: | ||
# TODO: replace with path lookup and should_store lookup | ||
_robot_context_tracker = package_to_use( | ||
get_performance_metrics_data_dir(), _should_track | ||
) | ||
return _robot_context_tracker | ||
|
||
|
||
def track_analysis(func: F) -> F: | ||
"""Track the analysis of a protocol.""" | ||
return _get_robot_context_tracker().track(RobotContextState.ANALYZING_PROTOCOL)( | ||
func | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Tests for performance_helpers.""" | ||
|
||
from pathlib import Path | ||
from opentrons_shared_data.performance.dev_types import RobotContextState | ||
from opentrons.util.performance_helpers import ( | ||
StubbedTracker, | ||
_get_robot_context_tracker, | ||
) | ||
|
||
|
||
def test_return_function_unchanged() -> None: | ||
"""Test that the function is returned unchanged when using StubbedTracker.""" | ||
tracker = StubbedTracker(Path("/path/to/storage"), True) | ||
|
||
def func_to_track() -> None: | ||
pass | ||
|
||
assert ( | ||
tracker.track(RobotContextState.ANALYZING_PROTOCOL)(func_to_track) | ||
is func_to_track | ||
) | ||
|
||
|
||
def test_singleton_tracker() -> None: | ||
"""Test that the tracker is a singleton.""" | ||
tracker = _get_robot_context_tracker() | ||
tracker2 = _get_robot_context_tracker() | ||
assert tracker is tracker2 |
Oops, something went wrong.