Skip to content

Commit

Permalink
add ExecutionCancelledError
Browse files Browse the repository at this point in the history
  • Loading branch information
ahiuchingau committed Sep 13, 2023
1 parent 891e344 commit 2ec3a3f
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 14 deletions.
2 changes: 0 additions & 2 deletions api/src/opentrons/hardware_control/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from .pause_manager import PauseManager
from .backends import Controller, Simulator
from .types import CriticalPoint, ExecutionState
from .errors import ExecutionCancelledError
from .constants import DROP_TIP_RELEASE_DISTANCE
from .thread_manager import ThreadManager
from .execution_manager import ExecutionManager
Expand Down Expand Up @@ -52,7 +51,6 @@
"ThreadManager",
"ExecutionManager",
"ExecutionState",
"ExecutionCancelledError",
"ThreadedAsyncLock",
"ThreadedAsyncForbidden",
"ThreadManagedHardware",
Expand Down
5 changes: 0 additions & 5 deletions api/src/opentrons/hardware_control/errors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import Optional
from .types import OT3Mount
from opentrons_shared_data.errors.exceptions import (
MotionPlanningFailureError,
InvalidInstrumentData,
Expand All @@ -20,10 +19,6 @@ def __init__(self, cp_name: str, instr: str, message: Optional[str] = None):
)


class ExecutionCancelledError(RuntimeError):
pass


class InvalidPipetteName(InvalidInstrumentData):
"""Raised for an invalid pipette."""

Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/hardware_control/execution_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import functools
from typing import Set, TypeVar, Type, cast, Callable, Any, Awaitable, overload
from .types import ExecutionState
from .errors import ExecutionCancelledError
from opentrons_shared_data.errors.exceptions import ExecutionCancelledError

TaskContents = TypeVar("TaskContents")

Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/protocol_api/instrument_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Any, List, Optional, Sequence, Union, cast
from opentrons.broker import Broker
from opentrons.hardware_control.dev_types import PipetteDict
from opentrons import types, hardware_control as hc
from opentrons import types
from opentrons.commands import commands as cmds

from opentrons.commands import publisher
Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/protocols/execution/execute_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from opentrons.protocol_api import ProtocolContext
from opentrons.protocols.execution.errors import ExceptionInProtocolError
from opentrons.protocols.types import PythonProtocol, MalformedPythonProtocolError
from opentrons.hardware_control import ExecutionCancelledError
from opentrons.protocol_engine.errors import ProtocolCommandFailedError
from opentrons_shared_data.errors.exceptions import ExecutionCancelledError

MODULE_LOG = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from opentrons.hardware_control import (
ExecutionManager,
ExecutionState,
ExecutionCancelledError,
)
from opentrons_shared_data.errors.exceptions import ExecutionCancelledError


