Skip to content

Commit

Permalink
convert liquid not found error to EnumeratedError
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanthecoder committed May 7, 2024
1 parent e2996a9 commit fba4b86
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 21 deletions.
9 changes: 5 additions & 4 deletions api/src/opentrons/hardware_control/backends/ot3controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@
EstopState,
HardwareEventHandler,
HardwareEventUnsubscriber,
LiquidNotFound,
)
from opentrons.hardware_control.errors import (
InvalidPipetteName,
Expand Down Expand Up @@ -192,6 +191,7 @@
PipetteOverpressureError,
FirmwareUpdateRequiredError,
FailedGripperPickupError,
LiquidNotFoundError,
)

from .subsystem_manager import SubsystemManager
Expand Down Expand Up @@ -1406,11 +1406,12 @@ async def liquid_probe(
or positions[head_node].move_ack
== MoveCompleteAck.complete_without_condition
):
raise LiquidNotFound(
raise LiquidNotFoundError(
"Liquid not found during probe.",
{
node_to_axis(node): point.motor_position
str(node_to_axis(node)): str(point.motor_position)
for node, point in positions.items()
}
},
)
return self._position[axis_to_node(Axis.by_mount(mount))]

Expand Down
4 changes: 1 addition & 3 deletions api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2556,9 +2556,7 @@ async def liquid_probe(
reading from the pressure sensor.
If the move is completed without the specified threshold being triggered, a
LiquidNotFound error will be thrown.
If the threshold is triggered before the minimum z distance has been traveled,
a EarlyLiquidSenseTrigger error will be thrown.
LiquidNotFoundError error will be thrown.
Otherwise, the function will stop moving once the threshold is triggered,
and return the position of the
Expand Down
9 changes: 0 additions & 9 deletions api/src/opentrons/hardware_control/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,15 +694,6 @@ def __init__(
)


class LiquidNotFound(RuntimeError):
"""Error raised if liquid sensing move completes without detecting liquid."""

def __init__(self, position: Dict[Axis, float]) -> None:
"""Initialize LiquidNotFound error."""
super().__init__(f"Liquid threshold not found, current_position = {position}")
self.position = position


class FailedTipStateCheck(RuntimeError):
"""Error raised if the tip ejector state does not match the expected value."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
EstopState,
CurrentConfig,
InstrumentProbeType,
LiquidNotFound,
)
from opentrons.hardware_control.errors import (
InvalidPipetteName,
Expand Down Expand Up @@ -96,6 +95,7 @@
EStopNotPresentError,
FirmwareUpdateRequiredError,
FailedGripperPickupError,
LiquidNotFoundError,
)

from opentrons_hardware.hardware_control.move_group_runner import MoveGroupRunner
Expand Down Expand Up @@ -725,7 +725,7 @@ async def test_liquid_probe(
threshold_pascals=fake_liquid_settings.sensor_threshold_pascals,
output_option=fake_liquid_settings.output_option,
)
except LiquidNotFound:
except LiquidNotFoundError:
# the move raises a liquid not found now since we don't call the move group and it doesn't
# get any positions back
pass
Expand Down
8 changes: 5 additions & 3 deletions hardware-testing/hardware_testing/liquid_sense/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
OT3Mount,
Axis,
top_types,
LiquidNotFound,
)

from hardware_testing.gravimetric.measurement.scale import Scale
Expand All @@ -27,6 +26,9 @@

from opentrons.protocol_api import ProtocolContext, Well, Labware

from opentrons_shared_data.errors.exceptions import LiquidNotFoundError


PROBE_MAX_TIME: Dict[int, float] = {
1: 2.75,
8: 1.75,
Expand Down Expand Up @@ -370,8 +372,8 @@ def _run_trial(run_args: RunArgs, tip: int, well: Well, trial: int) -> float:
# TODO add in stuff for secondary probe
try:
height = hw_api.liquid_probe(hw_mount, lps, probe_target)
except LiquidNotFound as lnf:
ui.print_info(f"Liquid not found current position {lnf.position}")
except LiquidNotFoundError as lnf:
ui.print_info(f"Liquid not found current position {lnf.detail}")
start_height -= z_dist
else:
break
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 @@ -122,6 +122,10 @@
"detail": "Motor Driver Error",
"category": "roboticsControlError"
},
"2017": {
"detail": "Liquid Not Found",
"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 @@ -60,6 +60,7 @@ class ErrorCodes(Enum):
EXECUTION_CANCELLED = _code_from_dict_entry("2014")
FAILED_GRIPPER_PICKUP_ERROR = _code_from_dict_entry("2015")
MOTOR_DRIVER_ERROR = _code_from_dict_entry("2016")
LIQUID_NOT_FOUND = _code_from_dict_entry("2017")
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
18 changes: 18 additions & 0 deletions shared-data/python/opentrons_shared_data/errors/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,24 @@ def __init__(
super().__init__(ErrorCodes.MOTOR_DRIVER_ERROR, message, detail, wrapping)


class LiquidNotFoundError(RoboticsControlError):
"""Error raised if liquid sensing move completes without detecting liquid."""

def __init__(
self,
message: Optional[str] = None,
detail: Optional[Dict[str, str]] = None,
wrapping: Optional[Sequence[EnumeratedError]] = None,
) -> None:
"""Initialize LiquidNotFoundError."""
super().__init__(
ErrorCodes.LIQUID_NOT_FOUND,
message,
detail,
wrapping,
)


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

Expand Down

0 comments on commit fba4b86

Please sign in to comment.