Skip to content

Commit

Permalink
changed logic for current command errors
Browse files Browse the repository at this point in the history
  • Loading branch information
TamarZanzouri committed Nov 5, 2024
1 parent 85eda17 commit 5bc0500
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
7 changes: 6 additions & 1 deletion api/src/opentrons/protocol_engine/state/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,12 @@ def get_error(self) -> Optional[ErrorOccurrence]:

def get_all_errors(self) -> List[ErrorOccurrence]:
"""Get the run's full error list, if there was none, returns an empty list."""
return self._state.failed_command_errors
command_errors = self._state.command_history.get_all_commands()
return [
command_error.error
for command_error in command_errors
if command_error.error is not None
]

def get_has_entered_recovery_mode(self) -> bool:
"""Get whether the run has entered recovery mode."""
Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/protocol_runner/protocol_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
StateSummary,
Command,
commands as pe_commands,
ErrorOccurrence
)
from opentrons.protocols.parse import PythonParseMode
from opentrons.util.async_helpers import asyncio_yield
Expand Down Expand Up @@ -58,6 +57,7 @@ class RunResult(NamedTuple):
state_summary: StateSummary
parameters: List[RunTimeParameter]


class AbstractRunner(ABC):
"""An interface to manage and control a protocol run.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1046,8 +1046,15 @@ def test_get_errors_slice() -> None:
error_3 = ErrorOccurrence.construct(id="error-id-3") # type: ignore[call-arg]
error_4 = ErrorOccurrence.construct(id="error-id-4") # type: ignore[call-arg]

command_1 = create_failed_command(command_id="command-id-1", error=error_1)
command_2 = create_failed_command(command_id="command-id-2", error=error_2)
command_3 = create_failed_command(command_id="command-id-3", error=error_3)
command_4 = create_failed_command(command_id="command-id-4", error=error_4)
command_5 = create_running_command(command_id="command-id-5")
command_6 = create_queued_command(command_id="command-id-6")

subject = get_command_view(
failed_command_errors=[error_1, error_2, error_3, error_4]
commands=[command_1, command_2, command_3, command_4, command_5, command_6]
)

result = subject.get_errors_slice(cursor=1, length=3)
Expand Down

0 comments on commit 5bc0500

Please sign in to comment.