Skip to content

Commit

Permalink
fix the last step checker logic
Browse files Browse the repository at this point in the history
  • Loading branch information
sanni-t committed Jan 14, 2025
1 parent 7e5177b commit 7287185
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 2 deletions.
14 changes: 12 additions & 2 deletions api/src/opentrons/protocol_api/core/engine/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,9 +1043,19 @@ def _pick_up_tip() -> None:
air_gap=0,
)
]
for step_volume, src_dest_combo in source_dest_per_volume_step:
next_step_volume, next_src_dest_combo = next(source_dest_per_volume_step)
is_last_step = False
while not is_last_step:
step_volume = next_step_volume
src_dest_combo = next_src_dest_combo
step_source, step_destination = src_dest_combo
is_last_step = len([source_dest_per_volume_step]) > 0
try:
next_step_volume, next_src_dest_combo = next(
source_dest_per_volume_step
)
except StopIteration:
is_last_step = True

if new_tip == TransferTipPolicyV2.ALWAYS or (
new_tip == TransferTipPolicyV2.PER_SOURCE and step_source != prev_src
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,129 @@ def test_order_of_water_transfer_steps(
]
assert len(mock_manager.mock_calls) == 9
assert mock_manager.mock_calls == expected_calls


@pytest.mark.ot3_only
@pytest.mark.parametrize(
"simulated_protocol_context", [("2.20", "Flex")], indirect=True
)
def test_order_of_water_transfer_steps_with_no_new_tips(
decoy: Decoy, mock_feature_flags: None, simulated_protocol_context: ProtocolContext
) -> None:
"""It should run the transfer steps without any errors.
This test only checks that various supported configurations for a transfer
analyze successfully. It doesn't check whether the steps are as expected.
That will be covered in analysis snapshot tests.
"""
decoy.when(ff.allow_liquid_classes(RobotTypeEnum.FLEX)).then_return(True)
trash = simulated_protocol_context.load_trash_bin("A3")
tiprack = simulated_protocol_context.load_labware(
"opentrons_flex_96_tiprack_50ul", "D1"
)
pipette_50 = simulated_protocol_context.load_instrument(
"flex_1channel_50", mount="left", tip_racks=[tiprack]
)
nest_plate = simulated_protocol_context.load_labware(
"nest_96_wellplate_200ul_flat", "C3"
)
arma_plate = simulated_protocol_context.load_labware(
"armadillo_96_wellplate_200ul_pcr_full_skirt", "C2"
)

water = simulated_protocol_context.define_liquid_class("water")
pipette_50.pick_up_tip()
with (
mock.patch.object(
InstrumentCore,
"load_liquid_class",
side_effect=InstrumentCore.load_liquid_class,
autospec=True,
) as patched_load_liquid_class,
mock.patch.object(
InstrumentCore,
"pick_up_tip",
side_effect=InstrumentCore.pick_up_tip,
autospec=True,
) as patched_pick_up_tip,
mock.patch.object(
InstrumentCore,
"aspirate_liquid_class",
side_effect=InstrumentCore.aspirate_liquid_class,
autospec=True,
) as patched_aspirate,
mock.patch.object(
InstrumentCore,
"dispense_liquid_class",
side_effect=InstrumentCore.dispense_liquid_class,
autospec=True,
) as patched_dispense,
mock.patch.object(
InstrumentCore,
"drop_tip_in_disposal_location",
side_effect=InstrumentCore.drop_tip_in_disposal_location,
autospec=True,
) as patched_drop_tip,
):
mock_manager = mock.Mock()
mock_manager.attach_mock(patched_pick_up_tip, "pick_up_tip")
mock_manager.attach_mock(patched_load_liquid_class, "load_liquid_class")
mock_manager.attach_mock(patched_aspirate, "aspirate_liquid_class")
mock_manager.attach_mock(patched_dispense, "dispense_liquid_class")
mock_manager.attach_mock(patched_drop_tip, "drop_tip_in_disposal_location")
pipette_50.transfer_liquid(
liquid_class=water,
volume=40,
source=nest_plate.rows()[0][:2],
dest=arma_plate.rows()[0][:2],
new_tip="never",
trash_location=trash,
)
expected_calls = [
mock.call.load_liquid_class(
mock.ANY,
name="water",
transfer_properties=mock.ANY,
tiprack_uri="opentrons/opentrons_flex_96_tiprack_50ul/1",
),
mock.call.aspirate_liquid_class(
mock.ANY,
volume=40,
source=mock.ANY,
transfer_properties=mock.ANY,
transfer_type=TransferType.ONE_TO_ONE,
tip_contents=[LiquidAndAirGapPair(liquid=0, air_gap=0)],
),
mock.call.dispense_liquid_class(
mock.ANY,
volume=40,
dest=mock.ANY,
source=mock.ANY,
transfer_properties=mock.ANY,
transfer_type=TransferType.ONE_TO_ONE,
tip_contents=[LiquidAndAirGapPair(liquid=40, air_gap=0.1)],
add_final_air_gap=True,
trash_location=mock.ANY,
),
mock.call.aspirate_liquid_class(
mock.ANY,
volume=40,
source=mock.ANY,
transfer_properties=mock.ANY,
transfer_type=TransferType.ONE_TO_ONE,
tip_contents=[LiquidAndAirGapPair(liquid=0, air_gap=0.1)],
),
mock.call.dispense_liquid_class(
mock.ANY,
volume=40,
dest=mock.ANY,
source=mock.ANY,
transfer_properties=mock.ANY,
transfer_type=TransferType.ONE_TO_ONE,
tip_contents=[LiquidAndAirGapPair(liquid=40, air_gap=0.1)],
add_final_air_gap=False,
trash_location=mock.ANY,
),
]
assert len(mock_manager.mock_calls) == len(expected_calls)
assert mock_manager.mock_calls[2] == expected_calls[2]

0 comments on commit 7287185

Please sign in to comment.