Skip to content

Commit

Permalink
Temp deck deck item and fixed tests for engine deck conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
TamarZanzouri committed Jul 27, 2023
1 parent 7c77ebd commit f0cd5b5
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 43 deletions.
24 changes: 19 additions & 5 deletions api/src/opentrons/motion_planning/deck_conflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ class HeaterShakerModule(_Module):
"""A Heater-Shaker module."""


@dataclass
class TemperatureModule(_Module):
"""A Temperature module."""


@dataclass
class ThermocyclerModule(_Module):
"""A Thermocycler module."""
Expand All @@ -79,13 +84,14 @@ class ThermocyclerModule(_Module):

@dataclass
class OtherModule(_Module):
"""A module that's not a Heater-Shaker or Thermocycler."""
"""A module that's not a Heater-Shaker or Thermocycler or Temperature."""


DeckItem = Union[
Labware,
HeaterShakerModule,
ThermocyclerModule,
TemperatureModule,
OtherModule,
]

Expand Down Expand Up @@ -291,8 +297,8 @@ def _create_flex_restrictions(item: DeckItem, location: int) -> List[_DeckRestri
)

if (
isinstance(item, HeaterShakerModule)
and location in _flex_slots_for_heater_shaker()
isinstance(item, (HeaterShakerModule, TemperatureModule))
and location in _flex_right_hand_slots()
):
restrictions.append(
_NoModule(
Expand Down Expand Up @@ -367,8 +373,16 @@ def _flex_slots_covered_by_thermocycler() -> Set[int]:
return {7, 10}


def _flex_slots_for_heater_shaker() -> Set[int]:
return {1, 3, 4, 6, 7, 9, 10, 12}
def _flex_right_left_hand_slots() -> List[int]:
return _flex_left_hand_slots() + _flex_left_hand_slots()


def _flex_left_hand_slots() -> List[int]:
return [1, 4, 7, 10]


def _flex_right_hand_slots() -> List[int]:
return [3, 6, 9, 12]


def _is_fixed_trash(item: DeckItem) -> bool:
Expand Down
8 changes: 8 additions & 0 deletions api/src/opentrons/protocol_api/core/engine/deck_conflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@ def _map_module(
is_semi_configuration=False,
),
)
elif module_type == ModuleType.TEMPERATURE:
return (
mapped_location,
wrapped_deck_conflict.TemperatureModule(
name_for_errors=name_for_errors,
highest_z_including_labware=highest_z_including_labware,
),
)
else:
return (
mapped_location,
Expand Down
69 changes: 31 additions & 38 deletions api/tests/opentrons/protocol_api/core/engine/test_deck_conflict.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Unit tests for the deck_conflict module."""

from decoy import Decoy, matchers
from decoy import Decoy
import pytest

from opentrons_shared_data.labware.dev_types import LabwareUri
Expand Down Expand Up @@ -38,36 +38,11 @@ def mock_state_view(


@pytest.mark.parametrize(
("robot_type", "deck_type"), [("OT-3 Standard", DeckType.OT3_STANDARD)]
)
def test_noop_if_ot3(decoy: Decoy, mock_state_view: StateView) -> None:
"""For now, it shouldn't do anything if it's an OT-3."""
deck_conflict.check(
engine_state=mock_state_view,
existing_labware_ids=["lw1", "lw2"],
existing_module_ids=["m1", "m2"],
new_labware_id="lw3",
)

deck_conflict.check(
engine_state=mock_state_view,
existing_labware_ids=["lw1", "lw2"],
existing_module_ids=["m1", "m2"],
new_module_id="m3",
)

decoy.verify(
wrapped_deck_conflict.check(
existing_items=matchers.Anything(),
new_item=matchers.Anything(),
new_location=matchers.Anything(),
),
times=0,
)


@pytest.mark.parametrize(
("robot_type", "deck_type"), [("OT-2 Standard", DeckType.OT2_STANDARD)]
("robot_type", "deck_type"),
[
("OT-2 Standard", DeckType.OT2_STANDARD),
("OT-3 Standard", DeckType.OT3_STANDARD),
],
)
def test_maps_labware_on_deck(decoy: Decoy, mock_state_view: StateView) -> None:
"""It should correcly map a labware that's loaded directly into a deck slot."""
Expand Down Expand Up @@ -114,12 +89,17 @@ def test_maps_labware_on_deck(decoy: Decoy, mock_state_view: StateView) -> None:
is_fixed_trash=True,
),
new_location=5,
robot_type=mock_state_view.config.robot_type,
)
)


@pytest.mark.parametrize(
("robot_type", "deck_type"), [("OT-2 Standard", DeckType.OT2_STANDARD)]
("robot_type", "deck_type"),
[
("OT-2 Standard", DeckType.OT2_STANDARD),
("OT-3 Standard", DeckType.OT3_STANDARD),
],
)
def test_maps_module_without_labware(decoy: Decoy, mock_state_view: StateView) -> None:
"""It should correctly map a module with no labware loaded atop it."""
Expand Down Expand Up @@ -159,12 +139,17 @@ def test_maps_module_without_labware(decoy: Decoy, mock_state_view: StateView) -
highest_z_including_labware=3.14159,
),
new_location=5,
robot_type=mock_state_view.config.robot_type,
)
)


@pytest.mark.parametrize(
("robot_type", "deck_type"), [("OT-2 Standard", DeckType.OT2_STANDARD)]
("robot_type", "deck_type"),
[
("OT-2 Standard", DeckType.OT2_STANDARD),
("OT-3 Standard", DeckType.OT3_STANDARD),
],
)
def test_maps_module_with_labware(decoy: Decoy, mock_state_view: StateView) -> None:
"""It should correctly map a module with a labware loaded atop it.
Expand Down Expand Up @@ -207,12 +192,17 @@ def test_maps_module_with_labware(decoy: Decoy, mock_state_view: StateView) -> N
highest_z_including_labware=3.14159,
),
new_location=5,
robot_type=mock_state_view.config.robot_type,
)
)


@pytest.mark.parametrize(
("robot_type", "deck_type"), [("OT-2 Standard", DeckType.OT2_STANDARD)]
("robot_type", "deck_type"),
[
("OT-2 Standard", DeckType.OT2_STANDARD),
("OT-3 Standard", DeckType.OT3_STANDARD),
],
)
@pytest.mark.parametrize("module_model", ModuleModel)
def test_maps_different_module_models(
Expand All @@ -237,12 +227,14 @@ def get_expected_mapping_result() -> wrapped_deck_conflict.DeckItem:
is_semi_configuration=False,
)
elif (
module_model is ModuleModel.MAGNETIC_MODULE_V1
or module_model is ModuleModel.MAGNETIC_MODULE_V2
or module_model is ModuleModel.TEMPERATURE_MODULE_V1
module_model is ModuleModel.TEMPERATURE_MODULE_V1
or module_model is ModuleModel.TEMPERATURE_MODULE_V2
or module_model is ModuleModel.MAGNETIC_BLOCK_V1
):
return wrapped_deck_conflict.TemperatureModule(
name_for_errors=expected_name_for_errors,
highest_z_including_labware=3.14159,
)
else:
return wrapped_deck_conflict.OtherModule(
name_for_errors=expected_name_for_errors,
highest_z_including_labware=3.14159,
Expand Down Expand Up @@ -278,5 +270,6 @@ def get_expected_mapping_result() -> wrapped_deck_conflict.DeckItem:
existing_items={},
new_item=expected_mapping_result,
new_location=5,
robot_type=mock_state_view.config.robot_type,
)
)

0 comments on commit f0cd5b5

Please sign in to comment.