Skip to content

Commit

Permalink
Merge branch 'edge' into chore_7.1.0-mergeback-into-edge
Browse files Browse the repository at this point in the history
  • Loading branch information
sfoster1 committed Dec 14, 2023
2 parents c08937e + d15b22e commit 59b436a
Show file tree
Hide file tree
Showing 161 changed files with 10,016 additions and 1,281 deletions.
84 changes: 80 additions & 4 deletions .github/workflows/components-test-build-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
files: ./coverage/lcov.info
flags: components

build-components:
build-components-storybook:
name: 'build components artifact'
runs-on: 'ubuntu-22.04'
if: github.event_name != 'pull_request'
Expand Down Expand Up @@ -102,11 +102,32 @@ jobs:
with:
name: 'components-artifact'
path: storybook-static

determine-build-type:
runs-on: 'ubuntu-latest'
name: 'Determine build type'
outputs:
type: ${{steps.determine-build-type.outputs.type}}
steps:
- id: determine-build-type
run: |
echo "Determining build type for event ${{github.event_type}} and ref ${{github.ref}}"
if [ "${{ format('{0}', github.ref == 'refs/heads/edge') }}" = "true" ] ; then
echo "storybook s3 builds for edge"
echo 'type=storybook' >> $GITHUB_OUTPUT
elif [ "${{ format('{0}', startsWith(github.ref, 'refs/tags/components')) }}" = "true" ] ; then
echo "publish builds for components tags"
echo 'type=publish' >> $GITHUB_OUTPUT
else
echo "No build for ref ${{github.ref}} and event ${{github.event_type}}"
echo 'type=none' >> $GITHUB_OUTPUT
fi
deploy-components:
name: 'deploy components artifact to S3'
name: 'deploy components storybook artifact to S3'
runs-on: 'ubuntu-22.04'
needs: ['js-unit-test', 'build-components']
if: github.event_name != 'pull_request'
needs: ['js-unit-test', 'build-components-storybook', 'determine-build-type']
if: needs.determine-build-type.outputs.type != 'none'
steps:
- uses: 'actions/checkout@v3'
# https://github.com/actions/checkout/issues/290
Expand Down Expand Up @@ -137,3 +158,58 @@ jobs:
AWS_DEFAULT_REGION: us-east-2
run: |
aws s3 sync ./dist s3://opentrons-components/${{ env.OT_BRANCH}} --acl public-read
publish-components:
name: 'publish components package to npm'
runs-on: 'ubuntu-latest'
needs: ['js-unit-test', 'determine-build-type']
if: needs.determine-build-type.outputs.type == 'publish'
steps:
- uses: 'actions/checkout@v3'
# https://github.com/actions/checkout/issues/290
- name: 'Fix actions/checkout odd handling of tags'
if: startsWith(github.ref, 'refs/tags')
run: |
git fetch -f origin ${{ github.ref }}:${{ github.ref }}
git checkout ${{ github.ref }}
- uses: 'actions/setup-node@v3'
with:
node-version: '16'
registry-url: 'https://registry.npmjs.org'
- name: 'cache yarn cache'
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.yarn-cache
${{ github.workspace }}/.npm-cache
key: js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-
- name: 'setup-js'
run: |
npm config set cache ./.npm-cache
yarn config set cache-folder ./.yarn-cache
yarn config set network-timeout 60000
yarn
- name: 'build library'
run: |
make -C components lib
# replace package.json stub version number with version from tag
- name: 'set version number'
run: |
npm install -g json
VERSION_STRING=$(echo ${{ github.ref }} | sed 's/refs\/tags\/components@//')
json -I -f ./components/package.json -e "this.version=\"$VERSION_STRING\""
json -I -f ./components/package.json -e "this.dependencies['@opentrons/shared-data']=\"$VERSION_STRING\""
- uses: 'actions/setup-node@v3'
with:
node-version: '16'
registry-url: 'https://registry.npmjs.org'
- name: 'publish to npm registry'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
cd ./components && echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ./.npmrc && npm publish --access public
77 changes: 76 additions & 1 deletion .github/workflows/shared-data-test-lint-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ on:
- '*hotfix*'
tags:
- 'v*'
- 'shared-data*'
- 'components*'
pull_request:
paths:
- 'Makefile'
Expand Down Expand Up @@ -127,7 +129,7 @@ jobs:
key: js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-
- name: 'setup-js'
- name: 'js deps'
run: |
npm config set cache ./.npm-cache
yarn config set cache-folder ./.yarn-cache
Expand Down Expand Up @@ -187,3 +189,76 @@ jobs:
project: 'shared-data/python'
repository_url: 'https://upload.pypi.org/legacy/'
password: '${{ secrets.OT_PYPI_PASSWORD }}'

