Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
"""Test labware definition ."""
from opentrons.protocol_api import ProtocolContext, ParameterContext
from opentrons.protocol_api.module_contexts import HeaterShakerContext


metadata = {
"protocolName": "labware definition checker ",
"author": "Opentrons <[email protected]>",
"source": "Protocol Library",
}

requirements = {"robotType": "Flex", "apiLevel": "2.23"}


def add_parameters(parameters: ParameterContext) -> None:
"""Parameters."""
parameters.add_str(
variable_name="labware_type",
display_name="Labware Type",
description="Type of Labware",
choices=[
{
"display_name": "Axygen 500 ul Well Plate",
"value": "axygen_96_wellplate_500ul",
},
{
"display_name": "Corn96Wellplate 360 ul Lid",
"value": "corning_96_wellplate_360ul_lid",
},
{"display_name": "SMC384well Read Plate", "value": "smc_384_read_plate"},
{
"display_name": "ibidi96 SqrWellFltBtmPlt300µL",
"value": "ibidi_96_square_well_plate_300ul",
},
],
default="axygen_96_wellplate_500ul",
)
parameters.add_bool(
variable_name="heater_shaker",
display_name="Heater Shaker Use",
description="If true, heater shaker is used.",
default=False,
)


def run(protocol: ProtocolContext) -> None:
"""Protocol."""
labware_type = protocol.params.labware_type # type: ignore[attr-defined]
heater_shaker_enabled = protocol.params.heater_shaker # type: ignore[attr-defined]

# Lid loading
if labware_type == "corning_96_wellplate_360ul_lid":
protocol.load_lid_stack(labware_type, "C3", 1)
labware = protocol.load_labware("ibidi_96_square_well_plate_300ul", "D3")
for _ in range(3):
protocol.move_lid("C3", labware, use_gripper=True)
protocol.move_lid(labware, "C3", use_gripper=True)
else:
labware = protocol.load_labware(labware_type, "D3")
# load pipette and tip rack
tip_rack = protocol.load_labware("opentrons_flex_96_tiprack_200ul", "D2")
pipette = protocol.load_instrument(
"flex_8channel_1000", "left", tip_racks=[tip_rack]
)

# pick up tip
pipette.pick_up_tip()

# move tip to positions
pipette.move_to(labware["A6"].top(z=1))
protocol.pause("Check top height with shim")
pipette.move_to(labware["A6"].bottom(z=1))
protocol.pause("Check bottom height with shim")

# Optional heater shaker use
if heater_shaker_enabled:
hsh: HeaterShakerContext = protocol.load_module(
"heaterShakerModuleV1", "D1"
) # type: ignore[assignment]
hsh.close_labware_latch()
adapter = hsh.load_adapter("opentrons_universal_flat_adapter")
hsh.open_labware_latch()
protocol.move_labware(labware, adapter, use_gripper=True)
hsh.close_labware_latch()

pipette.move_to(labware["A6"].top(z=1))
protocol.pause("Check top height with shim")

pipette.return_tip()
4 changes: 2 additions & 2 deletions api/src/opentrons/protocol_api/core/engine/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,8 +1094,8 @@ def define_liquid(
display_color=(liquid.displayColor.root if liquid.displayColor else None),
)

