Skip to content

Commit

Permalink
weep
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxColoring committed Mar 11, 2024
1 parent 11799b3 commit 97285cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions api/src/opentrons/protocol_engine/state/command_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def get_failed_command(self) -> Optional[CommandEntry]:
def get_queued_command_ids(self) -> OrderedSet[str]:
return self._queued_command_ids

def get_queued_setup_command_ids(self) -> OrderedSet[str]:
return self._queued_setup_command_ids

def add_queued(self, queued_command: Command) -> None:
assert queued_command.status == CommandStatus.QUEUED
assert not self.has(queued_command.id)
Expand Down
18 changes: 9 additions & 9 deletions api/src/opentrons/protocol_engine/state/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ def __init__(
run_result=None,
run_error=None,
finish_error=None,
failed_command=None,
run_completed_at=None,
run_started_at=None,
latest_command_hash=None,
Expand Down Expand Up @@ -473,13 +472,15 @@ def get_next_to_execute(self) -> Optional[str]:
raise RunStoppedError("Engine was stopped")

# if there is a setup command queued, prioritize it
next_setup_cmd = self._state.queued_setup_command_ids.head(None)
next_setup_cmd = self._state.command_structure.get_queued_command_ids().head(
None
)
if self._state.queue_status != QueueStatus.PAUSED and next_setup_cmd:
return next_setup_cmd

# if the queue is running, return the next protocol command
if self._state.queue_status == QueueStatus.RUNNING:
return self._state.queued_command_ids.head(None)
return self._state.command_structure.get_queued_command_ids().head(None)

# otherwise we've got nothing to do
return None
Expand All @@ -490,8 +491,8 @@ def get_is_okay_to_clear(self) -> bool:
return True
elif (
self.get_status() == EngineStatus.IDLE
and self._state.running_command_id is None
and len(self._state.queued_setup_command_ids) == 0
and self._state.command_structure.get_running_command() is None
and len(self._state.command_structure.get_queued_setup_command_ids()) == 0
):
return True
else:
Expand Down Expand Up @@ -539,15 +540,14 @@ def get_all_commands_final(self) -> bool:
CommandExecutionFailedError: if any added command failed, and its `intent` wasn't
`setup`.
"""
no_command_running = self._state.running_command_id is None
no_command_running = self._state.command_structure.get_running_command() is None
no_command_to_execute = (
self._state.run_result is not None
or len(self._state.queued_command_ids) == 0
or len(self._state.command_structure.get_queued_command_ids()) == 0
)

if no_command_running and no_command_to_execute:
for command_id in self._state.all_command_ids:
command = self._state.commands_by_id[command_id].command
for command in self._state.command_structure.get_all():
if command.error and command.intent != CommandIntent.SETUP:
# TODO(tz, 7-11-23): avoid raising an error and return the status instead
raise ProtocolCommandFailedError(
Expand Down

0 comments on commit 97285cb

Please sign in to comment.