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(api,robot-server): use deck def v6 #17278

Open
wants to merge 4 commits into
base: exec-80-deck-slot-defs-for-locating-features
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions api/src/opentrons/protocol_api/core/engine/protocol.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""ProtocolEngine-based Protocol API core implementation."""

from __future__ import annotations
from typing import Dict, Optional, Type, Union, List, Tuple, TYPE_CHECKING

Expand All @@ -7,7 +8,7 @@
from opentrons.protocol_engine import commands as cmd
from opentrons.protocol_engine.commands import LoadModuleResult

from opentrons_shared_data.deck.types import DeckDefinitionV5, SlotDefV3
from opentrons_shared_data.deck.types import DeckDefinitionV6, SlotDefV3
from opentrons_shared_data.labware.labware_definition import LabwareDefinition
from opentrons_shared_data.labware.types import LabwareDefinition as LabwareDefDict
from opentrons_shared_data import liquid_classes
Expand Down Expand Up @@ -759,7 +760,7 @@ def load_lid_stack(

return labware_core

def get_deck_definition(self) -> DeckDefinitionV5:
def get_deck_definition(self) -> DeckDefinitionV6:
"""Get the geometry definition of the robot's deck."""
return self._engine_client.state.labware.get_deck_definition()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from typing import Dict, List, Optional, Set, Union, cast, Tuple

from opentrons_shared_data.deck.types import DeckDefinitionV5, SlotDefV3
from opentrons_shared_data.deck.types import DeckDefinitionV6, SlotDefV3
from opentrons_shared_data.labware.types import LabwareDefinition
from opentrons_shared_data.pipette.types import PipetteNameType
from opentrons_shared_data.robot.types import RobotType
Expand Down Expand Up @@ -525,7 +525,7 @@ def get_labware_on_labware(
) -> Optional[LegacyLabwareCore]:
assert False, "get_labware_on_labware only supported on engine core"

def get_deck_definition(self) -> DeckDefinitionV5:
def get_deck_definition(self) -> DeckDefinitionV6:
"""Get the geometry definition of the robot's deck."""
assert False, "get_deck_definition only supported on engine core"

Expand Down
4 changes: 2 additions & 2 deletions api/src/opentrons/protocol_api/core/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from abc import abstractmethod, ABC
from typing import Generic, List, Optional, Union, Tuple, Dict, TYPE_CHECKING

