Skip to content

Commit

Permalink
started creating the orchestrator
Browse files Browse the repository at this point in the history
  • Loading branch information
TamarZanzouri committed Apr 29, 2024
1 parent bc4131c commit 27a1438
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/src/opentrons/protocol_runner/protocol_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
47 changes: 47 additions & 0 deletions api/src/opentrons/protocol_runner/run_orchestrator.py
Original file line number Diff line number Diff line change
@@ -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,
)

0 comments on commit 27a1438

Please sign in to comment.