From a213c1fe739c39e9330b0aa339be56b409671f3c Mon Sep 17 00:00:00 2001 From: tamarzanzouri Date: Thu, 26 Sep 2024 15:59:26 -0400 Subject: [PATCH] legacy command mapper and test fixes --- .../protocol_runner/legacy_command_mapper.py | 9 +++++- .../commands/test_configure_for_volume.py | 10 ++++++ .../protocol_engine/commands/test_drop_tip.py | 10 +++--- .../commands/test_drop_tip_in_place.py | 19 ++++++----- .../commands/test_load_pipette.py | 32 +++++++++++++------ .../commands/test_pick_up_tip.py | 4 +-- .../unsafe/test_unsafe_drop_tip_in_place.py | 19 ++++++----- 7 files changed, 68 insertions(+), 35 deletions(-) diff --git a/api/src/opentrons/protocol_runner/legacy_command_mapper.py b/api/src/opentrons/protocol_runner/legacy_command_mapper.py index 8ffb67d3560..686560c1ca2 100644 --- a/api/src/opentrons/protocol_runner/legacy_command_mapper.py +++ b/api/src/opentrons/protocol_runner/legacy_command_mapper.py @@ -754,10 +754,17 @@ def _map_instrument_load( # We just set this above, so we know it's not None. started_at=succeeded_command.startedAt, # type: ignore[arg-type] ) + state_update = StateUpdate() + state_update.set_load_pipette( + pipette_id=pipette_id, + mount=succeeded_command.params.mount, + pipette_name=succeeded_command.params.pipetteName, + liquid_presence_detection=succeeded_command.params.liquidPresenceDetection, + ) succeed_action = pe_actions.SucceedCommandAction( command=succeeded_command, private_result=pipette_config_result, - state_update=StateUpdate(), + state_update=state_update, ) self._command_count["LOAD_PIPETTE"] = count + 1 diff --git a/api/tests/opentrons/protocol_engine/commands/test_configure_for_volume.py b/api/tests/opentrons/protocol_engine/commands/test_configure_for_volume.py index 95e1e856bd4..309ab41d53e 100644 --- a/api/tests/opentrons/protocol_engine/commands/test_configure_for_volume.py +++ b/api/tests/opentrons/protocol_engine/commands/test_configure_for_volume.py @@ -1,4 +1,9 @@ """Test load pipette commands.""" +from opentrons.protocol_engine.state.update_types import ( + LoadPipetteUpdate, + PipetteConfigUpdate, + StateUpdate, +) import pytest from decoy import Decoy @@ -84,4 +89,9 @@ async def test_configure_for_volume_implementation( private=ConfigureForVolumePrivateResult( pipette_id="pipette-id", serial_number="some number", config=config ), + state_update=StateUpdate( + pipette_config=PipetteConfigUpdate( + pipette_id="pipette-id", serial_number="some number", config=config + ) + ), ) diff --git a/api/tests/opentrons/protocol_engine/commands/test_drop_tip.py b/api/tests/opentrons/protocol_engine/commands/test_drop_tip.py index b79e4c59089..a44b6892401 100644 --- a/api/tests/opentrons/protocol_engine/commands/test_drop_tip.py +++ b/api/tests/opentrons/protocol_engine/commands/test_drop_tip.py @@ -125,9 +125,8 @@ async def test_drop_tip_implementation( new_deck_point=DeckPoint(x=111, y=222, z=333), ), pipette_tip_state=update_types.PipetteTipStateUpdate( - pipette_id="abc", - tip_geometry=None - ) + pipette_id="abc", tip_geometry=None + ), ), ) @@ -202,8 +201,7 @@ async def test_drop_tip_with_alternating_locations( new_deck_point=DeckPoint(x=111, y=222, z=333), ), pipette_tip_state=update_types.PipetteTipStateUpdate( - pipette_id="abc", - tip_geometry=None - ) + pipette_id="abc", tip_geometry=None + ), ), ) diff --git a/api/tests/opentrons/protocol_engine/commands/test_drop_tip_in_place.py b/api/tests/opentrons/protocol_engine/commands/test_drop_tip_in_place.py index e8c203b1ee5..aa7854f6105 100644 --- a/api/tests/opentrons/protocol_engine/commands/test_drop_tip_in_place.py +++ b/api/tests/opentrons/protocol_engine/commands/test_drop_tip_in_place.py @@ -1,5 +1,8 @@ """Test drop tip in place commands.""" -from opentrons.protocol_engine.state.update_types import PipetteTipStateUpdate, StateUpdate +from opentrons.protocol_engine.state.update_types import ( + PipetteTipStateUpdate, + StateUpdate, +) import pytest from decoy import Decoy @@ -30,13 +33,13 @@ async def test_drop_tip_implementation( result = await subject.execute(params) - assert result == SuccessData(public=DropTipInPlaceResult(), private=None, - state_update=StateUpdate( - pipette_tip_state=PipetteTipStateUpdate( - pipette_id="abc", - tip_geometry=None - ) - )) + assert result == SuccessData( + public=DropTipInPlaceResult(), + private=None, + state_update=StateUpdate( + pipette_tip_state=PipetteTipStateUpdate(pipette_id="abc", tip_geometry=None) + ), + ) decoy.verify( await mock_tip_handler.drop_tip(pipette_id="abc", home_after=False), diff --git a/api/tests/opentrons/protocol_engine/commands/test_load_pipette.py b/api/tests/opentrons/protocol_engine/commands/test_load_pipette.py index c015dfc49a0..5884e015342 100644 --- a/api/tests/opentrons/protocol_engine/commands/test_load_pipette.py +++ b/api/tests/opentrons/protocol_engine/commands/test_load_pipette.py @@ -1,5 +1,9 @@ """Test load pipette commands.""" -from opentrons.protocol_engine.state.update_types import LoadPipetteUpdate, StateUpdate +from opentrons.protocol_engine.state.update_types import ( + LoadPipetteUpdate, + PipetteConfigUpdate, + StateUpdate, +) import pytest from decoy import Decoy @@ -94,10 +98,14 @@ async def test_load_pipette_implementation( pipette_name=PipetteNameType.P300_SINGLE, mount=MountType.LEFT, pipette_id="some id", - liquid_presence_detection=None + liquid_presence_detection=None, ), - pipette_config=config_data - ) + pipette_config=PipetteConfigUpdate( + pipette_id="some id", + serial_number="some-serial-number", + config=config_data, + ), + ), ) @@ -153,15 +161,19 @@ async def test_load_pipette_implementation_96_channel( private=LoadPipettePrivateResult( pipette_id="pipette-id", serial_number="some id", config=config_data ), - state_update=StateUpdate( + state_update=StateUpdate( loaded_pipette=LoadPipetteUpdate( - pipette_name=PipetteNameType.P300_SINGLE, + pipette_name=PipetteNameType.P1000_96, mount=MountType.LEFT, - pipette_id="some id", - liquid_presence_detection=None + pipette_id="pipette-id", + liquid_presence_detection=None, ), - pipette_config=config_data - ) + pipette_config=PipetteConfigUpdate( + pipette_id="pipette-id", + serial_number="some id", + config=config_data, + ), + ), ) diff --git a/api/tests/opentrons/protocol_engine/commands/test_pick_up_tip.py b/api/tests/opentrons/protocol_engine/commands/test_pick_up_tip.py index 539a26f03b0..c4ff37c501d 100644 --- a/api/tests/opentrons/protocol_engine/commands/test_pick_up_tip.py +++ b/api/tests/opentrons/protocol_engine/commands/test_pick_up_tip.py @@ -81,8 +81,8 @@ async def test_success( ), pipette_tip_state=update_types.PipetteTipStateUpdate( pipette_id="pipette-id", - tip_geometry=TipGeometry(length=42, diameter=5, volume=300) - ) + tip_geometry=TipGeometry(length=42, diameter=5, volume=300), + ), ), ) diff --git a/api/tests/opentrons/protocol_engine/commands/unsafe/test_unsafe_drop_tip_in_place.py b/api/tests/opentrons/protocol_engine/commands/unsafe/test_unsafe_drop_tip_in_place.py index 9171999ad01..4913fe3c444 100644 --- a/api/tests/opentrons/protocol_engine/commands/unsafe/test_unsafe_drop_tip_in_place.py +++ b/api/tests/opentrons/protocol_engine/commands/unsafe/test_unsafe_drop_tip_in_place.py @@ -1,5 +1,8 @@ """Test unsafe drop tip in place commands.""" -from opentrons.protocol_engine.state.update_types import PipetteTipStateUpdate, StateUpdate +from opentrons.protocol_engine.state.update_types import ( + PipetteTipStateUpdate, + StateUpdate, +) import pytest from decoy import Decoy @@ -45,13 +48,13 @@ async def test_drop_tip_implementation( result = await subject.execute(params) - assert result == SuccessData(public=UnsafeDropTipInPlaceResult(), private=None, - state_update=StateUpdate( - pipette_tip_state=PipetteTipStateUpdate( - pipette_id="abc", - tip_geometry=None - ) - )) + assert result == SuccessData( + public=UnsafeDropTipInPlaceResult(), + private=None, + state_update=StateUpdate( + pipette_tip_state=PipetteTipStateUpdate(pipette_id="abc", tip_geometry=None) + ), + ) decoy.verify( await ot3_hardware_api.update_axis_position_estimations([Axis.P_L]),