publish-switch:
runs-on: 'ubuntu-latest'
name: 'Determine whether or not to publish artifacts'
outputs:
should_publish: ${{steps.publish-switch.outputs.should_publish}}
steps:
- id: publish-switch
run: |
echo "Determining whether to publish artifacts for event ${{github.event_type}} and ref ${{github.ref}}"
if [ "${{ format('{0}', startsWith(github.ref, 'refs/tags/shared-data')) }}" = "true"] ; then
echo "Publishing builds for shared-data@ tags"
echo 'should_publish=true' >> $GITHUB_OUTPUT
elif [ "${{ format('{0}', startsWith(github.ref, 'refs/tags/components')) }}" = "true"] ; then
echo "Publishing builds for components@ tags"
echo 'should_publish=true' >> $GITHUB_OUTPUT
else
echo "No publish for ref ${{github.ref}} and event ${{github.event_type}}"
echo 'should_publish=false' >> $GITHUB_OUTPUT
fi
publish-to-npm:
name: 'publish shared-data package to npm'
runs-on: 'ubuntu-latest'
needs: ['js-test', 'publish-switch']
if: needs.publish-switch.outputs.should_publish == 'true'
steps:
- uses: 'actions/checkout@v3'
# https://github.com/actions/checkout/issues/290
- name: 'Fix actions/checkout odd handling of tags'
if: startsWith(github.ref, 'refs/tags')
run: |
git fetch -f origin ${{ github.ref }}:${{ github.ref }}
git checkout ${{ github.ref }}
- uses: 'actions/setup-node@v3'
with:
node-version: '16'
registry-url: 'https://registry.npmjs.org'
- name: 'cache yarn cache'
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.yarn-cache
${{ github.workspace }}/.npm-cache
key: js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-
- name: 'js deps'
run: |
npm config set cache ./.npm-cache
yarn config set cache-folder ./.yarn-cache
yarn config set network-timeout 60000
yarn
- name: 'build library'
run: |
make -C shared-data lib-js
# replace package.json stub version number with version from tag
- name: 'set version number'
run: |
npm install -g json
VERSION_STRING=$(echo ${{ github.ref }} | sed -E 's/refs\/tags\/(components|shared-data)@//')
json -I -f ./shared-data/package.json -e "this.version=\"$VERSION_STRING\""
cd ./shared-data
- uses: 'actions/setup-node@v3'
with:
node-version: '16'
registry-url: 'https://registry.npmjs.org'
- name: 'publish to npm registry'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
cd ./shared-data && echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ./.npmrc && npm publish --access public
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ setup-js:
yarn
$(MAKE) -C $(APP_SHELL_DIR) setup
$(MAKE) -C $(APP_SHELL_ODD_DIR) setup
$(MAKE) -C $(SHARED_DATA_DIR) setup-js

PYTHON_SETUP_TARGETS := $(addsuffix -py-setup, $(PYTHON_DIRS))

Expand Down
2 changes: 2 additions & 0 deletions api/docs/v2/robot_position.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ All positions relative to labware are adjusted automatically based on labware of

You should only adjust labware offsets in your Python code if you plan to run your protocol in Jupyter Notebook or from the command line. See :ref:`using_lpc` in the Advanced Control article for information.

.. _protocol-api-deck-coords:

Position Relative to the Deck
=============================

