From 867258a44418674629bc7dbc0e5facfb1b5a0b1b Mon Sep 17 00:00:00 2001 From: CaseyBatten Date: Fri, 30 Aug 2024 16:33:37 -0400 Subject: [PATCH 1/2] introduce stringify for referencing multiple wells simultaneously on a tiprack in simulate --- api/src/opentrons/legacy_commands/commands.py | 14 +++- api/src/opentrons/legacy_commands/helpers.py | 71 ++++++++++++++++++- 2 files changed, 82 insertions(+), 3 deletions(-) diff --git a/api/src/opentrons/legacy_commands/commands.py b/api/src/opentrons/legacy_commands/commands.py index 68b6f1a0595..9499d955b4c 100755 --- a/api/src/opentrons/legacy_commands/commands.py +++ b/api/src/opentrons/legacy_commands/commands.py @@ -2,7 +2,12 @@ from typing import TYPE_CHECKING, List, Union, overload -from .helpers import stringify_location, stringify_disposal_location, listify +from .helpers import ( + stringify_location, + stringify_disposal_location, + listify, + stringify_pickup_location_range, +) from . import types as command_types from opentrons.types import Location @@ -247,7 +252,12 @@ def return_tip() -> command_types.ReturnTipCommand: def pick_up_tip( instrument: InstrumentContext, location: Well ) -> command_types.PickUpTipCommand: - location_text = stringify_location(location) + if instrument._core.get_active_channels() < instrument.channels: + location_text = stringify_pickup_location_range( + instrument._core.get_nozzle_map(), location + ) + else: + location_text = stringify_location(location) text = f"Picking up tip from {location_text}" return { "name": command_types.PICK_UP_TIP, diff --git a/api/src/opentrons/legacy_commands/helpers.py b/api/src/opentrons/legacy_commands/helpers.py index b3de03de4bc..9f692f43816 100644 --- a/api/src/opentrons/legacy_commands/helpers.py +++ b/api/src/opentrons/legacy_commands/helpers.py @@ -5,7 +5,7 @@ from opentrons.protocol_api.disposal_locations import TrashBin, WasteChute from opentrons.protocol_api._types import OffDeckType from opentrons.types import Location, DeckLocation - +from opentrons.hardware_control.nozzle_manager import NozzleConfigurationType, NozzleMap CommandLocation = Union[Location, Well] @@ -41,6 +41,75 @@ def stringify_location(location: Union[CommandLocation, List[CommandLocation]]) return ", ".join(loc_str_list) +def stringify_pickup_location_range( # noqa: C901 + nozzle_map: NozzleMap, location: Well +) -> str: + if nozzle_map.configuration == NozzleConfigurationType.SINGLE: + loc_str_list = [_stringify_new_loc(location)] + else: + labware_columns = location.parent.columns() + critical_column = 0 + critical_row = 0 + for column in labware_columns: + if location in column: + critical_row = column.index(location) + critical_column = labware_columns.index(column) + + if nozzle_map.starting_nozzle == "A1": + last_well_col = len(labware_columns) - 1 + last_well_row = len(labware_columns[0]) - 1 + if critical_column + len(nozzle_map.columns) < len(labware_columns): + last_well_col = critical_column + (len(nozzle_map.columns) - 1) + if critical_row + len(nozzle_map.rows) < len( + labware_columns[critical_column] + ): + last_well_row = critical_row + (len(nozzle_map.rows) - 1) + + last_well = labware_columns[last_well_col][last_well_row] + loc_str_list = [location.well_name + "-" + _stringify_new_loc(last_well)] + + elif nozzle_map.starting_nozzle == "A12": + last_well_col = 0 + last_well_row = len(labware_columns[0]) - 1 + if critical_column - len(nozzle_map.columns) >= 0: + last_well_col = critical_column - (len(nozzle_map.columns) - 1) + if critical_row + len(nozzle_map.rows) < len( + labware_columns[critical_column] + ): + last_well_row = critical_row + (len(nozzle_map.rows) - 1) + + last_well = labware_columns[last_well_col][last_well_row] + loc_str_list = [location.well_name + "-" + _stringify_new_loc(last_well)] + + elif nozzle_map.starting_nozzle == "H1": + datastr = "" + first_well_col = len(labware_columns) - 1 + first_well_row = 0 + if critical_column + len(nozzle_map.columns) < len(labware_columns): + first_well_col = critical_column + (len(nozzle_map.columns) - 1) + if critical_row - len(nozzle_map.rows) >= 0: + datastr = "This should be true" + first_well_row = critical_row - (len(nozzle_map.rows) - 1) + + first_well = labware_columns[first_well_col][first_well_row] + loc_str_list = [ + first_well.well_name + "-" + _stringify_new_loc(location) + datastr + ] + + elif nozzle_map.starting_nozzle == "H12": + first_well_col = 0 + first_well_row = 0 + if critical_column - len(nozzle_map.columns) >= 0: + first_well_col = critical_column - (len(nozzle_map.columns) - 1) + if critical_row - len(nozzle_map.rows) >= 0: + first_well_row = critical_row - (len(nozzle_map.rows) - 1) + + first_well = labware_columns[first_well_col][first_well_row] + loc_str_list = [first_well.well_name + "-" + _stringify_new_loc(location)] + + return ", ".join(loc_str_list) + + def stringify_disposal_location(location: Union[TrashBin, WasteChute]) -> str: if isinstance(location, TrashBin): return f"Trash Bin on slot {location.location.id}" From 19d805926881d02fb402b54045806d1dc699b506 Mon Sep 17 00:00:00 2001 From: CaseyBatten Date: Fri, 30 Aug 2024 16:35:15 -0400 Subject: [PATCH 2/2] removal of data string --- api/src/opentrons/legacy_commands/helpers.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/api/src/opentrons/legacy_commands/helpers.py b/api/src/opentrons/legacy_commands/helpers.py index 9f692f43816..20df322d719 100644 --- a/api/src/opentrons/legacy_commands/helpers.py +++ b/api/src/opentrons/legacy_commands/helpers.py @@ -82,19 +82,15 @@ def stringify_pickup_location_range( # noqa: C901 loc_str_list = [location.well_name + "-" + _stringify_new_loc(last_well)] elif nozzle_map.starting_nozzle == "H1": - datastr = "" first_well_col = len(labware_columns) - 1 first_well_row = 0 if critical_column + len(nozzle_map.columns) < len(labware_columns): first_well_col = critical_column + (len(nozzle_map.columns) - 1) if critical_row - len(nozzle_map.rows) >= 0: - datastr = "This should be true" first_well_row = critical_row - (len(nozzle_map.rows) - 1) first_well = labware_columns[first_well_col][first_well_row] - loc_str_list = [ - first_well.well_name + "-" + _stringify_new_loc(location) + datastr - ] + loc_str_list = [first_well.well_name + "-" + _stringify_new_loc(location)] elif nozzle_map.starting_nozzle == "H12": first_well_col = 0