Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): stop-requested hanging on stop when awaiting-recovery #15066

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/src/opentrons/protocol_engine/state/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ def handle_action(self, action: Action) -> None: # noqa: C901

elif isinstance(action, StopAction):
if not self._state.run_result:
if self._state.queue_status == QueueStatus.AWAITING_RECOVERY:
self._state.recovery_target_command_id = None

self._state.queue_status = QueueStatus.PAUSED
if action.from_estop:
self._state.stopped_by_estop = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,41 @@ def test_command_store_handles_stop_action(
assert subject.state.command_history.get_setup_queue_ids() == OrderedSet()


def test_command_store_handles_stop_action_when_awaiting_recovery() -> None:
"""It should mark the engine as non-gracefully stopped on StopAction."""
subject = CommandStore(is_door_open=False, config=_make_config())

subject.handle_action(
PlayAction(
requested_at=datetime(year=2021, month=1, day=1), deck_configuration=[]
)
)

subject.state.queue_status = QueueStatus.AWAITING_RECOVERY

subject.handle_action(StopAction())

assert subject.state == CommandState(
command_history=CommandHistory(),
queue_status=QueueStatus.PAUSED,
run_result=RunResult.STOPPED,
run_completed_at=None,
is_door_blocking=False,
run_error=None,
finish_error=None,
failed_command=None,
command_error_recovery_types={},
recovery_target_command_id=None,
run_started_at=datetime(year=2021, month=1, day=1),
latest_protocol_command_hash=None,
stopped_by_estop=False,
)
assert subject.state.command_history.get_running_command() is None
assert subject.state.command_history.get_all_ids() == []
assert subject.state.command_history.get_queue_ids() == OrderedSet()
assert subject.state.command_history.get_setup_queue_ids() == OrderedSet()


def test_command_store_cannot_restart_after_should_stop() -> None:
"""It should reject a play action after finish."""
subject = CommandStore(is_door_open=False, config=_make_config())
Expand Down
Loading