From 27a1438b7c66a0c4556a52301856a9e983b742b8 Mon Sep 17 00:00:00 2001 From: tamarzanzouri Date: Mon, 29 Apr 2024 16:40:20 -0400 Subject: [PATCH] started creating the orchestrator --- .../protocol_runner/protocol_runner.py | 2 +- .../protocol_runner/run_orchestrator.py | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 api/src/opentrons/protocol_runner/run_orchestrator.py diff --git a/api/src/opentrons/protocol_runner/protocol_runner.py b/api/src/opentrons/protocol_runner/protocol_runner.py index 1faa2d72e3c..55c2cbf67ed 100644 --- a/api/src/opentrons/protocol_runner/protocol_runner.py +++ b/api/src/opentrons/protocol_runner/protocol_runner.py @@ -570,10 +570,10 @@ async def run( # noqa: D102 def create_protocol_runner( - protocol_config: Optional[Union[JsonProtocolConfig, PythonProtocolConfig]], protocol_engine: ProtocolEngine, hardware_api: HardwareControlAPI, task_queue: Optional[TaskQueue] = None, + protocol_config: Optional[Union[JsonProtocolConfig, PythonProtocolConfig]] = None, json_file_reader: Optional[JsonFileReader] = None, json_translator: Optional[JsonTranslator] = None, legacy_file_reader: Optional[LegacyFileReader] = None, diff --git a/api/src/opentrons/protocol_runner/run_orchestrator.py b/api/src/opentrons/protocol_runner/run_orchestrator.py new file mode 100644 index 00000000000..eeedf7aa148 --- /dev/null +++ b/api/src/opentrons/protocol_runner/run_orchestrator.py @@ -0,0 +1,47 @@ +from typing import Optional, Union + +from .protocol_runner import create_protocol_runner, AnyRunner +from ..hardware_control import HardwareControlAPI +from ..protocol_engine import ProtocolEngine +from ..protocol_engine.types import PostRunHardwareState +from ..protocol_reader import JsonProtocolConfig, PythonProtocolConfig + + +class RunOrchestrator: + _protocol_runner: AnyRunner + _setup_runner: AnyRunner + _fixit_runner: AnyRunner + + def __init__( + self, + protocol_config: Optional[Union[JsonProtocolConfig, PythonProtocolConfig]], + protocol_engine: ProtocolEngine, + hardware_api: HardwareControlAPI, + post_run_hardware_state: PostRunHardwareState = PostRunHardwareState.HOME_AND_STAY_ENGAGED, + drop_tips_after_run: bool = True, + ) -> None: + self._protocol_engine = protocol_engine + self._hardware_api = hardware_api + self._post_run_hardware_state = post_run_hardware_state + self._drop_tips_after_run = drop_tips_after_run + self._setup_runner = create_protocol_runner( + protocol_engine=protocol_engine, + hardware_api=hardware_api, + post_run_hardware_state=post_run_hardware_state, + drop_tips_after_run=drop_tips_after_run, + ) + self._fixit_runner = create_protocol_runner( + protocol_engine=protocol_engine, + hardware_api=hardware_api, + post_run_hardware_state=post_run_hardware_state, + drop_tips_after_run=drop_tips_after_run, + ) + + if protocol_config: + self._protocol_runner = create_protocol_runner( + protocol_config=protocol_config, + protocol_engine=protocol_engine, + hardware_api=hardware_api, + post_run_hardware_state=post_run_hardware_state, + drop_tips_after_run=drop_tips_after_run, + )