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

feat(shared-data): properly load new pipette configurations from shared data #11795

Merged
Show file tree
Hide file tree
Changes from 6 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
21 changes: 21 additions & 0 deletions api/src/opentrons/config/ot3_pipette_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from opentrons_shared_data.pipette import load_data
from opentrons_shared_data.pipette.pipette_definition import (
PipetteChannelType,
PipetteModelType,
PipetteVersionType,
PipetteConfigurations,
)

DEFAULT_CALIBRATION_OFFSET = [0.0, 0.0, 0.0]


def load_ot3_pipette(
pipette_model: str, number_of_channels: int, version: float
) -> PipetteConfigurations:
requested_model = PipetteModelType(pipette_model)
requested_channels = PipetteChannelType(number_of_channels)
requested_version = PipetteVersionType.convert_from_float(version)

return load_data.load_definition(
requested_model, requested_channels, requested_version
)
28 changes: 28 additions & 0 deletions api/tests/opentrons/config/test_ot3_pipette_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import pytest

from opentrons_shared_data.pipette.pipette_definition import (
SupportedTipsDefinition,
PipetteTipType,
)
from opentrons.config.ot3_pipette_config import load_ot3_pipette


def test_multiple_tip_configurations() -> None:
loaded_configuration = load_ot3_pipette("p1000", 8, 1.0)
assert list(loaded_configuration.supported_tips.keys()) == list(PipetteTipType)
assert isinstance(
loaded_configuration.supported_tips[PipetteTipType.t50],
SupportedTipsDefinition,
)


@pytest.mark.parametrize(
argnames=["model", "channels", "version"],
argvalues=[["p50", 8, 1.0], ["p1000", 96, 1.0], ["p50", 1, 1.0]],
)
def test_load_full_pipette_configurations(
model: str, channels: int, version: float
) -> None:
loaded_configuration = load_ot3_pipette(model, channels, version)
assert loaded_configuration.pipette_type.value == model
assert loaded_configuration.channels.as_int == channels
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$otSharedSchema": "#/pipette/schemas/2/pipettePropertiesSchema.json",
"displayName": "P1000 Eight Channel GEN3",
"model": "eightChannel",
"model": "p1000",
"displayCategory": "GEN3",
"pickUpTipConfigurations": {
"current": 0.5,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$otSharedSchema": "#/pipette/schemas/2/pipettePropertiesSchema.json",
"displayName": "P50 Eight Channel GEN3",
"model": "eightChannel",
"model": "p50",
"displayCategory": "GEN3",
"pickUpTipConfigurations": {
"current": 0.5,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$otSharedSchema": "#/pipette/schemas/2/pipettePropertiesSchema.json",
"displayName": "P1000 96 Channel GEN3",
"model": "ninetySixChannel",
"model": "p1000",
"displayCategory": "GEN3",
"pickUpTipConfigurations": {
"current": 0.4,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$otSharedSchema": "#/pipette/schemas/2/pipettePropertiesSchema.json",
"displayName": "P1000 One Channel GEN3",
"model": "oneChannel",
"model": "p1000",
"displayCategory": "GEN3",
"pickUpTipConfigurations": {
"current": 0.15,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$otSharedSchema": "#/pipette/schemas/2/pipettePropertiesSchema.json",
"displayName": "P50 One Channel GEN3",
"model": "oneChannel",
"model": "p50",
"displayCategory": "GEN3",
"pickUpTipConfigurations": {
"current": 0.15,
Expand Down
77 changes: 77 additions & 0 deletions shared-data/python/opentrons_shared_data/pipette/load_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import json

from typing import Dict, Any
from typing_extensions import Literal
from functools import lru_cache

from .. import load_shared_data, get_shared_data_root

from .pipette_definition import (
PipetteConfigurations,
PipetteChannelType,
PipetteVersionType,
PipetteModelType,
)


LoadedConfiguration = Dict[PipetteChannelType, Dict[PipetteModelType, Any]]


def _get_configuration_dictionary(
config_type: Literal["general", "geometry", "liquid"],
channels: PipetteChannelType,
max_volume: PipetteModelType,
version: PipetteVersionType,
) -> LoadedConfiguration:
config_path = (
get_shared_data_root()
/ "pipette"
/ "definitions"
/ "2"
/ config_type
/ channels.name.lower()
/ max_volume.value
/ f"{version.major}_{version.minor}.json"
)
return json.loads(load_shared_data(config_path))


@lru_cache(maxsize=None)
def _geometry(
channels: PipetteChannelType,
max_volume: PipetteModelType,
version: PipetteVersionType,
) -> LoadedConfiguration:
return _get_configuration_dictionary("geometry", channels, max_volume, version)


@lru_cache(maxsize=None)
def _liquid(
channels: PipetteChannelType,
max_volume: PipetteModelType,
version: PipetteVersionType,
) -> LoadedConfiguration:
return _get_configuration_dictionary("liquid", channels, max_volume, version)


@lru_cache(maxsize=None)
def _physical(
channels: PipetteChannelType,
max_volume: PipetteModelType,
version: PipetteVersionType,
) -> LoadedConfiguration:
return _get_configuration_dictionary("general", channels, max_volume, version)


def load_definition(
mcous marked this conversation as resolved.
Show resolved Hide resolved
max_volume: PipetteModelType,
channels: PipetteChannelType,
version: PipetteVersionType,
) -> PipetteConfigurations:
geometry_dict = _geometry(channels, max_volume, version)
physical_dict = _physical(channels, max_volume, version)
liquid_dict = _liquid(channels, max_volume, version)

return PipetteConfigurations.parse_obj(
{**geometry_dict, **physical_dict, **liquid_dict}
)
Loading