async def test_state_machine():
Expand Down
4 changes: 4 additions & 0 deletions shared-data/errors/definitions/1/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
"detail": "Position Unknown",
"category": "roboticsControlError"
},
"2013": {
"detail": "Execution Cancelled",
"category": "roboticsControlError"
},
"3000": {
"detail": "A robotics interaction error occurred.",
"category": "roboticsInteractionError"
Expand Down
1 change: 1 addition & 0 deletions shared-data/python/opentrons_shared_data/errors/codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class ErrorCodes(Enum):
INACCURATE_NON_CONTACT_SWEEP = _code_from_dict_entry("2010")
MISALIGNED_GANTRY = _code_from_dict_entry("2011")
POSITION_UNKNOWN = _code_from_dict_entry("2012")
EXECUTION_CANCELLED = _code_from_dict_entry("2013")
ROBOTICS_INTERACTION_ERROR = _code_from_dict_entry("3000")
LABWARE_DROPPED = _code_from_dict_entry("3001")
LABWARE_NOT_PICKED_UP = _code_from_dict_entry("3002")
Expand Down
25 changes: 22 additions & 3 deletions shared-data/python/opentrons_shared_data/errors/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,19 @@ def __init__(
super().__init__(ErrorCodes.POSITION_UNKNOWN, message, detail, wrapping)

Check warning on line 541 in shared-data/python/opentrons_shared_data/errors/exceptions.py

View check run for this annotation

Codecov / codecov/patch

shared-data/python/opentrons_shared_data/errors/exceptions.py#L541

Added line #L541 was not covered by tests


class ExecutionCancelledError(RoboticsControlError):
"""An error indicating that the robot's execution manager has been cancelled."""

def __init__(
self,
message: Optional[str] = None,
detail: Optional[Dict[str, Any]] = None,
wrapping: Optional[Sequence[EnumeratedError]] = None,
) -> None:
"""Build a ExecutionCancelledError."""
super().__init__(ErrorCodes.EXECUTION_CANCELLED, message, detail, wrapping)

Check warning on line 554 in shared-data/python/opentrons_shared_data/errors/exceptions.py

View check run for this annotation

Codecov / codecov/patch

shared-data/python/opentrons_shared_data/errors/exceptions.py#L554

Added line #L554 was not covered by tests


class LabwareDroppedError(RoboticsInteractionError):
"""An error indicating that the gripper dropped labware it was holding."""

Expand Down Expand Up @@ -596,7 +609,9 @@ def __init__(
checked_detail["pipette_name"] = pipette_name
checked_detail["mount"] = mount
message = f"Cannot perform {action} without a tip attached."
super().__init__(ErrorCodes.UNEXPECTED_TIP_REMOVAL, message, checked_detail, wrapping)
super().__init__(

Check warning on line 612 in shared-data/python/opentrons_shared_data/errors/exceptions.py

View check run for this annotation

Codecov / codecov/patch

shared-data/python/opentrons_shared_data/errors/exceptions.py#L608-L612

Added lines #L608 - L612 were not covered by tests
ErrorCodes.UNEXPECTED_TIP_REMOVAL, message, checked_detail, wrapping
)


class UnexpectedTipAttachError(RoboticsInteractionError):
Expand Down Expand Up @@ -642,7 +657,9 @@ def __init__(
wrapping: Optional[Sequence[EnumeratedError]] = None,
) -> None:
"""Build an PipetteOverpressureError."""
msg = f"The pressure sensor on the {mount} mount has exceeded operational limits."
msg = (

Check warning on line 660 in shared-data/python/opentrons_shared_data/errors/exceptions.py

View check run for this annotation

Codecov / codecov/patch

shared-data/python/opentrons_shared_data/errors/exceptions.py#L660

Added line #L660 was not covered by tests
f"The pressure sensor on the {mount} mount has exceeded operational limits."
)
super().__init__(ErrorCodes.PIPETTE_OVERPRESSURE, msg, detail, wrapping)

Check warning on line 663 in shared-data/python/opentrons_shared_data/errors/exceptions.py

View check run for this annotation

Codecov / codecov/patch

shared-data/python/opentrons_shared_data/errors/exceptions.py#L663

Added line #L663 was not covered by tests


Expand Down Expand Up @@ -777,4 +794,6 @@ def __init__(
wrapping: Optional[Sequence[EnumeratedError]] = None,
) -> None:
"""Build an UnsupportedHardwareCommand."""
super().__init__(ErrorCodes.NOT_SUPPORTED_ON_ROBOT_TYPE, message, detail, wrapping)
super().__init__(

Check warning on line 797 in shared-data/python/opentrons_shared_data/errors/exceptions.py

View check run for this annotation

Codecov / codecov/patch

shared-data/python/opentrons_shared_data/errors/exceptions.py#L797

Added line #L797 was not covered by tests
ErrorCodes.NOT_SUPPORTED_ON_ROBOT_TYPE, message, detail, wrapping
)

0 comments on commit 2ec3a3f

Please sign in to comment.