Expand Down
15 changes: 11 additions & 4 deletions api/src/opentrons/hardware_control/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,29 @@
from .api import API
from .pause_manager import PauseManager
from .backends import Controller, Simulator
from .types import CriticalPoint, ExecutionState
from .types import CriticalPoint, ExecutionState, OT3Mount
from .constants import DROP_TIP_RELEASE_DISTANCE
from .thread_manager import ThreadManager
from .execution_manager import ExecutionManager
from .threaded_async_lock import ThreadedAsyncLock, ThreadedAsyncForbidden
from .protocols import HardwareControlInterface
from .protocols import HardwareControlInterface, FlexHardwareControlInterface
from .instruments import AbstractInstrument, Gripper
from typing import Union
from .ot3_calibration import OT3Transforms
from .robot_calibration import RobotCalibration
from opentrons.config.types import RobotConfig, OT3Config

from opentrons.types import Mount

# TODO (lc 12-05-2022) We should 1. figure out if we need
# to globally export a class that is strictly used in the hardware controller
# and 2. how to properly export an ot2 and ot3 pipette.
from .instruments.ot2.pipette import Pipette

OT2HardwareControlAPI = HardwareControlInterface[RobotCalibration]
OT3HardwareControlAPI = HardwareControlInterface[OT3Transforms]
OT2HardwareControlAPI = HardwareControlInterface[RobotCalibration, Mount, RobotConfig]
OT3HardwareControlAPI = FlexHardwareControlInterface[
OT3Transforms, Union[Mount, OT3Mount], OT3Config
]
HardwareControlAPI = Union[OT2HardwareControlAPI, OT3HardwareControlAPI]

ThreadManagedHardware = ThreadManager[HardwareControlAPI]
Expand All @@ -55,4 +60,6 @@
"ThreadedAsyncForbidden",
"ThreadManagedHardware",
"SyncHardwareAPI",
"OT2HardwareControlAPI",
"OT3HardwareControlAPI",
]
5 changes: 4 additions & 1 deletion api/src/opentrons/hardware_control/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class API(
# of methods that are present in the protocol will call the (empty,
# do-nothing) methods in the protocol. This will happily make all the
# tests fail.
HardwareControlInterface[RobotCalibration],
HardwareControlInterface[RobotCalibration, top_types.Mount, RobotConfig],
):
"""This API is the primary interface to the hardware controller.
Expand Down Expand Up @@ -426,6 +426,9 @@ async def update_firmware(
firmware_file, checked_loop, explicit_modeset
)

def has_gripper(self) -> bool:
return False

async def cache_instruments(
self, require: Optional[Dict[top_types.Mount, PipetteName]] = None
) -> None:
Expand Down
26 changes: 25 additions & 1 deletion api/src/opentrons/hardware_control/instruments/ot3/gripper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
)
from ..instrument_abc import AbstractInstrument
from opentrons.hardware_control.dev_types import AttachedGripper, GripperDict
from opentrons_shared_data.errors.exceptions import CommandPreconditionViolated
from opentrons_shared_data.errors.exceptions import (
CommandPreconditionViolated,
FailedGripperPickupError,
)

from opentrons_shared_data.gripper import (
GripperDefinition,
Expand Down Expand Up @@ -101,6 +104,10 @@ def remove_probe(self) -> None:
assert self.attached_probe
self._attached_probe = None

@property
def max_allowed_grip_error(self) -> float:
return self._geometry.max_allowed_grip_error

@property
def jaw_width(self) -> float:
jaw_max = self.geometry.jaw_width["max"]
Expand Down Expand Up @@ -196,6 +203,23 @@ def check_calibration_pin_location_is_accurate(self) -> None:
},
)

def check_labware_pickup(self, labware_width: float) -> None:
"""Ensure that a gripper pickup succeeded."""
# check if the gripper is at an acceptable position after attempting to
# pick up labware
expected_gripper_position = labware_width
current_gripper_position = self.jaw_width
if (
abs(current_gripper_position - expected_gripper_position)
> self.max_allowed_grip_error
):
raise FailedGripperPickupError(
details={
"expected jaw width": expected_gripper_position,
"actual jaw width": current_gripper_position,
},
)

def critical_point(self, cp_override: Optional[CriticalPoint] = None) -> Point:
"""
The vector from the gripper mount to the critical point, which is selectable
Expand Down
Loading

0 comments on commit 59b436a

Please sign in to comment.