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): Actually ignore errors that are marked as ignorable #15850

Merged
merged 3 commits into from
Jul 31, 2024
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
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
Loading