Skip to content

Commit

Permalink
run_data_manager via orchestrator
Browse files Browse the repository at this point in the history
  • Loading branch information
TamarZanzouri committed May 23, 2024
1 parent 34b4391 commit 7bd9f5f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
22 changes: 14 additions & 8 deletions robot-server/robot_server/runs/run_data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def get_run_loaded_labware_definitions(
)

return (
self._engine_store.engine.state_view.labware.get_loaded_labware_definitions()
self.engine._run_orchestrator.state_view.labware.get_loaded_labware_definitions()
)

def get_all(self, length: Optional[int]) -> List[Union[Run, BadRun]]:
Expand Down Expand Up @@ -334,7 +334,9 @@ async def update(self, run_id: str, current: Optional[bool]) -> Union[Run, BadRu
run_id
)
else:
state_summary = self._engine_store.engine.state_view.get_summary()
state_summary = (
self._engine_store._run_orchestrator.engine.state_view.get_summary()
)
runner = self._engine_store.runner
parameters = runner.run_time_parameters if runner else []
run_resource = self._run_store.get(run_id=run_id)
Expand Down Expand Up @@ -363,7 +365,7 @@ def get_commands_slice(
RunNotFoundError: The given run identifier was not found in the database.
"""
if run_id == self._engine_store.current_run_id:
the_slice = self._engine_store.engine.state_view.commands.get_slice(
the_slice = self._engine_store._run_orchestrator.engine.state_view.commands.get_slice(
cursor=cursor, length=length
)
return the_slice
Expand All @@ -383,7 +385,9 @@ def get_current_command(self, run_id: str) -> Optional[CommandPointer]:
run_id: ID of the run.
"""
if self._engine_store.current_run_id == run_id:
return self._engine_store.engine.state_view.commands.get_current()
return (
self._engine_store._run_orchestrator.engine.state_view.commands.get_current()
)
else:
# todo(mm, 2024-05-20):
# For historical runs to behave consistently with the current run,
Expand All @@ -399,7 +403,9 @@ def get_recovery_target_command(self, run_id: str) -> Optional[CommandPointer]:
run_id: ID of the run.
"""
if self._engine_store.current_run_id == run_id:
return self._engine_store.engine.state_view.commands.get_recovery_target()
return (
self._engine_store._run_orchestrator.engine.state_view.commands.get_recovery_target()
)
else:
# Historical runs can't have any ongoing error recovery.
return None
Expand All @@ -416,7 +422,7 @@ def get_command(self, run_id: str, command_id: str) -> Command:
CommandNotFoundError: The given command identifier was not found.
"""
if self._engine_store.current_run_id == run_id:
return self._engine_store.engine.state_view.commands.get(
return self._engine_store._run_orchestrator.engine.state_view.commands.get(
command_id=command_id
)

Expand All @@ -426,7 +432,7 @@ def get_all_commands_as_preserialized_list(self, run_id: str) -> List[str]:
"""Get all commands of a run in a serialized json list."""
if (
run_id == self._engine_store.current_run_id
and not self._engine_store.engine.state_view.commands.get_is_terminal()
and not self._engine_store._run_orchestrator.engine.state_view.commands.get_is_terminal()
):
raise PreSerializedCommandsNotAvailableError(
"Pre-serialized commands are only available after a run has ended."
Expand All @@ -435,7 +441,7 @@ def get_all_commands_as_preserialized_list(self, run_id: str) -> List[str]:

def _get_state_summary(self, run_id: str) -> Union[StateSummary, BadStateSummary]:
if run_id == self._engine_store.current_run_id:
return self._engine_store.engine.state_view.get_summary()
return self._engine_store._run_orchestrator.engine.state_view.get_summary()
else:
return self._run_store.get_state_summary(run_id=run_id)

Expand Down
9 changes: 5 additions & 4 deletions robot-server/tests/runs/test_engine_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ async def test_get_default_engine_run_stopped(subject: EngineStore) -> None:
protocol=None,
notify_publishers=mock_notify_publishers,
)
await subject.finish()
await subject.finish(error=None)

result = await subject.get_default_engine()
assert isinstance(result, ProtocolEngine)
Expand All @@ -321,22 +321,23 @@ async def test_estop_callback(

decoy.when(engine_store.current_run_id).then_return(None)
await handle_estop_event(engine_store, disengage_event)
assert subject._run_orchestrator is not None
assert engine_store._run_orchestrator is not None
decoy.verify(
engine_store._run_orchestrator.engine.estop(),
ignore_extra_args=True,
times=0,
)
decoy.verify(
await engine_store.finish(),
await engine_store.finish(error=None),
ignore_extra_args=True,
times=0,
)

decoy.when(engine_store.current_run_id).then_return("fake-run-id")
await handle_estop_event(engine_store, engage_event)
assert engine_store._run_orchestrator is not None
decoy.verify(
engine_store.engine.estop(),
engine_store._run_orchestrator.engine.estop(),
await engine_store.finish(error=matchers.IsA(EStopActivatedError)),
times=1,
)

0 comments on commit 7bd9f5f

Please sign in to comment.