From 0d1d21ffaaa0d164a31a02beb4e10de72ce5a655 Mon Sep 17 00:00:00 2001 From: Max Marrone Date: Tue, 23 Apr 2024 13:05:11 -0400 Subject: [PATCH] fix(api): Filter out `air_gap()` calls as higher-order commands (#14985) --- .../protocol_runner/legacy_command_mapper.py | 1 + .../smoke_tests/test_legacy_command_mapper.py | 44 +++++++++++++++++++ .../test_legacy_command_mapper.py | 1 + 3 files changed, 46 insertions(+) diff --git a/api/src/opentrons/protocol_runner/legacy_command_mapper.py b/api/src/opentrons/protocol_runner/legacy_command_mapper.py index e835a6af8e6..9243f50f70d 100644 --- a/api/src/opentrons/protocol_runner/legacy_command_mapper.py +++ b/api/src/opentrons/protocol_runner/legacy_command_mapper.py @@ -79,6 +79,7 @@ def __init__(self, wrapping_exc: BaseException) -> None: legacy_command_types.DISTRIBUTE, legacy_command_types.TRANSFER, legacy_command_types.RETURN_TIP, + legacy_command_types.AIR_GAP, } diff --git a/api/tests/opentrons/protocol_runner/smoke_tests/test_legacy_command_mapper.py b/api/tests/opentrons/protocol_runner/smoke_tests/test_legacy_command_mapper.py index 5d6595227b9..c8950cbe090 100644 --- a/api/tests/opentrons/protocol_runner/smoke_tests/test_legacy_command_mapper.py +++ b/api/tests/opentrons/protocol_runner/smoke_tests/test_legacy_command_mapper.py @@ -5,6 +5,7 @@ """ from datetime import datetime from pathlib import Path +from textwrap import dedent from typing import List import pytest @@ -753,3 +754,46 @@ async def test_zero_volume_dispense_commands( labwareId=load_well_plate.result.labwareId, wellName="D7", ) + + +async def test_air_gap(tmp_path: Path) -> None: + """An `air_gap()` should be mapped to an `aspirate`. + + This covers RQA-2621. + """ + path = tmp_path / "protocol.py" + path.write_text( + dedent( + """\ + metadata = {"apiLevel": "2.13"} + def run(protocol): + # Prep: + tip_rack = protocol.load_labware("opentrons_96_tiprack_300ul", 1) + well_plate = protocol.load_labware("biorad_96_wellplate_200ul_pcr", 2) + pipette = protocol.load_instrument("p300_single_gen2", mount="left", tip_racks=[tip_rack]) + pipette.pick_up_tip() + + # Test: + pipette.move_to(well_plate["A1"].top()) + pipette.air_gap(100) + """ + ) + ) + result_commands = await simulate_and_get_commands(path) + [ + initial_home, + load_tip_rack, + load_well_plate, + load_pipette, + pick_up_tip, + move_to_well, + air_gap_aspirate, + ] = result_commands + assert isinstance(initial_home, commands.Home) + assert isinstance(load_tip_rack, commands.LoadLabware) + assert isinstance(load_well_plate, commands.LoadLabware) + assert isinstance(load_pipette, commands.LoadPipette) + assert isinstance(pick_up_tip, commands.PickUpTip) + # TODO(mm, 2024-04-23): This commands.Custom looks wrong. This should be a commands.MoveToWell. + assert isinstance(move_to_well, commands.Custom) + assert isinstance(air_gap_aspirate, commands.Aspirate) diff --git a/api/tests/opentrons/protocol_runner/test_legacy_command_mapper.py b/api/tests/opentrons/protocol_runner/test_legacy_command_mapper.py index f0412878856..a0581001a82 100644 --- a/api/tests/opentrons/protocol_runner/test_legacy_command_mapper.py +++ b/api/tests/opentrons/protocol_runner/test_legacy_command_mapper.py @@ -579,6 +579,7 @@ def test_map_pause() -> None: "command.DISTRIBUTE", "command.TRANSFER", "command.RETURN_TIP", + "command.AIR_GAP", ], ) def test_filter_higher_order_commands(command_type: str) -> None: