Skip to content

Commit

Permalink
Allow resume-from-recovery and stop (but nothing else) while `awa…
Browse files Browse the repository at this point in the history
…iting-recovery`.
  • Loading branch information
SyntaxColoring committed Mar 19, 2024
1 parent 4491e58 commit 05c9986
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions api/src/opentrons/protocol_engine/state/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,38 +725,47 @@ def validate_action_allowed( # noqa: C901
SetupCommandNotAllowedError: The engine is running, so a setup command
may not be added.
"""
if self.get_status() == EngineStatus.AWAITING_RECOVERY:
# While we're developing error recovery, we'll conservatively disallow
# all actions, to avoid putting the engine in weird undefined states.
# We'll allow specific actions here as we flesh things out and add support
# for them.
raise NotImplementedError()

if isinstance(action, ResumeFromRecoveryAction):
# https://opentrons.atlassian.net/browse/EXEC-301
raise NotImplementedError()

if self._state.run_result is not None:
raise RunStoppedError("The run has already stopped.")

elif isinstance(action, PlayAction):
if self.get_status() == EngineStatus.BLOCKED_BY_OPEN_DOOR:
raise RobotDoorOpenError("Front door or top window is currently open.")
elif self.get_status() == EngineStatus.AWAITING_RECOVERY:
raise NotImplementedError()
else:
return action

elif isinstance(action, PauseAction):
if not self.get_is_running():
raise PauseNotAllowedError("Cannot pause a run that is not running.")
elif self.get_status() == EngineStatus.AWAITING_RECOVERY:
raise NotImplementedError()
else:
return action

elif (
isinstance(action, QueueCommandAction)
and action.request.intent == CommandIntent.SETUP
):
if self._state.queue_status != QueueStatus.SETUP:
elif isinstance(action, QueueCommandAction):
if (
action.request.intent == CommandIntent.SETUP
and self._state.queue_status != QueueStatus.SETUP
):
raise SetupCommandNotAllowedError(
"Setup commands are not allowed after run has started."
)
else:
return action

elif isinstance(action, ResumeFromRecoveryAction):
if self.get_status() != EngineStatus.AWAITING_RECOVERY:
raise NotImplementedError()
else:
return action

return action
elif isinstance(action, StopAction):
return action

else:
assert_never(action)

def get_status(self) -> EngineStatus:
"""Get the current execution status of the engine."""
Expand Down

0 comments on commit 05c9986

Please sign in to comment.