def define_liquid_class(self, name: str, version: int) -> LiquidClass:
"""Define a liquid class for use in transfer functions."""
def get_liquid_class(self, name: str, version: int) -> LiquidClass:
"""Get an instance of a built-in liquid class."""
try:
# Check if we have already loaded this liquid class' definition
liquid_class_def = self._liquid_class_def_cache[(name, version)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,8 @@ def define_liquid(
"""Define a liquid to load into a well."""
assert False, "define_liquid only supported on engine core"

def define_liquid_class(self, name: str, version: int) -> LiquidClass:
"""Define a liquid class."""
def get_liquid_class(self, name: str, version: int) -> LiquidClass:
"""Get an instance of a built-in liquid class."""
assert False, "define_liquid_class is only supported on engine core"

def get_labware_location(
Expand Down
4 changes: 2 additions & 2 deletions api/src/opentrons/protocol_api/core/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ def define_liquid(
"""Define a liquid to load into a well."""

@abstractmethod
def define_liquid_class(self, name: str, version: int) -> LiquidClass:
"""Define a liquid class for use in transfer functions."""
def get_liquid_class(self, name: str, version: int) -> LiquidClass:
"""Get an instance of a built-in liquid class."""

@abstractmethod
def get_labware_location(
Expand Down
17 changes: 9 additions & 8 deletions api/src/opentrons/protocol_api/protocol_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1371,22 +1371,23 @@ def define_liquid(
display_color=display_color,
)

@requires_version(2, 23)
def define_liquid_class(
@requires_version(2, 24)
def get_liquid_class(
self,
name: str,
) -> LiquidClass:
"""
Define a liquid class for use in the protocol.
..
This is intended for Opentrons internal use only and is not a guaranteed API.
Get an instance of a built-in liquid class for use in the protocol.

:meta private:
Args:
name: Name of an Opentrons-defined liquid class.

:raises: ``LiquidClassDefinitionDoesNotExist``: if the specified liquid class does not exist.
"""
return self._core.define_liquid_class(name=name, version=DEFAULT_LC_VERSION)
return self._core.get_liquid_class(name=name, version=DEFAULT_LC_VERSION)

@requires_version(2, 24)
def define_custom_liquid_class(
def define_liquid_class(
self,
name: str,
properties: Dict[str, Dict[str, TransferPropertiesDict]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1876,21 +1876,21 @@ def test_define_liquid_class(
decoy.when(liquid_classes.load_definition("water", version=123)).then_return(
minimal_liquid_class_def1
)
assert subject.define_liquid_class("water", 123) == expected_liquid_class
assert subject.get_liquid_class("water", 123) == expected_liquid_class

# Test that different version number works
decoy.when(liquid_classes.load_definition("water", version=456)).then_return(
minimal_liquid_class_def2
)
different_liquid_class = subject.define_liquid_class("water", 456)
different_liquid_class = subject.get_liquid_class("water", 456)
assert different_liquid_class.name == "water2"
assert different_liquid_class.display_name == "water 2"

# Test that definition caching works
decoy.when(liquid_classes.load_definition("water", version=123)).then_return(
minimal_liquid_class_def2
)
assert subject.define_liquid_class("water", 123) == expected_liquid_class
assert subject.get_liquid_class("water", 123) == expected_liquid_class


def test_get_labware_location_deck_slot(
Expand Down
12 changes: 6 additions & 6 deletions api/tests/opentrons/protocol_api/test_protocol_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1797,11 +1797,11 @@ def test_define_liquid_class(
expected_liquid_class = LiquidClass(
_name="volatile_100", _display_name="volatile 100%", _by_pipette_setting={}
)
decoy.when(mock_core.define_liquid_class("volatile_90", 1)).then_return(
decoy.when(mock_core.get_liquid_class("volatile_90", 1)).then_return(
expected_liquid_class
)
decoy.when(mock_core.robot_type).then_return(robot_type)
assert subject.define_liquid_class("volatile_90") == expected_liquid_class
assert subject.get_liquid_class("volatile_90") == expected_liquid_class


@pytest.mark.parametrize("robot_type", ["OT-2 Standard", "OT-3 Standard"])
Expand All @@ -1813,7 +1813,7 @@ def test_define_new_custom_liquid_class_from_dict(
minimal_transfer_properties_dict: Dict[str, Dict[str, TransferPropertiesDict]],
) -> None:
"""It should define a custom liquid class."""
my_liquid_class = subject.define_custom_liquid_class(
my_liquid_class = subject.define_liquid_class(
name="my_liquid",
properties=minimal_transfer_properties_dict,
display_name="My liquid",
Expand Down Expand Up @@ -1857,7 +1857,7 @@ def test_customize_existing_liquid_class(
== 4
)

my_liquid_class = subject.define_custom_liquid_class(
my_liquid_class = subject.define_liquid_class(
name="my_liquid",
properties=minimal_transfer_properties_dict,
base_liquid_class=existing_glycerol_class,
Expand All @@ -1878,7 +1878,7 @@ def test_customize_existing_liquid_class(
)

# Test that new entries are created for pipettes and tipracks not present in the base liquid class
lc_with_custom_pip_n_tip = subject.define_custom_liquid_class(
lc_with_custom_pip_n_tip = subject.define_liquid_class(
name="my_liquid_2",
properties=custom_pip_n_tip_transfer_properties_dict,
base_liquid_class=existing_glycerol_class,
Expand All @@ -1899,7 +1899,7 @@ def test_customize_existing_liquid_class(
"opentrons/opentrons_flex_96_tiprack_50ul/1"
]
}
lc_with_new_tip_entry = subject.define_custom_liquid_class(
lc_with_new_tip_entry = subject.define_liquid_class(
name="my_liquid_3",
properties=modified_custom_dict,
base_liquid_class=lc_with_custom_pip_n_tip,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@pytest.mark.ot3_only
@pytest.mark.parametrize(
"simulated_protocol_context", [("2.23", "Flex")], indirect=True
"simulated_protocol_context", [("2.24", "Flex")], indirect=True
)
def test_liquid_class_creation_and_property_fetching(
simulated_protocol_context: ProtocolContext,
Expand All @@ -20,7 +20,7 @@ def test_liquid_class_creation_and_property_fetching(
tiprack = simulated_protocol_context.load_labware(
"opentrons_flex_96_tiprack_50ul", "D1"
)
water = simulated_protocol_context.define_liquid_class("water")
water = simulated_protocol_context.get_liquid_class("water")

assert water.name == "water"
assert water.display_name == "Aqueous"
Expand All @@ -44,7 +44,7 @@ def test_liquid_class_creation_and_property_fetching(
water.display_name = "bar" # type: ignore

with pytest.raises(ValueError, match="Liquid class definition not found"):
simulated_protocol_context.define_liquid_class("non-existent-liquid")
simulated_protocol_context.get_liquid_class("non-existent-liquid")


@pytest.mark.ot3_only
Expand All @@ -61,7 +61,7 @@ def test_custom_liquid_class_creation_and_property_fetching(
tiprack = simulated_protocol_context.load_labware(
"opentrons_flex_96_tiprack_50ul", "D1"
)
custom_water = simulated_protocol_context.define_custom_liquid_class(
custom_water = simulated_protocol_context.define_liquid_class(
name="water_50",
properties=minimal_transfer_properties_dict,
display_name="Custom Aqueous",
Expand Down
Loading
Loading