Skip to content

Commit

Permalink
get_default_engine for stateless commands WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
TamarZanzouri committed May 14, 2024
1 parent 5702c5c commit 4f8a49c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
5 changes: 2 additions & 3 deletions api/src/opentrons/protocol_runner/run_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class RunOrchestrator:

def __init__(
self,
run_id: str,
protocol_engine: ProtocolEngine,
hardware_api: HardwareControlAPI,
fixit_runner: protocol_runner.AnyRunner,
setup_runner: protocol_runner.AnyRunner,
json_or_python_protocol_runner: Optional[protocol_runner.AnyRunner] = None,
run_id: Optional[str] = None,
):
self.run_id = run_id
self._protocol_engine = protocol_engine
Expand All @@ -44,14 +44,14 @@ def __init__(
@classmethod
def build_orchestrator(
cls,
run_id:Optional[str],
protocol_engine: ProtocolEngine,
hardware_api: HardwareControlAPI,
protocol_config: Optional[
Union[JsonProtocolConfig, PythonProtocolConfig]
] = None,
post_run_hardware_state: PostRunHardwareState = PostRunHardwareState.HOME_AND_STAY_ENGAGED,
drop_tips_after_run: bool = True,
run_id: Optional[str] = None,
) -> "RunOrchestrator":
setup_runner = protocol_runner.create_protocol_runner(
protocol_engine=protocol_engine,
Expand Down Expand Up @@ -120,7 +120,6 @@ def add_command(
):
return self._json_or_python_runner.set_command_queued(request)

# TODO(tz, 2024-5-13): what runner should we return?
def get_protocol_runner(self) -> protocol_runner.AnyRunner:
return self._json_or_python_runner or self._setup_runner

Expand Down
16 changes: 8 additions & 8 deletions robot-server/robot_server/runs/engine_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def __init__(
self._hardware_api = hardware_api
self._robot_type = robot_type
self._deck_type = deck_type
# self._default_engine: Optional[ProtocolEngine] = None
self._default_engine: Optional[ProtocolEngine] = None
# self._runner_engine_pair: Optional[RunnerEnginePair] = None
hardware_api.register_callback(_get_estop_listener(self))

Expand Down Expand Up @@ -182,13 +182,13 @@ async def get_default_engine(self) -> ProtocolEngine:
block_on_door_open=False,
),
)
# if we are doing this we probably need a lock on _run_orchestrator
self._run_orchestrator = RunOrchestrator.build_orchestrator(
run_id="initial-engine",
protocol_engine=engine,
hardware_api=self._hardware_api,
)
return self._run_orchestrator.get_protocol_engine()
self._default_engine = engine
# # if we are doing this we probably need a lock on _run_orchestrator
# self._run_orchestrator = RunOrchestrator.build_orchestrator(
# protocol_engine=engine,
# hardware_api=self._hardware_api,
# )
return engine

async def create(
self,
Expand Down

0 comments on commit 4f8a49c

Please sign in to comment.