-
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
fix(api): simulation allows aspirating and dispensing on a tip rack #7788
Conversation
Doing the most basic fix and testing whether the destination is a tip-rack. I don't like it. It seems like there is a nicer and more general solution to validation problems. Though it looks like validation is often combined with type constraining. Will either put up a draft PR or pursue alternative: - refactor `aspirate` to see if the destination is a tiprack and raise runtime error if it is. - create a test protocol to unit test - adding change to .gitignore to include package-lock.json as it does not seem to be in the project but is generated if one does `npm install` on the root.
…vention already used (though no bug protocol scripts, I don't think)
Codecov Report
@@ Coverage Diff @@
## edge #7788 +/- ##
==========================================
+ Coverage 83.46% 83.48% +0.01%
==========================================
Files 333 333
Lines 21215 21228 +13
==========================================
+ Hits 17708 17722 +14
+ Misses 3507 3506 -1
Continue to review full report at Codecov.
|
…t complexity. And happily he did 'cause I totally disregarded dispense. Have since: - moved validation to keep validation in instrument.py company - unit test them - fix linting issues
e9820f9
to
e873a6e
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.
Less than 7 days in and you are venturing into some of our trickiest code. You are a brave soul.
…e_can_dispense` to locations as it cannot be anything other - updating unit tests
Haha, thanks! It was really educational and also touched a number of things and made me know how little I know...which I should have known... |
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.
Definitely some of our trickiest code
@@ -104,3 +104,47 @@ def determine_drop_target( | |||
assert tr.is_tiprack | |||
z_height = return_height * tr.tip_length | |||
return location.top(-z_height) | |||
|
|||
|
|||
def validate_can_aspirate( |
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.
(Ignore if you are already working on this) I think we can make a single validation for both aspirate and dispense. In fact, I feel like your _is_tiprack
function might be just the thing we need.
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.
That makes sense, but I guess I was/am thinking two (or three) things:
- Does this conflict with this feedback - https://github.com/Opentrons/opentrons/pull/7788/files#r630606222?
- I was thinking about the possibilities of validation. Right now it is very simple, but conceptually (in a future where we know more about the state of the deck) it seems like it could be capable of more. Such as validating that there is stuff in the location. Or that there is a tube in the location. Or if dispensing is the tube going to overflow.... Maybe I am making up stuff that we don't care about.
- Isolating validation. It seems like it has the potential to be a whole layer of responsibility of its own? But also, I ran into lint complexity issues when I attempted to make the change inline (https://github.com/Opentrons/opentrons/pull/7788/files#diff-6811e2f4d45b8d159abed031a1b00c50e69ecc5aa7d8e19a674527fb4be3298cR186).
Please let me know what you think. My mission certainly isn't to unnecessarily change the way you guys do things.
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.
(^might be my uninformed suggestion, so let me know if there's a specific reason for having separate logic for aspirate vs dispense)
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.
At the moment, none. But in a future where we knew what was in them then I can see (provided I am right and aspirate means to suck stuff out of a location) different concerns for the two. Sort of like I was saying in #2 above. For example, what if nothing is in the location from which you are trying to aspirate. Or if a location is beyond capacity once a dispense is performed. And then there is the differences in messaging that we send back in the exception. But here I think you are suggesting that I move the test and exception throwing into instrument_context? There I ran into complexity issues with the linter, but That was a three line conditional vs. a two line conditional.
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.
Was just thinking about dispense and the possibilities if we were smart(er). For example, let's pretend that we know whatever is the pipette when mixed with whatever is in the destination will cause an 💥 . That made me laugh. Don't think we are anywhere close to that. And maybe the user wants to blow themselves up. Who are we to judge!?
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.
Got it! Thanks for that explanation! So now I understand the thought process behind making two separate validations for aspirate & dispense but I still don't get why their logic is different. Can't both take a types.Location
and just check for if labware.parent and labware.parent.is_tiprack:
?
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.
@sanni-t - I changed it as a reaction to this feedback - #7788 (comment). It seems that we always know that the location is a (sorry, didn't fully understand what you were saying). Let me see....Location
and that being the case agreed with @amitlissack in that we don't need to add variability if we don't need it; thinking that it might lead to confusing conclusions (in the brains of other developers).
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.
@sanni-t - yes, you are totally right. I think I was too literal about @amitlissack 's suggestion. I see now that they both are constrained to Location
. Thanks and fixing.
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 changeset looks pretty good to me! Only putting this as a "change request" to make sure we don't accidentally merge before sorting out the API version
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.
API version bump changes look good. Added additional context for what I meant by "adding a gate"
…using lint complexity issues. Silencing 'cause I don't feel like refactoring the method as there is no complexity introduced that the method has not already had a taste of.
…ain types that may be aspirated and dispensed to `Location`
03dc712
to
dc62508
Compare
Co-authored-by: Mike Cousins <[email protected]>
Co-authored-by: Mike Cousins <[email protected]>
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.
🎥
Overview
The robot does not raise an error or warning when trying to aspirate and dispense on a tip rack. This occurs during the simulation and the tip rack is from the Opentrons labware library, not customized.
I am doing the most basic fix and testing which is to test whether destination is a tip-rack. I don't like it. It seems like there is a nicer and more general solution to validation problems. Though it looks like validation is often combined with type constraining. But have since learned/been-reminded that there is an architectural revision planned in the near future that will revise how validation is done. So, in the meantime I am sticking with the fix within.
Changelog
aspirate
anddispense
to see if the destination is a tiprack and raise runtime error if it is.npm install
on the root.Review requests
Do we want to try to centralize validation. I understand that it happens at different levels, but think there could be value in attempting to group the functionality, the messaging, possible re-use.See overview.aspirate
anddispense
?Risk assessment