Skip to content

Commit

Permalink
fix(api): Actually ignore errors that are marked as ignorable (#15850)
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxColoring authored Jul 31, 2024
1 parent 5d39889 commit 8739d72
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
8 changes: 5 additions & 3 deletions api/src/opentrons/protocol_engine/clients/transports.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,13 @@ async def run_in_pe_thread() -> Command:
)

if command.error is not None:
error_was_recovered_from = (
error_recovery_type = (
self._engine.state_view.commands.get_error_recovery_type(command.id)
== ErrorRecoveryType.WAIT_FOR_RECOVERY
)
if not error_was_recovered_from:
error_should_fail_run = (
error_recovery_type == ErrorRecoveryType.FAIL_RUN
)
if error_should_fail_run:
error = command.error
# TODO: this needs to have an actual code
raise ProtocolCommandFailedError(
Expand Down
8 changes: 5 additions & 3 deletions api/src/opentrons/protocol_runner/protocol_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,15 @@ async def _add_and_execute_commands(self) -> None:
)
)
if executed_command.error is not None:
error_was_recovered_from = (
error_recovery_type = (
self._protocol_engine.state_view.commands.get_error_recovery_type(
executed_command.id
)
== ErrorRecoveryType.WAIT_FOR_RECOVERY
)
if not error_was_recovered_from:
error_should_fail_run = (
error_recovery_type == ErrorRecoveryType.FAIL_RUN
)
if error_should_fail_run:
raise ProtocolCommandFailedError(
original_error=executed_command.error,
message=f"{executed_command.error.errorType}: {executed_command.error.detail}",
Expand Down
7 changes: 7 additions & 0 deletions api/tests/opentrons/protocol_runner/test_protocol_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from opentrons.hardware_control import API as HardwareAPI
from opentrons.legacy_broker import LegacyBroker
from opentrons.protocol_api import ProtocolContext
from opentrons.protocol_engine.error_recovery_policy import ErrorRecoveryType
from opentrons.protocol_engine.types import PostRunHardwareState
from opentrons.protocols.api_support.types import APIVersion
from opentrons.protocols.parse import PythonParseMode
Expand Down Expand Up @@ -409,8 +410,14 @@ async def test_run_json_runner_stop_requested_stops_enqueuing(
createdAt=datetime(year=2021, month=1, day=1),
error=pe_errors.ProtocolEngineError(),
),
status=pe_commands.CommandStatus.FAILED,
)
)
decoy.when(
protocol_engine.state_view.commands.get_error_recovery_type(
"protocol-command-id"
)
).then_return(ErrorRecoveryType.FAIL_RUN)

await json_runner_subject.load(json_protocol_source)

Expand Down

0 comments on commit 8739d72

Please sign in to comment.