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

refactor(robot-server): implement the load labware function to accept tipracks from the client #7131

Merged
merged 11 commits into from
Jan 5, 2021

Conversation

Laura-Danielle
Copy link
Contributor

Overview

This PR supports #7901 on the backend.

Changelog

  • Add ability to pass a tiprack definition during a load labware command
  • Implement load labware for deck calibration and pipette offset
  • Add tests for that + modify older tests

Review requests

Due to pydantic union issues (again) I had to make the tiprack definition required in load labware. Should we try to do a refactor of request models to avoid using unions again here, or is this fine for now?

Risk assessment

Medium. We are changing how load labware works on the backend, and forcing the front end to pass in a tiprack definition for all of the user flows to this command.

We should test all of the user flows once #7901 is up.

@Laura-Danielle Laura-Danielle added ready for review robot server Affects the `robot-server` project labels Dec 15, 2020
@Laura-Danielle Laura-Danielle requested a review from a team December 15, 2020 15:16
@Laura-Danielle Laura-Danielle requested review from a team as code owners December 15, 2020 15:16
@codecov
Copy link

codecov bot commented Dec 15, 2020

Codecov Report

Merging #7131 (9fa965a) into edge (4cab53f) will decrease coverage by 0.05%.
The diff coverage is 84.45%.

Impacted file tree graph

@@            Coverage Diff             @@
##             edge    #7131      +/-   ##
==========================================
- Coverage   87.21%   87.16%   -0.06%     
==========================================
  Files          99       99              
  Lines        4489     4588      +99     
==========================================
+ Hits         3915     3999      +84     
- Misses        574      589      +15     
Impacted Files Coverage Δ
...ver/service/session/session_types/check_session.py 41.26% <ø> (ø)
.../session/session_types/deck_calibration_session.py 47.05% <0.00%> (-0.95%) ⬇️
...ession/session_types/pipette_offset_calibration.py 45.45% <33.33%> (-0.58%) ⬇️
...ce/session/session_types/tip_length_calibration.py 44.26% <40.00%> (-1.51%) ⬇️
...r/robot_server/robot/calibration/helper_classes.py 72.61% <53.33%> (-4.53%) ⬇️
...t_server/robot/calibration/tip_length/user_flow.py 89.93% <75.00%> (-0.33%) ⬇️
.../robot_server/robot/calibration/check/user_flow.py 73.13% <80.00%> (+0.01%) ⬆️
...obot-server/robot_server/robot/calibration/util.py 93.06% <81.81%> (-1.50%) ⬇️
...r/robot_server/robot/calibration/deck/user_flow.py 85.78% <83.33%> (+2.00%) ⬆️
...rver/robot/calibration/pipette_offset/user_flow.py 84.58% <97.72%> (+1.11%) ⬆️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4cab53f...9fa965a. Read the comment docs.

Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

We cannot require all loadLabware commands to contain a labware. The app in 4.0 sends this command for all the user flows, and this would therefore be a breaking API change.

We have to accept loadLabware commands without a definition element in all cases. In cases where it previously did nothing, it should continue to do nothing; in the cases we're adding, not sending a labware def should make it continue to do nothing, and stick with the labware def sent at session establish. I'm not sure what the best way to do that is - @amitlissack any ideas about the particulars of how to get this to work with pydantic?

@@ -81,6 +81,12 @@ class SetHasCalibrationBlockRequest(BaseModel):
description="whether or not there is a calibration block present")


class UpdateTiprackRequest(BaseModel):
tiprackDefinition: dict = Field(
Copy link
Member

Choose a reason for hiding this comment

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

This may want a richer type like at least Dict[str, Any]

pass
async def load_labware(self, tiprackDefinition: dict):
existing_offset_calibration = self._get_stored_pipette_offset_cal()
self._load_tip_rack(
Copy link
Member

Choose a reason for hiding this comment

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

let's validate this def against the schema and make sure it's a tiprack before passing it to _load_tiprack. _load_tiprack taking a LabwareDefinition means that the def should be checked for validity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't validate that anywhere else. Should I add that in to the create params as well for all of the flows?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah probably should! Should return a 4xx if it fails

def _determine_state_machine(
self, perform_tip_length: bool
) -> Tuple[PipetteOffsetStateMachine, GenericState]:
state_machine: PipetteOffsetStateMachine =\
Copy link
Member

Choose a reason for hiding this comment

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

Any way we can get rid of these type ignores?

Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

I'm ok moving forward with this but it is a little weird that it will always emit "loadLabware" as a supported command no matter the current state.

@mcous
Copy link
Contributor

mcous commented Jan 4, 2021

Just a heads up: The ProtocolEngine will almost certainly have separate loadLabware and loadLabwareFromDefinition commands defined. I think we should do the same here, especially if we're looking for the presence of some supported command to answer on the client side "can this thing load a custom labware"?

@Laura-Danielle Laura-Danielle force-pushed the allow_tiprack_selection_robot_server branch from cff6aa3 to 67fabb5 Compare January 5, 2021 15:54
Copy link
Contributor

@ahiuchingau ahiuchingau left a comment

Choose a reason for hiding this comment

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

Tested on robot, LGTM!

@Laura-Danielle Laura-Danielle merged commit 1c44453 into edge Jan 5, 2021
@Laura-Danielle Laura-Danielle deleted the allow_tiprack_selection_robot_server branch January 5, 2021 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
robot server Affects the `robot-server` project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants