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

fix(api): allow aspirate/dispense at arbitrary locations #11352

Merged
merged 3 commits into from
Aug 17, 2022

Conversation

mcous
Copy link
Contributor

@mcous mcous commented Aug 16, 2022

Overview

The addition of tip-rack checking for aspirate/dispense in #7788 introduced a regression where previously valid aspirate and dispense calls to arbitrary deck coordinates would fail. This PR fixes the problems with the logic that was added in that PR to ensure aspirate and dispense work as expected.

Closes #11302, re: RSS-70

Changelog

  • fix(api): allow aspirate/dispense at arbitrary locations

Review requests

This bug was caused by misunderstandings with how to use the LabwareLike interface via Location.labware. We're experiencing similar issues in #11296.

See reproduction protocol in RSS-70 to validate that this PR does its job.

Risk assessment

Low

@mcous mcous added the papi-v2 Python API V2 label Aug 16, 2022
@mcous mcous requested a review from a team as a code owner August 16, 2022 16:51
@codecov
Copy link

codecov bot commented Aug 16, 2022

Codecov Report

Merging #11352 (cf99f3b) into release_6.1.0 (d28bc76) will increase coverage by 0.76%.
The diff coverage is n/a.

Impacted file tree graph

@@                Coverage Diff                @@
##           release_6.1.0   #11352      +/-   ##
=================================================
+ Coverage          66.59%   67.35%   +0.76%     
=================================================
  Files                447      464      +17     
  Lines               6624     6855     +231     
  Branches            1173     1173              
=================================================
+ Hits                4411     4617     +206     
- Misses              2014     2039      +25     
  Partials             199      199              
Flag Coverage Δ
notify-server 89.17% <ø> (?)

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

Impacted Files Coverage Δ
notify-server/notify_server/models/topics.py 0.00% <0.00%> (ø)
...erver/notify_server/models/hardware_event/names.py 100.00% <0.00%> (ø)
.../notify_server/models/hardware_event/door_state.py 100.00% <0.00%> (ø)
notify-server/notify_server/settings.py 100.00% <0.00%> (ø)
notify-server/notify_server/__init__.py 100.00% <0.00%> (ø)
...er/notify_server/models/hardware_event/__init__.py 100.00% <0.00%> (ø)
notify-server/notify_server/models/event.py 100.00% <0.00%> (ø)
notify-server/notify_server/network/connection.py 100.00% <0.00%> (ø)
notify-server/notify_server/clients/serdes.py 90.90% <0.00%> (ø)
notify-server/notify_server/logging.py 85.71% <0.00%> (ø)
... and 7 more

Copy link
Contributor

@SyntaxColoring SyntaxColoring left a comment

Choose a reason for hiding this comment

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

Fix makes sense to me. Thanks!

Comment on lines +131 to +132
if location.labware.is_module and reject_module:
raise ValueError("Cannot aspirate/dispense directly to a module")
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with your thoughts in the PR description about this fundamentally being about confusion around Location.labware and its LabwareLike type.

In an ideal world, I think we could refactor things to reduce that confusion:

  1. The name of the location.labware attribute is confusing because it's not necessarily a labware.
    • We could rename it to something like location.logical_anchor.
  2. LabwareLike is basically a union, but worse, because it erases the static type of the object.
    • Our methods could accept plain Unions instead of LabwareLike to spell out more precisely what kinds of locations they accept.
  3. The name of the LabwareLike type is confusing, in my opinion. Wells, modules, deck slots, and None are labware-unlike in many meaningful ways, but we mush them all into the LabwareLike box.
    • Same solution as above: let methods spell out what they accept on a case-by-case basis.

We'd have to be careful to preserve backwards compatibility, and APIv2 might not be worth the investment. But...it would be nice.

@@ -195,7 +195,9 @@ def aspirate(
"knows where it is."
)
if self.api_version >= APIVersion(2, 11):
instrument.validate_can_aspirate(dest)
instrument.validate_takes_liquid(
location=dest, reject_module=self.api_version >= APIVersion(2, 13)
Copy link
Contributor

Choose a reason for hiding this comment

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

The reject_module bool arg is a nice way of handling this behavioral change across versions. 👍

@@ -255,3 +255,4 @@ Version 2.13

- :py:meth:`.InstrumentContext.drop_tip` now has a ``prep_after`` parameter.
- :py:meth:`.InstrumentContext.home` may home *both* pipettes as needed to avoid collision risks.
- :py:meth:`.InstrumentContext.aspirate` and :py:meth:`.InstrumentContext.dispense` will avoid interacting directly with modules.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this validation is a good idea, but for my understanding: this is an independent change from the bug fix, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, came up naturally once the function started working with LabwareLike correctly. I decided that a fix guarded by the API version was a better move than leaving a TODO in the code, given that there was already a TODO pointing out the bug this PR set out to solve

Copy link
Member

@sanni-t sanni-t left a comment

Choose a reason for hiding this comment

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

LGTM.
Agree with @SyntaxColoring 's points above about disambiguating locations in the future.

@mcous mcous merged commit d9107d2 into release_6.1.0 Aug 17, 2022
@mcous mcous deleted the RSS-70_fix-liquid-handling-at-coordinate branch August 17, 2022 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
papi-v2 Python API V2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants