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

feat(api,robot-server): check pipette offset consistency #13583

Merged
merged 4 commits into from
Sep 19, 2023

Conversation

sfoster1
Copy link
Member

@sfoster1 sfoster1 commented Sep 18, 2023

Add a basic instrument offset consistency check to drive UI indicating that an instrument may be miscalibrated and the user should run calibration.

This checks the consistency between the calibrated pipette offsets of the left and right pipettes. It detects a problem if

  • There are two pipettes
  • Both are calibrated
  • Their calibration offsets differ by more than 1.5mm in any axis (this is tunable)

In other situations they succeed.

The outcome of this check shouldn't be treated as definitely meaning a calibration is bad; rather, it can serve as a hint that a user might want to retry calibration (so for instance if we display a banner on this it should be dismissable).

Closes RAUT-738

Testing

  • Check that a robot with two pipettes with similar offsets passes
  • Check that a robot with two pipettes with different enough offsets fails
  • Check that a robot with one pipette passes
  • Take an inventory of robots and see if 1.5 is appropriate

Add a basic instrument offset consistency check to drive UI indicating
that an insturment may be miscalibrated and the user should run
calibration.

Closes RAUT-738
@codecov
Copy link

codecov bot commented Sep 18, 2023

Codecov Report

Merging #13583 (02b907e) into chore_release-7.0.0 (581bc6c) will not change coverage.
Report is 3 commits behind head on chore_release-7.0.0.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                  @@
##           chore_release-7.0.0   #13583   +/-   ##
====================================================
  Coverage                71.32%   71.32%           
====================================================
  Files                     2422     2422           
  Lines                    68142    68142           
  Branches                  7934     7934           
====================================================
  Hits                     48605    48605           
  Misses                   17680    17680           
  Partials                  1857     1857           
Flag Coverage Δ
g-code-testing 96.44% <ø> (ø)
notify-server 89.13% <ø> (ø)
react-api-client 69.30% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
api/src/opentrons/hardware_control/ot3api.py 79.59% <ø> (ø)

@sfoster1 sfoster1 marked this pull request as ready for review September 19, 2023 16:53
@sfoster1 sfoster1 requested review from a team as code owners September 19, 2023 16:53
@sfoster1 sfoster1 changed the title feat(api,robot-server): offset consistency feat(api,robot-server): check pipette offset consistency Sep 19, 2023
Copy link
Contributor

@Laura-Danielle Laura-Danielle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of my comments are blocking. In general it looks good to me, but unsure about some of the data we're providing.


@dataclass
class InconsistentPipetteOffsets:
kind: Literal["inconsistent-pipette-offset"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need kind if InconsistentPipetteOffsets is already its own class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's to have future support for the thing that goes in the reasonability_check_failures being a discriminated union if we add more checks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but we're already calling the dataclass InconsistentPipetteOffsets which feels restricted to me. Also what if the other checks require other data inputs that don't map to what InconsistentPipetteOffsets requires? I'm just not sure if we need to worry about future proofing that much at the moment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this dataclass is called InconsistentPipetteOffsets, but if you look below, the type that's bound into the PipetteOffsetSummary is actually ReasonabilityCheckFailure which is a union of (right now) one element. And having other checks have different data is exactly what the discriminated union is for - we'd definitely have to change stuff internally but we wouldn't have to change the shape of the server code or responses.

):
return []
diff = left_offset - right_offset
if any(abs(d) > PIPETTE_OFFSET_CONSISTENCY_LIMIT for d in diff):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does the limit come from?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussions with hardware

return [
InconsistentPipetteOffsets(
"inconsistent-pipette-offset",
{Mount.LEFT: left_offset, Mount.RIGHT: right_offset},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we already provide the offsets in the UI for users, could we not just pass in the difference and/or only show th e limit here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, but it feels kind of nice to have it in the error class (kind of like the details fields in the error codes)

taken as an advisory.
"""

kind: Literal["inconsistent-pipette-offset"] = "inconsistent-pipette-offset"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments for this as per the dataclass in instruments/ot3

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same answer - adds support for a discriminated union of different kinds of checks with different payloads

@sfoster1 sfoster1 merged commit ffaa00f into chore_release-7.0.0 Sep 19, 2023
@sfoster1 sfoster1 deleted the add-instrument-offset-consistency-check branch September 19, 2023 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants