From 12d7673ac59559225a7652ee68496df520828914 Mon Sep 17 00:00:00 2001 From: Laura Cox Date: Wed, 30 Oct 2024 21:45:53 +0200 Subject: [PATCH] fix pip dict related commands --- .../instruments/ot2/pipette.py | 1 - .../instruments/ot2/pipette_handler.py | 1 - .../instruments/ot3/pipette.py | 1 - .../instruments/ot3/pipette_handler.py | 1 - api/src/opentrons/protocol_api/__init__.py | 31 ++++++++++++------- .../protocol_api/core/engine/robot.py | 16 +++++----- api/src/opentrons/protocol_api/core/robot.py | 1 + 7 files changed, 30 insertions(+), 22 deletions(-) diff --git a/api/src/opentrons/hardware_control/instruments/ot2/pipette.py b/api/src/opentrons/hardware_control/instruments/ot2/pipette.py index 376e06d44038..7fc15c4c2d3a 100644 --- a/api/src/opentrons/hardware_control/instruments/ot2/pipette.py +++ b/api/src/opentrons/hardware_control/instruments/ot2/pipette.py @@ -635,7 +635,6 @@ def as_dict(self) -> "Pipette.DictType": "versioned_tip_overlap": self.tip_overlap, "back_compat_names": self._config.pipette_backcompat_names, "supported_tips": self.liquid_class.supported_tips, - "plunger_positions": self.plunger_positions, } ) return self._config_as_dict diff --git a/api/src/opentrons/hardware_control/instruments/ot2/pipette_handler.py b/api/src/opentrons/hardware_control/instruments/ot2/pipette_handler.py index fb74c002810b..f61547dfd3c0 100644 --- a/api/src/opentrons/hardware_control/instruments/ot2/pipette_handler.py +++ b/api/src/opentrons/hardware_control/instruments/ot2/pipette_handler.py @@ -221,7 +221,6 @@ def get_attached_instrument(self, mount: MountType) -> PipetteDict: "back_compat_names", "supported_tips", "lld_settings", - "plunger_positions", ] instr_dict = instr.as_dict() diff --git a/api/src/opentrons/hardware_control/instruments/ot3/pipette.py b/api/src/opentrons/hardware_control/instruments/ot3/pipette.py index 5659a20ca90a..109747ea1b9d 100644 --- a/api/src/opentrons/hardware_control/instruments/ot3/pipette.py +++ b/api/src/opentrons/hardware_control/instruments/ot3/pipette.py @@ -585,7 +585,6 @@ def as_dict(self) -> "Pipette.DictType": "versioned_tip_overlap": self.tip_overlap, "back_compat_names": self._config.pipette_backcompat_names, "supported_tips": self.liquid_class.supported_tips, - "plunger_positions": self.plunger_positions, } ) return self._config_as_dict diff --git a/api/src/opentrons/hardware_control/instruments/ot3/pipette_handler.py b/api/src/opentrons/hardware_control/instruments/ot3/pipette_handler.py index fd637445f955..c9ac53350e92 100644 --- a/api/src/opentrons/hardware_control/instruments/ot3/pipette_handler.py +++ b/api/src/opentrons/hardware_control/instruments/ot3/pipette_handler.py @@ -237,7 +237,6 @@ def get_attached_instrument(self, mount: OT3Mount) -> PipetteDict: "back_compat_names", "supported_tips", "lld_settings", - "plunger_positions", ] instr_dict = instr.as_dict() diff --git a/api/src/opentrons/protocol_api/__init__.py b/api/src/opentrons/protocol_api/__init__.py index 543d207769df..077004d0792f 100644 --- a/api/src/opentrons/protocol_api/__init__.py +++ b/api/src/opentrons/protocol_api/__init__.py @@ -30,7 +30,16 @@ ) from .disposal_locations import TrashBin, WasteChute from ._liquid import Liquid -from ._types import OFF_DECK, PLUNGER_BLOWOUT, PLUNGER_TOP, PLUNGER_BOTTOM, PLUNGER_DROPTIP, ASPIRATE_ACTION, DISPENSE_ACTION, BLOWOUT_ACTION +from ._types import ( + OFF_DECK, + PLUNGER_BLOWOUT, + PLUNGER_TOP, + PLUNGER_BOTTOM, + PLUNGER_DROPTIP, + ASPIRATE_ACTION, + DISPENSE_ACTION, + BLOWOUT_ACTION, +) from ._nozzle_layout import ( COLUMN, PARTIAL_COLUMN, @@ -68,22 +77,22 @@ "Well", "Liquid", "Parameters", - # Partial Tip types + # Partial Tip types "COLUMN", "PARTIAL_COLUMN", "SINGLE", "ROW", "ALL", - # Deck location types + # Deck location types "OFF_DECK", - # Pipette plunger types - "PLUNGER_BLOWOUT", - "PLUNGER_TOP", - "PLUNGER_BOTTOM", - "PLUNGER_DROPTIP", - "ASPIRATE_ACTION", - "DISPENSE_ACTION", - "BLOWOUT_ACTION", + # Pipette plunger types + "PLUNGER_BLOWOUT", + "PLUNGER_TOP", + "PLUNGER_BOTTOM", + "PLUNGER_DROPTIP", + "ASPIRATE_ACTION", + "DISPENSE_ACTION", + "BLOWOUT_ACTION", "RuntimeParameterRequiredError", "CSVParameter", # For internal Opentrons use only: diff --git a/api/src/opentrons/protocol_api/core/engine/robot.py b/api/src/opentrons/protocol_api/core/engine/robot.py index e919fc1c16ba..0fbb2356e56d 100644 --- a/api/src/opentrons/protocol_api/core/engine/robot.py +++ b/api/src/opentrons/protocol_api/core/engine/robot.py @@ -2,6 +2,7 @@ from opentrons.hardware_control import SyncHardwareAPI from opentrons.types import Mount, MountType, Point, AxisType, AxisMapType +from opentrons_shared_data.pipette import types as pip_types from opentrons_shared_data.pipette.ul_per_mm import ( piecewise_volume_conversion, PIPETTING_FUNCTION_FALLBACK_VERSION, @@ -76,7 +77,7 @@ def get_plunger_position_from_name( maybe_pipette_state = self._sync_hardware_api.get_attached_instrument(mount) if not maybe_pipette_state: return 0.0 - return maybe_pipette_state.plunger_positions[position_name.value] + return maybe_pipette_state["plunger_positions"][position_name.value] def get_plunger_position_from_volume( self, mount: Mount, volume: float, action: PlungerPositionTypes, robot_type: str @@ -84,22 +85,23 @@ def get_plunger_position_from_volume( maybe_pipette_state = self._sync_hardware_api.get_attached_instrument(mount) if not maybe_pipette_state: return 0.0 - tip_settings = maybe_pipette_state.supported_tips[ - maybe_pipette_state.working_volume - ] - + converted_working_volume = pip_types.PipetteTipType.check_and_return_type( + maybe_pipette_state["working_volume"], maybe_pipette_state["max_volume"] + ) + tip_settings = maybe_pipette_state["supported_tips"][converted_working_volume] + plunger_bottom = maybe_pipette_state["plunger_positions"]["bottom"] if robot_type == "OT-2 Standard": convert_volume = self._ul_per_mm_conversion( tip_settings, volume, action, PIPETTING_FUNCTION_FALLBACK_VERSION ) mm = volume / convert_volume - position = maybe_pipette_state.plunger_positions.bottom + mm + position = plunger_bottom + mm else: convert_volume = self._ul_per_mm_conversion( tip_settings, volume, action, PIPETTING_FUNCTION_LATEST_VERSION ) mm = volume / convert_volume - position = maybe_pipette_state.plunger_positions.bottom - mm + position = plunger_bottom - mm return round(position, 6) def move_to(self, mount: Mount, destination: Point, speed: Optional[float]) -> None: diff --git a/api/src/opentrons/protocol_api/core/robot.py b/api/src/opentrons/protocol_api/core/robot.py index 03955f336159..6542ae5ff1c6 100644 --- a/api/src/opentrons/protocol_api/core/robot.py +++ b/api/src/opentrons/protocol_api/core/robot.py @@ -4,6 +4,7 @@ from opentrons.types import AxisMapType, Mount, Point from opentrons.protocol_api._types import PlungerPositionTypes, PipetteActionTypes + class AbstractRobot(ABC): @abstractmethod def get_pipette_type_from_engine(self, mount: Union[Mount, str]) -> Optional[str]: