From 1a102543f7e84226a1b4c6df002ee857a4e96846 Mon Sep 17 00:00:00 2001 From: caila-marashaj Date: Tue, 22 Apr 2025 13:52:54 -0400 Subject: [PATCH 1/2] retarget onto edge --- .../opentrons/protocol_api/core/engine/well.py | 16 ++++++++++++++++ .../protocol_api/core/legacy/legacy_well_core.py | 8 ++++++++ api/src/opentrons/protocol_api/core/well.py | 8 ++++++++ api/src/opentrons/protocol_api/labware.py | 10 ++++++++++ 4 files changed, 42 insertions(+) diff --git a/api/src/opentrons/protocol_api/core/engine/well.py b/api/src/opentrons/protocol_api/core/engine/well.py index e18bdb8ecf6a..7b4e195515b4 100644 --- a/api/src/opentrons/protocol_api/core/engine/well.py +++ b/api/src/opentrons/protocol_api/core/engine/well.py @@ -210,3 +210,19 @@ def get_liquid_volume(self) -> LiquidTrackingType: return self._engine_client.state.geometry.get_current_well_volume( labware_id=labware_id, well_name=well_name ) + + def height_from_volume(self, volume: LiquidTrackingType) -> LiquidTrackingType: + """Return the height in a well corresponding to a given volume.""" + labware_id = self.labware_id + well_name = self._name + return self._engine_client.state.geometry.get_well_height_at_volume( + labware_id=labware_id, well_name=well_name, volume=volume + ) + + def volume_from_height(self, height: LiquidTrackingType) -> LiquidTrackingType: + """Return the volume contained in a well at any height.""" + labware_id = self.labware_id + well_name = self._name + return self._engine_client.state.geometry.get_well_volume_at_height( + labware_id=labware_id, well_name=well_name, height=height + ) diff --git a/api/src/opentrons/protocol_api/core/legacy/legacy_well_core.py b/api/src/opentrons/protocol_api/core/legacy/legacy_well_core.py index e0a12039c518..4bcbb8ca5142 100644 --- a/api/src/opentrons/protocol_api/core/legacy/legacy_well_core.py +++ b/api/src/opentrons/protocol_api/core/legacy/legacy_well_core.py @@ -142,6 +142,14 @@ def get_liquid_volume(self) -> LiquidTrackingType: """Get the current well volume.""" return 0.0 + def height_from_volume(self, volume: LiquidTrackingType) -> LiquidTrackingType: + """Return the height in a well corresponding to a given volume.""" + return 0.0 + + def volume_from_height(self, height: LiquidTrackingType) -> LiquidTrackingType: + """Return the volume contained in a well at any height.""" + return 0.0 + # TODO(mc, 2022-10-28): is this used and/or necessary? def __repr__(self) -> str: """Use the well's display name as its repr.""" diff --git a/api/src/opentrons/protocol_api/core/well.py b/api/src/opentrons/protocol_api/core/well.py index d02cea5cb24b..c3e081df6b90 100644 --- a/api/src/opentrons/protocol_api/core/well.py +++ b/api/src/opentrons/protocol_api/core/well.py @@ -103,5 +103,13 @@ def current_liquid_height(self) -> LiquidTrackingType: def get_liquid_volume(self) -> LiquidTrackingType: """Get the current volume within a well.""" + @abstractmethod + def height_from_volume(self, volume: LiquidTrackingType) -> LiquidTrackingType: + """Return the height in a well corresponding to a given volume.""" + + @abstractmethod + def volume_from_height(self, height: LiquidTrackingType) -> LiquidTrackingType: + """Return the volume contained in a well at any height.""" + WellCoreType = TypeVar("WellCoreType", bound=AbstractWellCore) diff --git a/api/src/opentrons/protocol_api/labware.py b/api/src/opentrons/protocol_api/labware.py index 7c0b3fd4b6cf..30fc313b36ab 100644 --- a/api/src/opentrons/protocol_api/labware.py +++ b/api/src/opentrons/protocol_api/labware.py @@ -346,6 +346,16 @@ def current_liquid_volume(self) -> LiquidTrackingType: """Get the current liquid volume in a well.""" return self._core.get_liquid_volume() + @requires_version(2, 21) + def volume_from_height(self, height: LiquidTrackingType) -> LiquidTrackingType: + """Return the volume contained in a well at any height.""" + return self._core.volume_from_height(height) + + @requires_version(2, 21) + def height_from_volume(self, volume: LiquidTrackingType) -> LiquidTrackingType: + """Return the height in a well corresponding to a given volume.""" + return self._core.height_from_volume(volume) + @requires_version(2, 21) def estimate_liquid_height_after_pipetting( self, From 6da5c546e817ecbc9821793f8fe3c8504b8e8da1 Mon Sep 17 00:00:00 2001 From: caila-marashaj Date: Tue, 22 Apr 2025 14:05:08 -0400 Subject: [PATCH 2/2] api v 24 --- api/src/opentrons/protocol_api/labware.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/opentrons/protocol_api/labware.py b/api/src/opentrons/protocol_api/labware.py index 30fc313b36ab..b67ca1c0337f 100644 --- a/api/src/opentrons/protocol_api/labware.py +++ b/api/src/opentrons/protocol_api/labware.py @@ -346,12 +346,12 @@ def current_liquid_volume(self) -> LiquidTrackingType: """Get the current liquid volume in a well.""" return self._core.get_liquid_volume() - @requires_version(2, 21) + @requires_version(2, 24) def volume_from_height(self, height: LiquidTrackingType) -> LiquidTrackingType: """Return the volume contained in a well at any height.""" return self._core.volume_from_height(height) - @requires_version(2, 21) + @requires_version(2, 24) def height_from_volume(self, volume: LiquidTrackingType) -> LiquidTrackingType: """Return the height in a well corresponding to a given volume.""" return self._core.height_from_volume(volume)