Skip to content

Commit

Permalink
add labware defs to new def list and modify validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura-Danielle committed Dec 13, 2024
1 parent e01dcbe commit 5608ebd
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 1 deletion.
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 @@ -104,6 +105,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 @@ -39,6 +39,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 "stackableOnly" 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 @@ -837,6 +837,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
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ class LabwareRole(str, Enum):
fixture = "fixture"
adapter = "adapter"
maintenance = "maintenance"
stackableOnly = "stackableOnly"
lid = "lid"


Expand Down

0 comments on commit 5608ebd

Please sign in to comment.