from opentrons_shared_data.deck.types import DeckDefinitionV5, SlotDefV3
from opentrons_shared_data.deck.types import DeckDefinitionV6, SlotDefV3
from opentrons_shared_data.pipette.types import PipetteNameType
from opentrons_shared_data.labware.types import LabwareDefinition
from opentrons_shared_data.robot.types import RobotType
Expand Down Expand Up @@ -220,7 +220,7 @@ def load_lid_stack(
...

@abstractmethod
def get_deck_definition(self) -> DeckDefinitionV5:
def get_deck_definition(self) -> DeckDefinitionV6:
"""Get the geometry definition of the robot's deck."""

@abstractmethod
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Deck configuration resource provider."""

from typing import List, Set, Tuple

from opentrons_shared_data.deck.types import DeckDefinitionV5, CutoutFixture
from opentrons_shared_data.deck.types import DeckDefinitionV6, CutoutFixture

from opentrons.types import DeckSlotName

Expand All @@ -20,7 +21,7 @@
)


def get_cutout_position(cutout_id: str, deck_definition: DeckDefinitionV5) -> DeckPoint:
def get_cutout_position(cutout_id: str, deck_definition: DeckDefinitionV6) -> DeckPoint:
"""Get the base position of a cutout on the deck."""
for cutout in deck_definition["locations"]["cutouts"]:
if cutout_id == cutout["id"]:
Expand All @@ -31,7 +32,7 @@ def get_cutout_position(cutout_id: str, deck_definition: DeckDefinitionV5) -> De


def get_cutout_fixture(
cutout_fixture_id: str, deck_definition: DeckDefinitionV5
cutout_fixture_id: str, deck_definition: DeckDefinitionV6
) -> CutoutFixture:
"""Gets cutout fixture from deck that matches the cutout fixture ID provided."""
for cutout_fixture in deck_definition["cutoutFixtures"]:
Expand All @@ -43,7 +44,7 @@ def get_cutout_fixture(


def get_provided_addressable_area_names(
cutout_fixture_id: str, cutout_id: str, deck_definition: DeckDefinitionV5
cutout_fixture_id: str, cutout_id: str, deck_definition: DeckDefinitionV6
) -> List[str]:
"""Gets a list of the addressable areas provided by the cutout fixture on the cutout."""
cutout_fixture = get_cutout_fixture(cutout_fixture_id, deck_definition)
Expand All @@ -54,7 +55,7 @@ def get_provided_addressable_area_names(


def get_addressable_area_display_name(
addressable_area_name: str, deck_definition: DeckDefinitionV5
addressable_area_name: str, deck_definition: DeckDefinitionV6
) -> str:
"""Get the display name for an addressable area name."""
for addressable_area in deck_definition["locations"]["addressableAreas"]:
Expand All @@ -66,7 +67,7 @@ def get_addressable_area_display_name(


def get_potential_cutout_fixtures(
addressable_area_name: str, deck_definition: DeckDefinitionV5
addressable_area_name: str, deck_definition: DeckDefinitionV6
) -> Tuple[str, Set[PotentialCutoutFixture]]:
"""Given an addressable area name, gets the cutout ID associated with it and a set of potential fixtures."""
potential_fixtures = []
Expand Down Expand Up @@ -99,7 +100,7 @@ def get_addressable_area_from_name(
addressable_area_name: str,
cutout_position: DeckPoint,
base_slot: DeckSlotName,
deck_definition: DeckDefinitionV5,
deck_definition: DeckDefinitionV6,
) -> AddressableArea:
"""Given a name and a cutout position, get an addressable area on the deck."""
for addressable_area in deck_definition["locations"]["addressableAreas"]:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Deck data resource provider."""

from dataclasses import dataclass
from typing import List, Optional, cast
from typing_extensions import final
Expand All @@ -9,7 +10,7 @@
load as load_deck,
DEFAULT_DECK_DEFINITION_VERSION,
)
from opentrons_shared_data.deck.types import DeckDefinitionV5
from opentrons_shared_data.deck.types import DeckDefinitionV6
from opentrons_shared_data.labware.labware_definition import LabwareDefinition
from opentrons.types import DeckSlotName

