Skip to content

Commit

Permalink
fix(api): restrict the labware that can be loaded/moved to the plate …
Browse files Browse the repository at this point in the history
…reader.
  • Loading branch information
vegano1 committed Oct 31, 2024
1 parent a74408d commit 4c2831e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api/src/opentrons/protocol_engine/commands/load_labware.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from ..resources import labware_validation, fixture_validation
from ..types import (
LabwareLocation,
ModuleLocation,
ModuleModel,
OnLabwareLocation,
DeckSlotLocation,
AddressableAreaLocation,
Expand Down Expand Up @@ -160,6 +162,13 @@ async def execute(
top_labware_definition=loaded_labware.definition,
bottom_labware_id=verified_location.labwareId,
)
# Labware needs to be 15mm or less to fit into the absorbance reader
elif isinstance(params.location, ModuleLocation):
module = self._state_view.modules.get(params.location.moduleId)
if module is not None and module.model == ModuleModel.ABSORBANCE_READER_V1:
self._state_view.labware.raise_if_labware_incompatible_with_plate_reader(
loaded_labware.labware_id
)

return SuccessData(
public=LoadLabwareResult(
Expand Down
9 changes: 9 additions & 0 deletions api/src/opentrons/protocol_engine/commands/move_labware.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
from opentrons.protocol_engine.resources.model_utils import ModelUtils
from opentrons.types import Point
from ..types import (
ModuleModel,
CurrentWell,
LabwareLocation,
DeckSlotLocation,
ModuleLocation,
OnLabwareLocation,
AddressableAreaLocation,
LabwareMovementStrategy,
Expand Down Expand Up @@ -188,6 +190,13 @@ async def execute(self, params: MoveLabwareParams) -> _ExecuteReturn: # noqa: C
raise LabwareMovementNotAllowedError(
"Cannot move a labware onto itself."
)
# Labware needs to be 15mm or less to fit into the absorbance reader
elif isinstance(available_new_location, ModuleLocation):
module = self._state_view.modules.get(available_new_location.moduleId)
if module is not None and module.model == ModuleModel.ABSORBANCE_READER_V1:
self._state_view.labware.raise_if_labware_incompatible_with_plate_reader(
params.labwareId
)

# Allow propagation of ModuleNotLoadedError.
new_offset_id = self._equipment.find_applicable_labware_offset_id(
Expand Down
28 changes: 28 additions & 0 deletions api/src/opentrons/protocol_engine/state/labware.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
}


# The max height of the labware that can fit in a plate reader
_PLATE_READER_MAX_LABWARE_Z_MM = 15


class LabwareLoadParams(NamedTuple):
"""Parameters required to load a labware in Protocol Engine."""

Expand Down Expand Up @@ -817,6 +821,30 @@ def raise_if_labware_in_location(
f"Labware {labware.loadName} is already present at {location}."
)

def raise_if_labware_incompatible_with_plate_reader(
self,
labware_id: str,
) -> None:
"""Raise an error if the labware is not compatible with the plate reader."""
labware_definition = self.get_definition(labware_id)
if labware_definition is not None:
number_of_wells = len(labware_definition.wells)
if number_of_wells != 96:
raise errors.LabwareMovementNotAllowedError(
f"Cannot move '{labware_definition.parameters.loadName}'"
f" into plate reader because the labware contains {number_of_wells}"
f" wells where 96 wells is expected."
)
elif (
labware_definition.dimensions.zDimension
> _PLATE_READER_MAX_LABWARE_Z_MM
):
raise errors.LabwareMovementNotAllowedError(
f"Cannot move '{labware_definition.parameters.loadName}'"
f" into plate reader because the maximum allowed labware height"
f" is {_PLATE_READER_MAX_LABWARE_Z_MM}mm."
)

def raise_if_labware_cannot_be_stacked( # noqa: C901
self, top_labware_definition: LabwareDefinition, bottom_labware_id: str
) -> None:
Expand Down

0 comments on commit 4c2831e

Please sign in to comment.