-
Notifications
You must be signed in to change notification settings - Fork 178
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
refactor(api): hardware controller use error codes #13318
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## edge #13318 +/- ##
==========================================
- Coverage 71.26% 71.08% -0.19%
==========================================
Files 1588 1593 +5
Lines 52824 53026 +202
Branches 3481 3548 +67
==========================================
+ Hits 37646 37693 +47
- Misses 14627 14782 +155
Partials 551 551
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline feedback!
|
||
@wraps(func) | ||
async def wrapper(self: Any, *args: Any, **kwargs: Any) -> Any: | ||
if self.update_required and self.initialized: | ||
raise FirmwareUpdateRequired() | ||
raise FirmwareUpdateRequiredError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the idea with these errors is that you can pack details in them, and we should generally take advantage of that. so here for instance, you could put in the details
argument a dict containing like
func.__name__
update_required
andinitialized
- maybe even poke into
self.subsystems
and figuring out which subsystems need the update
def __init__(self, message: str): | ||
self.message = message | ||
super().__init__() | ||
super().__init__(message=message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should also pass the details in and store them in details
api/src/opentrons/hardware_control/instruments/ot3/gripper_handler.py
Outdated
Show resolved
Hide resolved
aa3095e
to
2ec3a3f
Compare
3f62208
to
92ce759
Compare
HardwareMustHomeError -> PositionUnknownError GripperNotAttachedError -> GripperNotPresentError AxisNotPresentError -> InvalidActuator FirmwareUpdateRequired -> FirmwareUpdateRequiredError FirmwareUpdateFailed -> FirmwareUpdateFailedError InvalidMove -> InvalidCriticalPoint UpdateOngoingError as part of RobotInUseError NotSupportedByHardware -> UnsupportedHardwareCommand NoTipAttachedError -> UnexpectedTipRemovalError TipAttachedError -> UnexpectedTipAttachError add detail for error msgs in ot3api.py gripper errors fix tests
cae045d
to
306b9d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple nitpicks but looking good!
@@ -107,7 +107,7 @@ async def get_position( | |||
critical_point=pipette_location.critical_point, | |||
fail_on_not_homed=fail_on_not_homed, | |||
) | |||
except HardwareMustHomeError as e: | |||
except PositionUnknownError as e: | |||
raise MustHomeError(str(e)) from e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should link the lower level error with wraps=[e]
@@ -167,7 +167,7 @@ async def move_relative( | |||
critical_point=critical_point, | |||
fail_on_not_homed=True, | |||
) | |||
except HardwareMustHomeError as e: | |||
except PositionUnknownError as e: | |||
raise MustHomeError(str(e)) from e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should link the error with wraps=[e]
f"Motor positions for {str(mount)} are missing; must first home motors." | ||
raise PositionUnknownError( | ||
message=f"Motor positions for {str(mount)} are missing; must first home motors.", | ||
detail={"mount": str(mount)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we put the exact missing axis positions in the mount?
raise MustHomeError( | ||
f"Current position of {str(mount)} pipette is unknown, please home." | ||
raise PositionUnknownError( | ||
message=f"Current position of {str(mount)} pipette is unknown, please home." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe put in the details whether the problem is that the axis isn't homed or that position hasn't been pulled yet
raise NotSupportedByHardware( | ||
f"At least one axis in {axes} is not supported on the OT2." | ||
raise UnsupportedHardwareCommand( | ||
message=f"At least one axis in {axes} is not supported on the OT2." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe worth putting in which axis it is, at least in the details
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Overview
We are now using the error codes in the hardware controller api. Let me know if i forgot anything!