Skip to content

Commit

Permalink
add validation and the definitions to the latest labware def list
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura-Danielle committed Jan 10, 2025
1 parent b1f6257 commit 40fe2d9
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/src/opentrons/protocol_engine/commands/load_labware.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ async def execute(
)
state_update.set_addressable_area_used(area_name)
elif isinstance(params.location, DeckSlotLocation):
self._state_view.labware.raise_if_labware_cannot_be_ondeck(
labware_id=params.labwareId
)
self._state_view.addressable_areas.raise_if_area_not_in_deck_configuration(
params.location.slotName.id
)
Expand Down
6 changes: 6 additions & 0 deletions api/src/opentrons/protocol_engine/commands/move_labware.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ async def execute(self, params: MoveLabwareParams) -> _ExecuteReturn: # noqa: C
self._state_view.labware.raise_if_labware_has_labware_on_top(
labware_id=params.labwareId
)

if isinstance(available_new_location, DeckSlotLocation):
self._state_view.labware.raise_if_labware_cannot_be_ondeck(
labware_id=params.labwareId
)

if isinstance(available_new_location, OnLabwareLocation):
self._state_view.labware.raise_if_labware_has_labware_on_top(
available_new_location.labwareId
Expand Down
2 changes: 2 additions & 0 deletions api/src/opentrons/protocol_engine/errors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
LiquidDoesNotExistError,
LabwareDefinitionDoesNotExistError,
LabwareCannotBeStackedError,
LabwareCannotSitOnDeckError,
LabwareIsInStackError,
LabwareOffsetDoesNotExistError,
LabwareIsNotTipRackError,
Expand Down Expand Up @@ -105,6 +106,7 @@
"LiquidDoesNotExistError",
"LabwareDefinitionDoesNotExistError",
"LabwareCannotBeStackedError",
"LabwareCannotSitOnDeckError",
"LabwareIsInStackError",
"LabwareOffsetDoesNotExistError",
"LabwareIsNotTipRackError",
Expand Down
13 changes: 13 additions & 0 deletions api/src/opentrons/protocol_engine/errors/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,19 @@ def __init__(
super().__init__(ErrorCodes.GENERAL_ERROR, message, details, wrapping)


class LabwareCannotSitOnDeckError(ProtocolEngineError):
"""Raised when a labware is incompatible with a deck slot."""

def __init__(
self,
message: Optional[str] = None,
details: Optional[Dict[str, Any]] = None,
wrapping: Optional[Sequence[EnumeratedError]] = None,
) -> None:
"""Build a LabwareCannotSitOnDeckError."""
super().__init__(ErrorCodes.GENERAL_ERROR, message, details, wrapping)


class LabwareIsInStackError(ProtocolEngineError):
"""Raised when trying to move to or physically interact with a labware that has another labware on top."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ def validate_labware_can_be_stacked(
return below_labware_load_name in top_labware_definition.stackingOffsetWithLabware


def validate_labware_can_be_ondeck(definition: LabwareDefinition) -> bool:
"""Validate that the labware being loaded onto the deck can sit in a slot."""
return (
definition.parameters.quirks is None
or "stackingOnly" not in definition.parameters.quirks
)


def validate_gripper_compatible(definition: LabwareDefinition) -> bool:
"""Validate that the labware definition does not have a quirk disallowing movement with gripper."""
return (
Expand Down
13 changes: 13 additions & 0 deletions api/src/opentrons/protocol_engine/state/labware.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,19 @@ def raise_if_labware_in_location(
f"Labware {labware.loadName} is already present at {location}."
)

def raise_if_labware_cannot_be_ondeck(
self,
location: OnDeckLabwareLocation,
labware_definition: LabwareDefinition,
) -> None:
"""Raise an error if the labware cannot be in the specified location."""
if isinstance(
location, (DeckSlotLocation, AddressableAreaLocation)
) and not labware_validation.validate_labware_can_be_ondeck(labware_definition):
raise errors.LabwareCannotSitOnDeckError(
f"{labware_definition.parameters.loadName} cannot sit in a slot by itself."
)

def raise_if_labware_incompatible_with_plate_reader(
self,
labware_definition: LabwareDefinition,
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/__tests__/labwareDefQuirks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const EXPECTED_VALID_QUIRKS = [
'gripperIncompatible',
'tiprackAdapterFor96Channel',
'stackingMaxFive',
'stackingOnly',
]

describe('check quirks for all labware defs', () => {
Expand Down
6 changes: 6 additions & 0 deletions shared-data/js/labware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ import thermoscientificnunc96Wellplate2000UlV1Uncasted from '../labware/definiti
import tipone96Tiprack200UlV1Uncasted from '../labware/definitions/2/tipone_96_tiprack_200ul/1.json'
import usascientific12Reservoir22MlV1Uncasted from '../labware/definitions/2/usascientific_12_reservoir_22ml/1.json'
import usascientific96Wellplate24MlDeepV1Uncasted from '../labware/definitions/2/usascientific_96_wellplate_2.4ml_deep/1.json'
import evotipsFlex96TiprackAdapterV1Uncasted from '../labware/definitions/2/evotips_flex_96_tiprack_adapter/1.json'
import evotipsOpentrons96LabwareV1Uncasted from '../labware/definitions/2/evotips_opentrons_96_labware/1.json'

// v1 legacy labware definitions

Expand Down Expand Up @@ -297,6 +299,8 @@ const thermoscientificnunc96Wellplate2000UlV1 = thermoscientificnunc96Wellplate2
const tipone96Tiprack200UlV1 = tipone96Tiprack200UlV1Uncasted as LabwareDefinition2
const usascientific12Reservoir22MlV1 = usascientific12Reservoir22MlV1Uncasted as LabwareDefinition2
const usascientific96Wellplate24MlDeepV1 = usascientific96Wellplate24MlDeepV1Uncasted as LabwareDefinition2
const evotipsFlex96TiprackAdapterV1 = evotipsFlex96TiprackAdapterV1Uncasted as LabwareDefinition2
const evotipsOpentrons96LabwareV1 = evotipsOpentrons96LabwareV1Uncasted as LabwareDefinition2

// cast v1 defs

Expand Down Expand Up @@ -466,6 +470,8 @@ const latestDefs = {
tipone96Tiprack200UlV1,
usascientific12Reservoir22MlV1,
usascientific96Wellplate24MlDeepV1,
evotipsFlex96TiprackAdapterV1,
evotipsOpentrons96LabwareV1,
}
// labware definitions
const getAllLabwareDefs = (): Record<
Expand Down

0 comments on commit 40fe2d9

Please sign in to comment.