Skip to content

Commit

Permalink
volume_added
Browse files Browse the repository at this point in the history
  • Loading branch information
sfoster1 committed Oct 28, 2024
1 parent 1f972d7 commit b844901
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 28 deletions.
4 changes: 2 additions & 2 deletions api/src/opentrons/protocol_engine/commands/aspirate.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ async def execute(self, params: AspirateParams) -> _ExecuteReturn:
state_update.set_liquid_operated(
labware_id=labware_id,
well_name=well_name,
volume=CLEAR,
volume_added=CLEAR,
)
return DefinedErrorData(
public=OverpressureError(
Expand All @@ -160,7 +160,7 @@ async def execute(self, params: AspirateParams) -> _ExecuteReturn:
state_update.set_liquid_operated(
labware_id=labware_id,
well_name=well_name,
volume=-volume_aspirated,
volume_added=-volume_aspirated,
)
return SuccessData(
public=AspirateResult(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async def execute(self, params: AspirateInPlaceParams) -> _ExecuteReturn:
state_update.set_liquid_operated(
labware_id=current_location.labware_id,
well_name=current_location.well_name,
volume=CLEAR,
volume_added=CLEAR,
)
return DefinedErrorData(
public=OverpressureError(
Expand Down Expand Up @@ -146,7 +146,7 @@ async def execute(self, params: AspirateInPlaceParams) -> _ExecuteReturn:
state_update.set_liquid_operated(
labware_id=current_location.labware_id,
well_name=current_location.well_name,
volume=-volume,
volume_added=-volume,
)
return SuccessData(
public=AspirateInPlaceResult(volume=volume),
Expand Down
4 changes: 2 additions & 2 deletions api/src/opentrons/protocol_engine/commands/dispense.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async def execute(self, params: DispenseParams) -> _ExecuteReturn:
state_update.set_liquid_operated(
labware_id=labware_id,
well_name=well_name,
volume=CLEAR,
volume_added=CLEAR,
)
return DefinedErrorData(
public=OverpressureError(
Expand All @@ -131,7 +131,7 @@ async def execute(self, params: DispenseParams) -> _ExecuteReturn:
state_update.set_liquid_operated(
labware_id=labware_id,
well_name=well_name,
volume=volume,
volume_added=volume,
)
return SuccessData(
public=DispenseResult(volume=volume, position=deck_point),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async def execute(self, params: DispenseInPlaceParams) -> _ExecuteReturn:
state_update.set_liquid_operated(
labware_id=current_location.labware_id,
well_name=current_location.well_name,
volume=CLEAR,
volume_added=CLEAR,
)
return DefinedErrorData(
public=OverpressureError(
Expand Down Expand Up @@ -125,7 +125,7 @@ async def execute(self, params: DispenseInPlaceParams) -> _ExecuteReturn:
state_update.set_liquid_operated(
labware_id=current_location.labware_id,
well_name=current_location.well_name,
volume=volume,
volume_added=volume,
)
return SuccessData(
public=DispenseInPlaceResult(volume=volume),
Expand Down
6 changes: 3 additions & 3 deletions api/src/opentrons/protocol_engine/state/update_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class LiquidOperatedUpdate:

labware_id: str
well_name: str
volume: float | ClearType
volume_added: float | ClearType


@dataclasses.dataclass
Expand Down Expand Up @@ -398,11 +398,11 @@ def set_liquid_probed(
)

def set_liquid_operated(
self, labware_id: str, well_name: str, volume: float | ClearType
self, labware_id: str, well_name: str, volume_added: float | ClearType
) -> None:
"""Update liquid volumes in well state. See `OperateLiquidUpdate`."""
self.liquid_operated = LiquidOperatedUpdate(
labware_id=labware_id,
well_name=well_name,
volume=volume,
volume_added=volume_added,
)
10 changes: 6 additions & 4 deletions api/src/opentrons/protocol_engine/state/wells.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ def _handle_liquid_operated_update(
labware_id in self._state.loaded_volumes
and well_name in self._state.loaded_volumes[labware_id]
):
if state_update.volume is update_types.CLEAR:
if state_update.volume_added is update_types.CLEAR:
del self._state.loaded_volumes[labware_id][well_name]
else:
prev_loaded_vol_info = self._state.loaded_volumes[labware_id][well_name]
assert prev_loaded_vol_info.volume is not None
self._state.loaded_volumes[labware_id][well_name] = LoadedVolumeInfo(
volume=prev_loaded_vol_info.volume + state_update.volume,
volume=prev_loaded_vol_info.volume + state_update.volume_added,
last_loaded=prev_loaded_vol_info.last_loaded,
operations_since_load=prev_loaded_vol_info.operations_since_load
+ 1,
Expand All @@ -109,14 +109,16 @@ def _handle_liquid_operated_update(
labware_id in self._state.probed_volumes
and well_name in self._state.probed_volumes[labware_id]
):
if state_update.volume is update_types.CLEAR:
if state_update.volume_added is update_types.CLEAR:
del self._state.probed_volumes[labware_id][well_name]
else:
prev_probed_vol_info = self._state.probed_volumes[labware_id][well_name]
if prev_probed_vol_info.volume is None:
new_vol_info: float | None = None
else:
new_vol_info = prev_probed_vol_info.volume + state_update.volume
new_vol_info = (
prev_probed_vol_info.volume + state_update.volume_added
)
self._state.probed_volumes[labware_id][well_name] = ProbedVolumeInfo(
volume=new_vol_info,
last_probed=prev_probed_vol_info.last_probed,
Expand Down
8 changes: 4 additions & 4 deletions api/tests/opentrons/protocol_engine/commands/test_aspirate.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async def test_aspirate_implementation_no_prep(
liquid_operated=update_types.LiquidOperatedUpdate(
labware_id="123",
well_name="A3",
volume=-50,
volume_added=-50,
),
),
)
Expand Down Expand Up @@ -187,7 +187,7 @@ async def test_aspirate_implementation_with_prep(
liquid_operated=update_types.LiquidOperatedUpdate(
labware_id="123",
well_name="A3",
volume=-50,
volume_added=-50,
),
),
)
Expand Down Expand Up @@ -327,7 +327,7 @@ async def test_overpressure_error(
liquid_operated=update_types.LiquidOperatedUpdate(
labware_id=labware_id,
well_name=well_name,
volume=update_types.CLEAR,
volume_added=update_types.CLEAR,
),
),
)
Expand Down Expand Up @@ -393,7 +393,7 @@ async def test_aspirate_implementation_meniscus(
liquid_operated=update_types.LiquidOperatedUpdate(
labware_id="123",
well_name="A3",
volume=-50,
volume_added=-50,
),
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ async def test_aspirate_in_place_implementation(
liquid_operated=update_types.LiquidOperatedUpdate(
labware_id=stateupdateLabware,
well_name=stateupdateWell,
volume=-123,
volume_added=-123,
)
),
)
Expand Down Expand Up @@ -270,7 +270,7 @@ async def test_overpressure_error(
liquid_operated=update_types.LiquidOperatedUpdate(
labware_id=stateupdateLabware,
well_name=stateupdateWell,
volume=update_types.CLEAR,
volume_added=update_types.CLEAR,
)
),
)
Expand Down
4 changes: 2 additions & 2 deletions api/tests/opentrons/protocol_engine/commands/test_dispense.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def test_dispense_implementation(
liquid_operated=update_types.LiquidOperatedUpdate(
labware_id="labware-id-abc123",
well_name="A3",
volume=42,
volume_added=42,
),
),
)
Expand Down Expand Up @@ -169,7 +169,7 @@ async def test_overpressure_error(
liquid_operated=update_types.LiquidOperatedUpdate(
labware_id="labware-id",
well_name="well-name",
volume=update_types.CLEAR,
volume_added=update_types.CLEAR,
),
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ async def test_dispense_in_place_implementation(
private=None,
state_update=update_types.StateUpdate(
liquid_operated=update_types.LiquidOperatedUpdate(
labware_id=stateupdateLabware, well_name=stateupdateWell, volume=42
labware_id=stateupdateLabware,
well_name=stateupdateWell,
volume_added=42,
)
),
)
Expand Down Expand Up @@ -175,7 +177,7 @@ async def test_overpressure_error(
liquid_operated=update_types.LiquidOperatedUpdate(
labware_id=stateupdateLabware,
well_name=stateupdateWell,
volume=update_types.CLEAR,
volume_added=update_types.CLEAR,
)
),
)
Expand Down
6 changes: 3 additions & 3 deletions api/tests/opentrons/protocol_engine/state/test_well_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_handles_load_liquid_and_aspirate(subject: WellStore) -> None:
liquid_operated=update_types.LiquidOperatedUpdate(
labware_id=labware_id,
well_name=well_name_1,
volume=-aspirated_volume,
volume_added=-aspirated_volume,
)
),
)
Expand All @@ -156,7 +156,7 @@ def test_handles_load_liquid_and_aspirate(subject: WellStore) -> None:
liquid_operated=update_types.LiquidOperatedUpdate(
labware_id=labware_id,
well_name=well_name_2,
volume=-aspirated_volume,
volume_added=-aspirated_volume,
)
),
)
Expand Down Expand Up @@ -220,7 +220,7 @@ def test_handles_liquid_probe_and_aspirate(subject: WellStore) -> None:
liquid_operated=update_types.LiquidOperatedUpdate(
labware_id="labware-id",
well_name="well-name",
volume=-aspirated_volume,
volume_added=-aspirated_volume,
)
),
)
Expand Down

0 comments on commit b844901

Please sign in to comment.