You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(api): move last tip picked up tracking from context to engine (#19061)
# Overview
This PR refactors the way the Python API tracks where a tip has been
picked up from. Previously we were relying on the
`InstrumentContext._last_tip_picked_up_from` to keep track of which tip
rack well the current tip was picked up from, mostly for the purposes of
storing it for `return_tip`. The issue with this approach is that
anything that did not go through the top level instrument context,
whether it is via the cores or directly in protocol engine, would lead
to this not being updated and lead to either incorrect behavior for tip
returns or an error.
This became more acute with the introduction of liquid classes and
allowing them to return tips and keep them at the end, as this variable
wasn't getting updated and we had to manually code around that.
Now the tracking of the last tip rack well has been moved entirely to
the engine, where it will store it as a combination of `labware_id` and
`well_name`. This is then reconstructed into a `LabwareCore` and
`WellCore` by the `InstrumentCore`, which is further reconstructed into
a `Well` object by the top level `InstrumentContext`. This allowed a lot
of the liquid class scaffolding around this issue to be removed and
those methods to be simplified.
This change also required adding this functionality to the legacy core.
With no engine, in those older cores we are now simply storing the
legacy labware and well cores when a pick up tip or drop tip is called,
allowing this new method to work via both intefaces.
Because it was discovered a lot of older protocols rely on
`_last_tip_picked_up_from`, a property of the same name was added that
uses the new interface. In addition, a version gated
`current_tip_source_well()` function was added to provide a
version-protected method that should now be used instead.
## Test Plan and Hands on Testing
Snapshots and integration tests should cover a lot of the regression
testing, but the following protocols will be tested:
```
requirements = {
"robotType": "Flex",
"apiLevel": "2.25"
}
metadata = {
"protocolName":'Return tip new',
'author':'Jeremy'
}
def run(protocol_context):
tiprack = protocol_context.load_labware("opentrons_flex_96_tiprack_200ul", "C2")
trash = protocol_context.load_trash_bin('A3')
pipette_1k = protocol_context.load_instrument("flex_1channel_1000", "right", tip_racks=[tiprack])
nest_plate = protocol_context.load_labware("nest_96_wellplate_2ml_deep", "D1")
arma_plate = protocol_context.load_labware("armadillo_96_wellplate_200ul_pcr_full_skirt", "D3")
pipette_1k.pick_up_tip()
pipette_1k.return_tip()
water_class = protocol_context.get_liquid_class("water")
pipette_1k.transfer_with_liquid_class(
liquid_class=water_class,
volume=200,
source=nest_plate.wells()[:4],
dest=arma_plate.wells()[:4],
new_tip="always",
trash_location=trash,
return_tip=True,
)
pipette_1k.transfer_with_liquid_class(
liquid_class=water_class,
volume=200,
source=nest_plate.wells()[0],
dest=arma_plate.wells()[0],
new_tip="once",
trash_location=trash,
keep_last_tip=True
)
pipette_1k.return_tip()
```
```
requirements = {
"robotType": "OT-2",
"apiLevel": "2.13"
}
metadata = {
"protocolName":'Return tip OT-2 2.13',
'author':'Jeremy'
}
def run(protocol_context):
p300rack = protocol_context.load_labware('opentrons_96_tiprack_300ul', 1)
p300 = protocol_context.load_instrument('p300_single_gen2', 'left', tip_racks=[p300rack])
p300.pick_up_tip()
p300.return_tip()
```
## Changelog
- Refactored `_last_tip_picked_up_from` to use engine and cores to keep
track of tip, not the instrument context
## Review requests
Does the way we reconstruct the `Well` object make sense?
## Risk assessment
Medium/high, this refactor touches a lot of long existing methods and is
not gated by version. There's no new logic added but this affects not
only Flex run code but OT-2 older API versions as well.
---------
Co-authored-by: David Chau <[email protected]>
0 commit comments