From 0afbfeb35cd78277e254fb3622a6eda3e24bb8fc Mon Sep 17 00:00:00 2001 From: Ryan howard Date: Fri, 22 Nov 2024 14:19:31 -0500 Subject: [PATCH] format --- .../resources/pipette_data_provider.py | 6 +- .../commands/test_liquid_probe.py | 473 +++++++++--------- 2 files changed, 238 insertions(+), 241 deletions(-) diff --git a/api/src/opentrons/protocol_engine/resources/pipette_data_provider.py b/api/src/opentrons/protocol_engine/resources/pipette_data_provider.py index ddcf17edef5..4df6b0d4d77 100644 --- a/api/src/opentrons/protocol_engine/resources/pipette_data_provider.py +++ b/api/src/opentrons/protocol_engine/resources/pipette_data_provider.py @@ -311,7 +311,11 @@ def get_pipette_static_config( """Get the config for a pipette, given the state/config object from the HW API.""" back_left_offset = pipette_dict["pipette_bounding_box_offsets"].back_left_corner front_right_offset = pipette_dict["pipette_bounding_box_offsets"].front_right_corner - available_sensors = pipette_dict["available_sensors"] if "available_sensors" in pipette_dict.keys() else pipette_definition.AvailableSensorDefinition(sensors=[]) + available_sensors = ( + pipette_dict["available_sensors"] + if "available_sensors" in pipette_dict.keys() + else pipette_definition.AvailableSensorDefinition(sensors=[]) + ) return LoadedStaticPipetteData( model=pipette_dict["model"], display_name=pipette_dict["display_name"], diff --git a/api/tests/opentrons/protocol_engine/commands/test_liquid_probe.py b/api/tests/opentrons/protocol_engine/commands/test_liquid_probe.py index 8cef843c798..34b979901aa 100644 --- a/api/tests/opentrons/protocol_engine/commands/test_liquid_probe.py +++ b/api/tests/opentrons/protocol_engine/commands/test_liquid_probe.py @@ -29,7 +29,7 @@ StaticPipetteConfig, BoundingNozzlesOffsets, PipetteBoundingBoxOffsets, - ) +) from opentrons.protocol_engine.state import update_types from opentrons.types import MountType, Point from opentrons.protocol_engine import WellLocation, WellOrigin, WellOffset, DeckPoint @@ -61,13 +61,13 @@ EitherParamsType = Union[Type[LiquidProbeParams], Type[TryLiquidProbeParams]] EitherResultType = Union[Type[LiquidProbeResult], Type[TryLiquidProbeResult]] + @pytest.fixture def available_sensors() -> AvailableSensorDefinition: """Provide a list of sensors.""" return AvailableSensorDefinition(sensors=["pressure", "capacitive", "environment"]) - @pytest.fixture( params=[ (LiquidProbeImplementation, LiquidProbeParams, LiquidProbeResult), @@ -178,41 +178,40 @@ async def test_liquid_probe_implementation( state_view.pipettes.get_nozzle_configuration_supports_lld("abc") ).then_return(True) - decoy.when( - state_view.pipettes.get_config("abc")).then_return( - StaticPipetteConfig( - min_volume=1, - max_volume=9001, - channels=1, - model="blah", - display_name="bleh", - serial_number="", - tip_configuration_lookup_table={9001: supported_tip_fixture}, - nominal_tip_overlap={}, - home_position=0, - nozzle_offset_z=0, - bounding_nozzle_offsets=BoundingNozzlesOffsets( - back_left_offset=Point(x=10, y=20, z=30), - front_right_offset=Point(x=40, y=50, z=60), - ), - default_nozzle_map=get_default_nozzle_map(PipetteNameType.P1000_96), - pipette_bounding_box_offsets=PipetteBoundingBoxOffsets( - back_left_corner=Point(x=10, y=20, z=30), - front_right_corner=Point(x=40, y=50, z=60), - front_left_corner=Point(x=10, y=50, z=60), - back_right_corner=Point(x=40, y=20, z=60), - ), - lld_settings={}, - plunger_positions={ - "top": 0.0, - "bottom": 5.0, - "blow_out": 19.0, - "drop_tip": 20.0, - }, - shaft_ul_per_mm=5.0, - available_sensors=available_sensors, - ) + decoy.when(state_view.pipettes.get_config("abc")).then_return( + StaticPipetteConfig( + min_volume=1, + max_volume=9001, + channels=1, + model="blah", + display_name="bleh", + serial_number="", + tip_configuration_lookup_table={9001: supported_tip_fixture}, + nominal_tip_overlap={}, + home_position=0, + nozzle_offset_z=0, + bounding_nozzle_offsets=BoundingNozzlesOffsets( + back_left_offset=Point(x=10, y=20, z=30), + front_right_offset=Point(x=40, y=50, z=60), + ), + default_nozzle_map=get_default_nozzle_map(PipetteNameType.P1000_96), + pipette_bounding_box_offsets=PipetteBoundingBoxOffsets( + back_left_corner=Point(x=10, y=20, z=30), + front_right_corner=Point(x=40, y=50, z=60), + front_left_corner=Point(x=10, y=50, z=60), + back_right_corner=Point(x=40, y=20, z=60), + ), + lld_settings={}, + plunger_positions={ + "top": 0.0, + "bottom": 5.0, + "blow_out": 19.0, + "drop_tip": 20.0, + }, + shaft_ul_per_mm=5.0, + available_sensors=available_sensors, ) + ) timestamp = datetime(year=2020, month=1, day=2) decoy.when(model_utils.get_timestamp()).then_return(timestamp) @@ -271,41 +270,40 @@ async def test_liquid_not_found_error( ) decoy.when(state_view.pipettes.get_aspirated_volume(pipette_id)).then_return(0) - decoy.when( - state_view.pipettes.get_config("pipette-id")).then_return( - StaticPipetteConfig( - min_volume=1, - max_volume=9001, - channels=1, - model="blah", - display_name="bleh", - serial_number="", - tip_configuration_lookup_table={9001: supported_tip_fixture}, - nominal_tip_overlap={}, - home_position=0, - nozzle_offset_z=0, - bounding_nozzle_offsets=BoundingNozzlesOffsets( - back_left_offset=Point(x=10, y=20, z=30), - front_right_offset=Point(x=40, y=50, z=60), - ), - default_nozzle_map=get_default_nozzle_map(PipetteNameType.P1000_96), - pipette_bounding_box_offsets=PipetteBoundingBoxOffsets( - back_left_corner=Point(x=10, y=20, z=30), - front_right_corner=Point(x=40, y=50, z=60), - front_left_corner=Point(x=10, y=50, z=60), - back_right_corner=Point(x=40, y=20, z=60), - ), - lld_settings={}, - plunger_positions={ - "top": 0.0, - "bottom": 5.0, - "blow_out": 19.0, - "drop_tip": 20.0, - }, - shaft_ul_per_mm=5.0, - available_sensors=available_sensors, - ) + decoy.when(state_view.pipettes.get_config("pipette-id")).then_return( + StaticPipetteConfig( + min_volume=1, + max_volume=9001, + channels=1, + model="blah", + display_name="bleh", + serial_number="", + tip_configuration_lookup_table={9001: supported_tip_fixture}, + nominal_tip_overlap={}, + home_position=0, + nozzle_offset_z=0, + bounding_nozzle_offsets=BoundingNozzlesOffsets( + back_left_offset=Point(x=10, y=20, z=30), + front_right_offset=Point(x=40, y=50, z=60), + ), + default_nozzle_map=get_default_nozzle_map(PipetteNameType.P1000_96), + pipette_bounding_box_offsets=PipetteBoundingBoxOffsets( + back_left_corner=Point(x=10, y=20, z=30), + front_right_corner=Point(x=40, y=50, z=60), + front_left_corner=Point(x=10, y=50, z=60), + back_right_corner=Point(x=40, y=20, z=60), + ), + lld_settings={}, + plunger_positions={ + "top": 0.0, + "bottom": 5.0, + "blow_out": 19.0, + "drop_tip": 20.0, + }, + shaft_ul_per_mm=5.0, + available_sensors=available_sensors, ) + ) decoy.when( await movement.move_to_well( pipette_id=pipette_id, @@ -397,41 +395,40 @@ async def test_liquid_probe_tip_checking( decoy.when(state_view.pipettes.get_aspirated_volume(pipette_id)).then_raise( TipNotAttachedError() ) - decoy.when( - state_view.pipettes.get_config("pipette-id")).then_return( - StaticPipetteConfig( - min_volume=1, - max_volume=9001, - channels=1, - model="blah", - display_name="bleh", - serial_number="", - tip_configuration_lookup_table={9001: supported_tip_fixture}, - nominal_tip_overlap={}, - home_position=0, - nozzle_offset_z=0, - bounding_nozzle_offsets=BoundingNozzlesOffsets( - back_left_offset=Point(x=10, y=20, z=30), - front_right_offset=Point(x=40, y=50, z=60), - ), - default_nozzle_map=get_default_nozzle_map(PipetteNameType.P1000_96), - pipette_bounding_box_offsets=PipetteBoundingBoxOffsets( - back_left_corner=Point(x=10, y=20, z=30), - front_right_corner=Point(x=40, y=50, z=60), - front_left_corner=Point(x=10, y=50, z=60), - back_right_corner=Point(x=40, y=20, z=60), - ), - lld_settings={}, - plunger_positions={ - "top": 0.0, - "bottom": 5.0, - "blow_out": 19.0, - "drop_tip": 20.0, - }, - shaft_ul_per_mm=5.0, - available_sensors=available_sensors, - ) + decoy.when(state_view.pipettes.get_config("pipette-id")).then_return( + StaticPipetteConfig( + min_volume=1, + max_volume=9001, + channels=1, + model="blah", + display_name="bleh", + serial_number="", + tip_configuration_lookup_table={9001: supported_tip_fixture}, + nominal_tip_overlap={}, + home_position=0, + nozzle_offset_z=0, + bounding_nozzle_offsets=BoundingNozzlesOffsets( + back_left_offset=Point(x=10, y=20, z=30), + front_right_offset=Point(x=40, y=50, z=60), + ), + default_nozzle_map=get_default_nozzle_map(PipetteNameType.P1000_96), + pipette_bounding_box_offsets=PipetteBoundingBoxOffsets( + back_left_corner=Point(x=10, y=20, z=30), + front_right_corner=Point(x=40, y=50, z=60), + front_left_corner=Point(x=10, y=50, z=60), + back_right_corner=Point(x=40, y=20, z=60), + ), + lld_settings={}, + plunger_positions={ + "top": 0.0, + "bottom": 5.0, + "blow_out": 19.0, + "drop_tip": 20.0, + }, + shaft_ul_per_mm=5.0, + available_sensors=available_sensors, ) + ) with pytest.raises(TipNotAttachedError): await subject.execute(data) @@ -461,41 +458,40 @@ async def test_liquid_probe_plunger_preparedness_checking( decoy.when( state_view.pipettes.get_nozzle_configuration_supports_lld(pipette_id) ).then_return(True) - decoy.when( - state_view.pipettes.get_config("pipette-id")).then_return( - StaticPipetteConfig( - min_volume=1, - max_volume=9001, - channels=1, - model="blah", - display_name="bleh", - serial_number="", - tip_configuration_lookup_table={9001: supported_tip_fixture}, - nominal_tip_overlap={}, - home_position=0, - nozzle_offset_z=0, - bounding_nozzle_offsets=BoundingNozzlesOffsets( - back_left_offset=Point(x=10, y=20, z=30), - front_right_offset=Point(x=40, y=50, z=60), - ), - default_nozzle_map=get_default_nozzle_map(PipetteNameType.P1000_96), - pipette_bounding_box_offsets=PipetteBoundingBoxOffsets( - back_left_corner=Point(x=10, y=20, z=30), - front_right_corner=Point(x=40, y=50, z=60), - front_left_corner=Point(x=10, y=50, z=60), - back_right_corner=Point(x=40, y=20, z=60), - ), - lld_settings={}, - plunger_positions={ - "top": 0.0, - "bottom": 5.0, - "blow_out": 19.0, - "drop_tip": 20.0, - }, - shaft_ul_per_mm=5.0, - available_sensors=available_sensors, - ) + decoy.when(state_view.pipettes.get_config("pipette-id")).then_return( + StaticPipetteConfig( + min_volume=1, + max_volume=9001, + channels=1, + model="blah", + display_name="bleh", + serial_number="", + tip_configuration_lookup_table={9001: supported_tip_fixture}, + nominal_tip_overlap={}, + home_position=0, + nozzle_offset_z=0, + bounding_nozzle_offsets=BoundingNozzlesOffsets( + back_left_offset=Point(x=10, y=20, z=30), + front_right_offset=Point(x=40, y=50, z=60), + ), + default_nozzle_map=get_default_nozzle_map(PipetteNameType.P1000_96), + pipette_bounding_box_offsets=PipetteBoundingBoxOffsets( + back_left_corner=Point(x=10, y=20, z=30), + front_right_corner=Point(x=40, y=50, z=60), + front_left_corner=Point(x=10, y=50, z=60), + back_right_corner=Point(x=40, y=20, z=60), + ), + lld_settings={}, + plunger_positions={ + "top": 0.0, + "bottom": 5.0, + "blow_out": 19.0, + "drop_tip": 20.0, + }, + shaft_ul_per_mm=5.0, + available_sensors=available_sensors, ) + ) decoy.when(state_view.pipettes.get_aspirated_volume(pipette_id)).then_return(None) with pytest.raises(PipetteNotReadyToAspirateError): await subject.execute(data) @@ -527,41 +523,40 @@ async def test_liquid_probe_volume_checking( decoy.when( state_view.pipettes.get_aspirated_volume(pipette_id=pipette_id), ).then_return(123) - decoy.when( - state_view.pipettes.get_config("pipette-id")).then_return( - StaticPipetteConfig( - min_volume=1, - max_volume=9001, - channels=1, - model="blah", - display_name="bleh", - serial_number="", - tip_configuration_lookup_table={9001: supported_tip_fixture}, - nominal_tip_overlap={}, - home_position=0, - nozzle_offset_z=0, - bounding_nozzle_offsets=BoundingNozzlesOffsets( - back_left_offset=Point(x=10, y=20, z=30), - front_right_offset=Point(x=40, y=50, z=60), - ), - default_nozzle_map=get_default_nozzle_map(PipetteNameType.P1000_96), - pipette_bounding_box_offsets=PipetteBoundingBoxOffsets( - back_left_corner=Point(x=10, y=20, z=30), - front_right_corner=Point(x=40, y=50, z=60), - front_left_corner=Point(x=10, y=50, z=60), - back_right_corner=Point(x=40, y=20, z=60), - ), - lld_settings={}, - plunger_positions={ - "top": 0.0, - "bottom": 5.0, - "blow_out": 19.0, - "drop_tip": 20.0, - }, - shaft_ul_per_mm=5.0, - available_sensors=available_sensors, - ) + decoy.when(state_view.pipettes.get_config("pipette-id")).then_return( + StaticPipetteConfig( + min_volume=1, + max_volume=9001, + channels=1, + model="blah", + display_name="bleh", + serial_number="", + tip_configuration_lookup_table={9001: supported_tip_fixture}, + nominal_tip_overlap={}, + home_position=0, + nozzle_offset_z=0, + bounding_nozzle_offsets=BoundingNozzlesOffsets( + back_left_offset=Point(x=10, y=20, z=30), + front_right_offset=Point(x=40, y=50, z=60), + ), + default_nozzle_map=get_default_nozzle_map(PipetteNameType.P1000_96), + pipette_bounding_box_offsets=PipetteBoundingBoxOffsets( + back_left_corner=Point(x=10, y=20, z=30), + front_right_corner=Point(x=40, y=50, z=60), + front_left_corner=Point(x=10, y=50, z=60), + back_right_corner=Point(x=40, y=20, z=60), + ), + lld_settings={}, + plunger_positions={ + "top": 0.0, + "bottom": 5.0, + "blow_out": 19.0, + "drop_tip": 20.0, + }, + shaft_ul_per_mm=5.0, + available_sensors=available_sensors, ) + ) decoy.when( state_view.pipettes.get_nozzle_configuration_supports_lld(pipette_id) ).then_return(True) @@ -601,41 +596,40 @@ async def test_liquid_probe_location_checking( wellLocation=well_location, ) decoy.when(state_view.pipettes.get_aspirated_volume(pipette_id)).then_return(0) - decoy.when( - state_view.pipettes.get_config("pipette-id")).then_return( - StaticPipetteConfig( - min_volume=1, - max_volume=9001, - channels=1, - model="blah", - display_name="bleh", - serial_number="", - tip_configuration_lookup_table={9001: supported_tip_fixture}, - nominal_tip_overlap={}, - home_position=0, - nozzle_offset_z=0, - bounding_nozzle_offsets=BoundingNozzlesOffsets( - back_left_offset=Point(x=10, y=20, z=30), - front_right_offset=Point(x=40, y=50, z=60), - ), - default_nozzle_map=get_default_nozzle_map(PipetteNameType.P1000_96), - pipette_bounding_box_offsets=PipetteBoundingBoxOffsets( - back_left_corner=Point(x=10, y=20, z=30), - front_right_corner=Point(x=40, y=50, z=60), - front_left_corner=Point(x=10, y=50, z=60), - back_right_corner=Point(x=40, y=20, z=60), - ), - lld_settings={}, - plunger_positions={ - "top": 0.0, - "bottom": 5.0, - "blow_out": 19.0, - "drop_tip": 20.0, - }, - shaft_ul_per_mm=5.0, - available_sensors=available_sensors, - ) + decoy.when(state_view.pipettes.get_config("pipette-id")).then_return( + StaticPipetteConfig( + min_volume=1, + max_volume=9001, + channels=1, + model="blah", + display_name="bleh", + serial_number="", + tip_configuration_lookup_table={9001: supported_tip_fixture}, + nominal_tip_overlap={}, + home_position=0, + nozzle_offset_z=0, + bounding_nozzle_offsets=BoundingNozzlesOffsets( + back_left_offset=Point(x=10, y=20, z=30), + front_right_offset=Point(x=40, y=50, z=60), + ), + default_nozzle_map=get_default_nozzle_map(PipetteNameType.P1000_96), + pipette_bounding_box_offsets=PipetteBoundingBoxOffsets( + back_left_corner=Point(x=10, y=20, z=30), + front_right_corner=Point(x=40, y=50, z=60), + front_left_corner=Point(x=10, y=50, z=60), + back_right_corner=Point(x=40, y=20, z=60), + ), + lld_settings={}, + plunger_positions={ + "top": 0.0, + "bottom": 5.0, + "blow_out": 19.0, + "drop_tip": 20.0, + }, + shaft_ul_per_mm=5.0, + available_sensors=available_sensors, ) + ) decoy.when( await movement.check_for_valid_position( mount=MountType.LEFT, @@ -672,41 +666,40 @@ async def test_liquid_probe_stall( decoy.when(state_view.pipettes.get_aspirated_volume(pipette_id="abc")).then_return( 0 ) - decoy.when( - state_view.pipettes.get_config("abc")).then_return( - StaticPipetteConfig( - min_volume=1, - max_volume=9001, - channels=1, - model="blah", - display_name="bleh", - serial_number="", - tip_configuration_lookup_table={9001: supported_tip_fixture}, - nominal_tip_overlap={}, - home_position=0, - nozzle_offset_z=0, - bounding_nozzle_offsets=BoundingNozzlesOffsets( - back_left_offset=Point(x=10, y=20, z=30), - front_right_offset=Point(x=40, y=50, z=60), - ), - default_nozzle_map=get_default_nozzle_map(PipetteNameType.P1000_96), - pipette_bounding_box_offsets=PipetteBoundingBoxOffsets( - back_left_corner=Point(x=10, y=20, z=30), - front_right_corner=Point(x=40, y=50, z=60), - front_left_corner=Point(x=10, y=50, z=60), - back_right_corner=Point(x=40, y=20, z=60), - ), - lld_settings={}, - plunger_positions={ - "top": 0.0, - "bottom": 5.0, - "blow_out": 19.0, - "drop_tip": 20.0, - }, - shaft_ul_per_mm=5.0, - available_sensors=available_sensors, - ) + decoy.when(state_view.pipettes.get_config("abc")).then_return( + StaticPipetteConfig( + min_volume=1, + max_volume=9001, + channels=1, + model="blah", + display_name="bleh", + serial_number="", + tip_configuration_lookup_table={9001: supported_tip_fixture}, + nominal_tip_overlap={}, + home_position=0, + nozzle_offset_z=0, + bounding_nozzle_offsets=BoundingNozzlesOffsets( + back_left_offset=Point(x=10, y=20, z=30), + front_right_offset=Point(x=40, y=50, z=60), + ), + default_nozzle_map=get_default_nozzle_map(PipetteNameType.P1000_96), + pipette_bounding_box_offsets=PipetteBoundingBoxOffsets( + back_left_corner=Point(x=10, y=20, z=30), + front_right_corner=Point(x=40, y=50, z=60), + front_left_corner=Point(x=10, y=50, z=60), + back_right_corner=Point(x=40, y=20, z=60), + ), + lld_settings={}, + plunger_positions={ + "top": 0.0, + "bottom": 5.0, + "blow_out": 19.0, + "drop_tip": 20.0, + }, + shaft_ul_per_mm=5.0, + available_sensors=available_sensors, ) + ) decoy.when( state_view.pipettes.get_nozzle_configuration_supports_lld("abc") ).then_return(True)