Skip to content

Commit

Permalink
- addressing more feedback which pointed out that I am able to constr…
Browse files Browse the repository at this point in the history
…ain types that may be aspirated and dispensed to `Location`
  • Loading branch information
curtelsasser committed May 13, 2021
1 parent 6983b63 commit 03dc712
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
17 changes: 5 additions & 12 deletions api/src/opentrons/protocols/api_support/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ def determine_drop_target(
return location.top(-z_height)


def validate_can_aspirate(
location: Union[Labware, Well, types.Location]) -> None:
def validate_can_aspirate(location: types.Location) -> None:
""" Can one aspirate on the given `location` or not? This method is
pretty basic and will probably remain so (?) as the future holds neat
ambitions for how validation is implemented. And as robots become more
Expand Down Expand Up @@ -135,16 +134,10 @@ def validate_can_dispense(location: types.Location) -> None:
Raises:
RuntimeError:
"""
labware = location.labware.as_labware()
if labware.parent and labware.parent.is_tiprack:
if _is_tiprack(location):
raise RuntimeError("Cannot dispense to a tiprack")


def _is_tiprack(location: Union[Labware, Well, types.Location]) -> bool:
if isinstance(location, Labware):
return location.is_tiprack
elif isinstance(location, Well):
return location.parent.is_tiprack
else:
labware = location.labware.as_labware()
return labware.parent and labware.parent.is_tiprack
def _is_tiprack(location: types.Location) -> bool:
labware = location.labware.as_labware()
return labware.parent and labware.parent.is_tiprack
8 changes: 0 additions & 8 deletions api/tests/opentrons/protocols/api_support/test_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,8 @@ def test_determine_drop_target(
def test_validate_can_aspirate(ctx):
well_plate = ctx.load_labware('corning_96_wellplate_360ul_flat', 1)
tip_rack = ctx.load_labware('opentrons_96_tiprack_300ul', 2)
# test type `Labware`
validate_can_aspirate(well_plate)
# test type `Well`
validate_can_aspirate(well_plate.wells()[0])
# test type `Location`
validate_can_aspirate(well_plate.wells()[0].top())
with pytest.raises(RuntimeError):
validate_can_aspirate(tip_rack)
with pytest.raises(RuntimeError):
validate_can_aspirate(tip_rack.wells_by_name()['A1'])
with pytest.raises(RuntimeError):
validate_can_aspirate(tip_rack.wells_by_name()['A1'].top())

Expand Down

0 comments on commit 03dc712

Please sign in to comment.