Expand Down Expand Up @@ -44,10 +45,10 @@ def __init__(
self._deck_type = deck_type
self._labware_data = labware_data or LabwareDataProvider()

async def get_deck_definition(self) -> DeckDefinitionV5:
async def get_deck_definition(self) -> DeckDefinitionV6:
"""Get a labware definition given the labware's identification."""

def sync() -> DeckDefinitionV5:
def sync() -> DeckDefinitionV6:
return load_deck(
name=self._deck_type.value, version=DEFAULT_DECK_DEFINITION_VERSION
)
Expand All @@ -57,7 +58,7 @@ def sync() -> DeckDefinitionV5:
async def get_deck_fixed_labware(
self,
load_fixed_trash: bool,
deck_definition: DeckDefinitionV5,
deck_definition: DeckDefinitionV6,
deck_configuration: Optional[DeckConfigurationType] = None,
) -> List[DeckFixedLabware]:
"""Get a list of all labware fixtures from a given deck definition."""
Expand Down
11 changes: 6 additions & 5 deletions api/src/opentrons/protocol_engine/state/addressable_areas.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""Basic addressable area data state and store."""

from dataclasses import dataclass
from functools import cached_property
from typing import Dict, List, Optional, Set

from opentrons_shared_data.robot.types import RobotType, RobotDefinition
from opentrons_shared_data.deck.types import (
DeckDefinitionV5,
DeckDefinitionV6,
SlotDefV3,
CutoutFixture,
)
Expand Down Expand Up @@ -53,7 +54,7 @@ class AddressableAreaState:

potential_cutout_fixtures_by_cutout_id: Dict[str, Set[PotentialCutoutFixture]]

deck_definition: DeckDefinitionV5
deck_definition: DeckDefinitionV6

deck_configuration: Optional[DeckConfigurationType]
"""The host robot's full deck configuration.
Expand Down Expand Up @@ -94,7 +95,7 @@ class AddressableAreaState:
def _get_conflicting_addressable_areas_error_string(
potential_cutout_fixtures: Set[PotentialCutoutFixture],
loaded_addressable_areas: Dict[str, AddressableArea],
deck_definition: DeckDefinitionV5,
deck_definition: DeckDefinitionV6,
) -> str:
loaded_areas_on_cutout = set()
for fixture in potential_cutout_fixtures:
Expand Down Expand Up @@ -158,7 +159,7 @@ def __init__(
self,
deck_configuration: DeckConfigurationType,
config: Config,
deck_definition: DeckDefinitionV5,
deck_definition: DeckDefinitionV6,
robot_definition: RobotDefinition,
) -> None:
"""Initialize an addressable area store and its state."""
Expand Down Expand Up @@ -208,7 +209,7 @@ def handle_action(self, action: Action) -> None:

@staticmethod
def _get_addressable_areas_from_deck_configuration(
deck_config: DeckConfigurationType, deck_definition: DeckDefinitionV5
deck_config: DeckConfigurationType, deck_definition: DeckDefinitionV6
) -> Dict[str, AddressableArea]:
"""Return all addressable areas provided by the given deck configuration."""
addressable_areas = []
Expand Down
9 changes: 5 additions & 4 deletions api/src/opentrons/protocol_engine/state/labware.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Basic labware data state and store."""

from __future__ import annotations

from dataclasses import dataclass
Expand All @@ -17,7 +18,7 @@
)

from opentrons.protocol_engine.state import update_types
from opentrons_shared_data.deck.types import DeckDefinitionV5
from opentrons_shared_data.deck.types import DeckDefinitionV6
from opentrons_shared_data.gripper.constants import LABWARE_GRIP_FORCE
from opentrons_shared_data.labware.labware_definition import (
InnerWellGeometry,
Expand Down Expand Up @@ -109,7 +110,7 @@ class LabwareState:
labware_offsets_by_id: Dict[str, LabwareOffset]

definitions_by_uri: Dict[str, LabwareDefinition]
deck_definition: DeckDefinitionV5
deck_definition: DeckDefinitionV6


class LabwareStore(HasState[LabwareState], HandlesActions):
Expand All @@ -119,7 +120,7 @@ class LabwareStore(HasState[LabwareState], HandlesActions):

def __init__(
self,
deck_definition: DeckDefinitionV5,
deck_definition: DeckDefinitionV6,
deck_fixed_labware: Sequence[DeckFixedLabware],
) -> None:
"""Initialize a labware store and its state."""
Expand Down Expand Up @@ -418,7 +419,7 @@ def get_display_name(self, labware_id: str) -> str:
or self.get_definition(labware_id).metadata.displayName
)

def get_deck_definition(self) -> DeckDefinitionV5:
def get_deck_definition(self) -> DeckDefinitionV6:
"""Get the current deck definition."""
return self._state.deck_definition

Expand Down
5 changes: 3 additions & 2 deletions api/src/opentrons/protocol_engine/state/state.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""Protocol engine state management."""

from __future__ import annotations

from dataclasses import dataclass
from typing import Callable, Dict, List, Optional, Sequence, TypeVar
from typing_extensions import ParamSpec

from opentrons_shared_data.deck.types import DeckDefinitionV5
from opentrons_shared_data.deck.types import DeckDefinitionV6
from opentrons_shared_data.robot.types import RobotDefinition

from opentrons.protocol_engine.error_recovery_policy import ErrorRecoveryPolicy
Expand Down Expand Up @@ -177,7 +178,7 @@ def __init__(
self,
*,
config: Config,
deck_definition: DeckDefinitionV5,
deck_definition: DeckDefinitionV6,
deck_fixed_labware: Sequence[DeckFixedLabware],
robot_definition: RobotDefinition,
is_door_open: bool,
Expand Down
4 changes: 2 additions & 2 deletions api/tests/opentrons/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
from opentrons_shared_data.deck.types import (
RobotModel,
DeckDefinitionV3,
DeckDefinitionV5,
DeckDefinitionV6,
)
from opentrons_shared_data.deck import (
load as load_deck,
Expand Down Expand Up @@ -277,7 +277,7 @@ def deck_definition_name(robot_model: RobotModel) -> str:


@pytest.fixture
def deck_definition(deck_definition_name: str) -> DeckDefinitionV5:
def deck_definition(deck_definition_name: str) -> DeckDefinitionV6:
return load_deck(deck_definition_name, DEFAULT_DECK_DEFINITION_VERSION)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from opentrons_shared_data.deck import load as load_deck
from opentrons_shared_data.deck.types import (
DeckDefinitionV5,
DeckDefinitionV6,
SlotDefV3,
)
from opentrons_shared_data.pipette.types import PipetteNameType
Expand Down Expand Up @@ -95,15 +95,15 @@


@pytest.fixture(scope="session")
def ot2_standard_deck_def() -> DeckDefinitionV5:
def ot2_standard_deck_def() -> DeckDefinitionV6:
"""Get the OT-2 standard deck definition."""
return load_deck(STANDARD_OT2_DECK, 5)
return load_deck(STANDARD_OT2_DECK, 6)


@pytest.fixture(scope="session")
def ot3_standard_deck_def() -> DeckDefinitionV5:
def ot3_standard_deck_def() -> DeckDefinitionV6:
"""Get the OT-2 standard deck definition."""
return load_deck(STANDARD_OT3_DECK, 5)
return load_deck(STANDARD_OT3_DECK, 6)


@pytest.fixture(autouse=True)
Expand Down Expand Up @@ -199,7 +199,7 @@ def test_api_version(


def test_get_slot_definition(
ot2_standard_deck_def: DeckDefinitionV5, subject: ProtocolCore, decoy: Decoy
ot2_standard_deck_def: DeckDefinitionV6, subject: ProtocolCore, decoy: Decoy
) -> None:
"""It should return a deck slot's definition."""
expected_slot_def = cast(
Expand Down Expand Up @@ -1026,9 +1026,9 @@ def test_move_labware(
labwareId="labware-id",
newLocation=DeckSlotLocation(slotName=DeckSlotName.SLOT_5),
strategy=expected_strategy,
pickUpOffset=LabwareOffsetVector(x=4, y=5, z=6)
if pick_up_offset
else None,
pickUpOffset=(
LabwareOffsetVector(x=4, y=5, z=6) if pick_up_offset else None
),
dropOffset=LabwareOffsetVector(x=4, y=5, z=6) if drop_offset else None,
)
),
Expand Down Expand Up @@ -1712,7 +1712,7 @@ def test_get_deck_definition(
decoy: Decoy, mock_engine_client: EngineClient, subject: ProtocolCore
) -> None:
"""It should return the loaded deck definition from engine state."""
deck_definition = cast(DeckDefinitionV5, {"schemaVersion": "5"})
deck_definition = cast(DeckDefinitionV6, {"schemaVersion": "6"})

decoy.when(mock_engine_client.state.labware.get_deck_definition()).then_return(
deck_definition
Expand Down
9 changes: 5 additions & 4 deletions api/tests/opentrons/protocol_api/test_deck.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""Tests for opentrons.legacy.Deck."""

import inspect
from typing import cast, Dict

import pytest
from decoy import Decoy

from opentrons_shared_data.deck.types import DeckDefinitionV5, SlotDefV3
from opentrons_shared_data.deck.types import DeckDefinitionV6, SlotDefV3

from opentrons.motion_planning import adjacent_slots_getters as mock_adjacent_slots
from opentrons.protocols.api_support.types import APIVersion
Expand All @@ -23,10 +24,10 @@


@pytest.fixture
def deck_definition() -> DeckDefinitionV5:
def deck_definition() -> DeckDefinitionV6:
"""Get a deck definition value object."""
return cast(
DeckDefinitionV5,
DeckDefinitionV6,
{
"locations": {"addressableAreas": [], "calibrationPoints": []},
"cutoutFixtures": {},
Expand Down Expand Up @@ -81,7 +82,7 @@ def staging_slot_definitions_by_name() -> Dict[str, SlotDefV3]:
@pytest.fixture
def subject(
decoy: Decoy,
deck_definition: DeckDefinitionV5,
deck_definition: DeckDefinitionV6,
mock_protocol_core: ProtocolCore,
mock_core_map: LoadedCoreMap,
api_version: APIVersion,
Expand Down
Loading
Loading