diff --git a/api/src/opentrons/protocol_runner/legacy_command_mapper.py b/api/src/opentrons/protocol_runner/legacy_command_mapper.py index d87f098c42a..ababa892616 100644 --- a/api/src/opentrons/protocol_runner/legacy_command_mapper.py +++ b/api/src/opentrons/protocol_runner/legacy_command_mapper.py @@ -17,10 +17,10 @@ from opentrons.protocol_api import InstrumentContext from opentrons.protocol_api.core.legacy.deck import FIXED_TRASH_ID from opentrons.protocol_api.core.legacy.load_info import ( - LoadInfo, - LabwareLoadInfo, - InstrumentLoadInfo, - ModuleLoadInfo, + LoadInfo as LegacyLoadInfo, + LabwareLoadInfo as LegacyLabwareLoadInfo, + InstrumentLoadInfo as LegacyInstrumentLoadInfo, + ModuleLoadInfo as LegacyModuleLoadInfo, ) from opentrons.protocol_engine import ( ProtocolEngineError, @@ -283,13 +283,13 @@ def map_command( # noqa: C901 return results - def map_equipment_load(self, load_info: LoadInfo) -> List[pe_actions.Action]: + def map_equipment_load(self, load_info: LegacyLoadInfo) -> List[pe_actions.Action]: """Map a labware, instrument (pipette), or module load to a PE command.""" - if isinstance(load_info, LabwareLoadInfo): + if isinstance(load_info, LegacyLabwareLoadInfo): return self._map_labware_load(load_info) - elif isinstance(load_info, InstrumentLoadInfo): + elif isinstance(load_info, LegacyInstrumentLoadInfo): return self._map_instrument_load(load_info) - elif isinstance(load_info, ModuleLoadInfo): + elif isinstance(load_info, LegacyModuleLoadInfo): return self._map_module_load(load_info) def _build_initial_command( @@ -592,7 +592,7 @@ def _build_blow_out( return custom_create, custom_running def _map_labware_load( - self, labware_load_info: LabwareLoadInfo + self, labware_load_info: LegacyLabwareLoadInfo ) -> List[pe_actions.Action]: """Map a legacy labware load to a ProtocolEngine command.""" now = ModelUtils.get_timestamp() @@ -660,7 +660,7 @@ def _map_labware_load( def _map_instrument_load( self, - instrument_load_info: InstrumentLoadInfo, + instrument_load_info: LegacyInstrumentLoadInfo, ) -> List[pe_actions.Action]: """Map a legacy instrument (pipette) load to a ProtocolEngine command. @@ -719,7 +719,7 @@ def _map_instrument_load( return [queue_action, run_action, succeed_action] def _map_module_load( - self, module_load_info: ModuleLoadInfo + self, module_load_info: LegacyModuleLoadInfo ) -> List[pe_actions.Action]: """Map a legacy module load to a Protocol Engine command.""" now = ModelUtils.get_timestamp() diff --git a/api/src/opentrons/protocol_runner/legacy_context_plugin.py b/api/src/opentrons/protocol_runner/legacy_context_plugin.py index f6f0e25d399..baf6ccbc716 100644 --- a/api/src/opentrons/protocol_runner/legacy_context_plugin.py +++ b/api/src/opentrons/protocol_runner/legacy_context_plugin.py @@ -122,7 +122,7 @@ def handle_action(self, action: pe_actions.Action) -> None: pass def _handle_legacy_command(self, command: LegacyCommand) -> None: - """Handle a command reported by the APIv2 protocol. + """Handle a command reported by the legacy APIv2 protocol. Used as a broker callback, so this will run in the APIv2 protocol's thread. """ @@ -130,7 +130,7 @@ def _handle_legacy_command(self, command: LegacyCommand) -> None: self._actions_to_dispatch.put(pe_actions) def _handle_equipment_loaded(self, load_info: LoadInfo) -> None: - """Handle an equipment load reported by the APIv2 protocol. + """Handle an equipment load reported by the legacy APIv2 protocol. Used as a broker callback, so this will run in the APIv2 protocol's thread. """ diff --git a/api/src/opentrons/protocol_runner/protocol_runner.py b/api/src/opentrons/protocol_runner/protocol_runner.py index 5271a4ddbfa..5a8b9134772 100644 --- a/api/src/opentrons/protocol_runner/protocol_runner.py +++ b/api/src/opentrons/protocol_runner/protocol_runner.py @@ -32,7 +32,7 @@ from .python_protocol_wrappers import ( LEGACY_PYTHON_API_VERSION_CUTOFF, LEGACY_JSON_SCHEMA_VERSION_CUTOFF, - PythonProtocolFileReader, + PythonAndLegacyFileReader, ProtocolContextCreator, PythonProtocolExecutor, ) @@ -136,7 +136,7 @@ def __init__( protocol_engine: ProtocolEngine, hardware_api: HardwareControlAPI, task_queue: Optional[TaskQueue] = None, - python_protocol_file_reader: Optional[PythonProtocolFileReader] = None, + python_and_legacy_file_reader: Optional[PythonAndLegacyFileReader] = None, protocol_context_creator: Optional[ProtocolContextCreator] = None, python_protocol_executor: Optional[PythonProtocolExecutor] = None, post_run_hardware_state: PostRunHardwareState = PostRunHardwareState.HOME_AND_STAY_ENGAGED, @@ -146,7 +146,7 @@ def __init__( super().__init__(protocol_engine) self._hardware_api = hardware_api self._protocol_file_reader = ( - python_protocol_file_reader or PythonProtocolFileReader() + python_and_legacy_file_reader or PythonAndLegacyFileReader() ) self._protocol_context_creator = ( protocol_context_creator @@ -422,7 +422,7 @@ def create_protocol_runner( task_queue: Optional[TaskQueue] = None, json_file_reader: Optional[JsonFileReader] = None, json_translator: Optional[JsonTranslator] = None, - python_protocol_file_reader: Optional[PythonProtocolFileReader] = None, + python_and_legacy_file_reader: Optional[PythonAndLegacyFileReader] = None, protocol_context_creator: Optional[ProtocolContextCreator] = None, python_protocol_executor: Optional[PythonProtocolExecutor] = None, post_run_hardware_state: PostRunHardwareState = PostRunHardwareState.HOME_AND_STAY_ENGAGED, @@ -448,7 +448,7 @@ def create_protocol_runner( protocol_engine=protocol_engine, hardware_api=hardware_api, task_queue=task_queue, - python_protocol_file_reader=python_protocol_file_reader, + python_and_legacy_file_reader=python_and_legacy_file_reader, protocol_context_creator=protocol_context_creator, python_protocol_executor=python_protocol_executor, post_run_hardware_state=post_run_hardware_state, diff --git a/api/src/opentrons/protocol_runner/python_protocol_wrappers.py b/api/src/opentrons/protocol_runner/python_protocol_wrappers.py index bf84c0311cb..e0a345db0f0 100644 --- a/api/src/opentrons/protocol_runner/python_protocol_wrappers.py +++ b/api/src/opentrons/protocol_runner/python_protocol_wrappers.py @@ -44,7 +44,7 @@ LEGACY_JSON_SCHEMA_VERSION_CUTOFF = 6 -class PythonProtocolFileReader: +class PythonAndLegacyFileReader: """Interface to read Protocol API v2 protocols prior to execution.""" @staticmethod 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 3824b79ee20..ada52714ee6 100644 --- a/api/tests/opentrons/protocol_runner/test_legacy_command_mapper.py +++ b/api/tests/opentrons/protocol_runner/test_legacy_command_mapper.py @@ -10,9 +10,9 @@ from opentrons.hardware_control.modules.types import TemperatureModuleModel from opentrons.legacy_commands.types import CommentMessage, PauseMessage, CommandMessage from opentrons.protocol_api.core.legacy.load_info import ( - LabwareLoadInfo, - InstrumentLoadInfo, - ModuleLoadInfo, + LabwareLoadInfo as LegacyLabwareLoadInfo, + InstrumentLoadInfo as LegacyInstrumentLoadInfo, + ModuleLoadInfo as LegacyModuleLoadInfo, ) from opentrons.protocol_engine import ( DeckSlotLocation, @@ -270,7 +270,7 @@ def test_command_stack() -> None: def test_map_labware_load(minimal_labware_def: LabwareDefinition) -> None: """It should correctly map a labware load.""" - input = LabwareLoadInfo( + input = LegacyLabwareLoadInfo( labware_definition=minimal_labware_def, labware_namespace="some_namespace", labware_load_name="some_load_name", @@ -334,7 +334,7 @@ def test_map_labware_load(minimal_labware_def: LabwareDefinition) -> None: def test_map_instrument_load(decoy: Decoy) -> None: """It should correctly map an instrument load.""" pipette_dict = cast(PipetteDict, {"pipette_id": "fizzbuzz"}) - input = InstrumentLoadInfo( + input = LegacyInstrumentLoadInfo( instrument_load_name="p1000_single_gen2", mount=Mount.LEFT, pipette_dict=pipette_dict, @@ -395,7 +395,7 @@ def test_map_module_load( ) -> None: """It should correctly map a module load.""" test_definition = ModuleDefinition.parse_obj(minimal_module_def) - input = ModuleLoadInfo( + input = LegacyModuleLoadInfo( requested_model=TemperatureModuleModel.TEMPERATURE_V1, loaded_model=TemperatureModuleModel.TEMPERATURE_V2, deck_slot=DeckSlotName.SLOT_1, @@ -454,7 +454,7 @@ def test_map_module_load( def test_map_module_labware_load(minimal_labware_def: LabwareDefinition) -> None: """It should correctly map a labware load on module.""" - load_input = LabwareLoadInfo( + load_input = LegacyLabwareLoadInfo( labware_definition=minimal_labware_def, labware_namespace="some_namespace", labware_load_name="some_load_name", diff --git a/api/tests/opentrons/protocol_runner/test_protocol_runner.py b/api/tests/opentrons/protocol_runner/test_protocol_runner.py index 98d00935579..6aa790bee98 100644 --- a/api/tests/opentrons/protocol_runner/test_protocol_runner.py +++ b/api/tests/opentrons/protocol_runner/test_protocol_runner.py @@ -48,7 +48,7 @@ from opentrons.protocol_runner.json_translator import JsonTranslator from opentrons.protocol_runner.legacy_context_plugin import LegacyContextPlugin from opentrons.protocol_runner.python_protocol_wrappers import ( - PythonProtocolFileReader, + PythonAndLegacyFileReader, ProtocolContextCreator, PythonProtocolExecutor, ) @@ -85,9 +85,9 @@ def json_translator(decoy: Decoy) -> JsonTranslator: @pytest.fixture -def python_protocol_file_reader(decoy: Decoy) -> PythonProtocolFileReader: - """Get a mocked out PythonProtocolFileReader dependency.""" - return decoy.mock(cls=PythonProtocolFileReader) +def python_and_legacy_file_reader(decoy: Decoy) -> PythonAndLegacyFileReader: + """Get a mocked out PythonAndLegacyFileReader dependency.""" + return decoy.mock(cls=PythonAndLegacyFileReader) @pytest.fixture @@ -137,7 +137,7 @@ def python_runner_subject( protocol_engine: ProtocolEngine, hardware_api: HardwareAPI, task_queue: TaskQueue, - python_protocol_file_reader: PythonProtocolFileReader, + python_and_legacy_file_reader: PythonAndLegacyFileReader, protocol_context_creator: ProtocolContextCreator, python_protocol_executor: PythonProtocolExecutor, ) -> PythonAndLegacyRunner: @@ -146,7 +146,7 @@ def python_runner_subject( protocol_engine=protocol_engine, hardware_api=hardware_api, task_queue=task_queue, - python_protocol_file_reader=python_protocol_file_reader, + python_and_legacy_file_reader=python_and_legacy_file_reader, protocol_context_creator=protocol_context_creator, python_protocol_executor=python_protocol_executor, ) @@ -183,7 +183,7 @@ def test_create_protocol_runner( task_queue: TaskQueue, json_file_reader: JsonFileReader, json_translator: JsonTranslator, - python_protocol_file_reader: PythonProtocolFileReader, + python_and_legacy_file_reader: PythonAndLegacyFileReader, protocol_context_creator: ProtocolContextCreator, python_protocol_executor: PythonProtocolExecutor, config: Optional[Union[JsonProtocolConfig, PythonProtocolConfig]], @@ -522,7 +522,7 @@ async def test_load_json_runner( async def test_load_legacy_python( decoy: Decoy, - python_protocol_file_reader: PythonProtocolFileReader, + python_and_legacy_file_reader: PythonAndLegacyFileReader, protocol_context_creator: ProtocolContextCreator, python_protocol_executor: PythonProtocolExecutor, task_queue: TaskQueue, @@ -563,7 +563,7 @@ async def test_load_legacy_python( await protocol_reader.extract_labware_definitions(legacy_protocol_source) ).then_return([labware_definition]) decoy.when( - python_protocol_file_reader.read( + python_and_legacy_file_reader.read( protocol_source=legacy_protocol_source, labware_definitions=[labware_definition], python_parse_mode=PythonParseMode.ALLOW_LEGACY_METADATA_AND_REQUIREMENTS, @@ -612,7 +612,7 @@ async def test_load_legacy_python( async def test_load_python_with_pe_papi_core( decoy: Decoy, - python_protocol_file_reader: PythonProtocolFileReader, + python_and_legacy_file_reader: PythonAndLegacyFileReader, protocol_context_creator: ProtocolContextCreator, protocol_engine: ProtocolEngine, python_runner_subject: PythonAndLegacyRunner, @@ -647,7 +647,7 @@ async def test_load_python_with_pe_papi_core( await protocol_reader.extract_labware_definitions(protocol_source) ).then_return([]) decoy.when( - python_protocol_file_reader.read( + python_and_legacy_file_reader.read( protocol_source=protocol_source, labware_definitions=[], python_parse_mode=PythonParseMode.ALLOW_LEGACY_METADATA_AND_REQUIREMENTS, @@ -672,7 +672,7 @@ async def test_load_python_with_pe_papi_core( async def test_load_legacy_json( decoy: Decoy, - python_protocol_file_reader: PythonProtocolFileReader, + python_and_legacy_file_reader: PythonAndLegacyFileReader, protocol_context_creator: ProtocolContextCreator, python_protocol_executor: PythonProtocolExecutor, task_queue: TaskQueue, @@ -708,7 +708,7 @@ async def test_load_legacy_json( await protocol_reader.extract_labware_definitions(legacy_protocol_source) ).then_return([labware_definition]) decoy.when( - python_protocol_file_reader.read( + python_and_legacy_file_reader.read( protocol_source=legacy_protocol_source, labware_definitions=[labware_definition], python_parse_mode=PythonParseMode.ALLOW_LEGACY_METADATA_AND_REQUIREMENTS,