-
Notifications
You must be signed in to change notification settings - Fork 179
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): OT2 fixed trash load fix and API 2,15 support for new trash container structure #14145
Changes from all commits
1dacc49
ba0f1c8
9933c3d
d3313f4
21432b4
6fd0245
d9d03f2
d1e2c7d
7703efb
82ea645
0147462
38a30b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -23,7 +23,10 @@ | |||||||||||||
from opentrons.commands import protocol_commands as cmds, types as cmd_types | ||||||||||||||
from opentrons.commands.publisher import CommandPublisher, publish | ||||||||||||||
from opentrons.protocols.api_support import instrument as instrument_support | ||||||||||||||
from opentrons.protocols.api_support.deck_type import NoTrashDefinedError | ||||||||||||||
from opentrons.protocols.api_support.deck_type import ( | ||||||||||||||
NoTrashDefinedError, | ||||||||||||||
should_load_fixed_trash_for_python_protocol, | ||||||||||||||
) | ||||||||||||||
from opentrons.protocols.api_support.types import APIVersion | ||||||||||||||
from opentrons.protocols.api_support.util import ( | ||||||||||||||
AxisMaxSpeeds, | ||||||||||||||
|
@@ -138,7 +141,26 @@ def __init__( | |||||||||||||
mount: None for mount in Mount | ||||||||||||||
} | ||||||||||||||
self._bundled_data: Dict[str, bytes] = bundled_data or {} | ||||||||||||||
|
||||||||||||||
# With the addition of Moveable Trashes and Waste Chute support, it is not necessary | ||||||||||||||
# to ensure that the list of "disposal locations", essentially the list of trashes, | ||||||||||||||
# is initialized correctly on protocols utilizing former API versions prior to 2.16 | ||||||||||||||
# and also to ensure that any protocols after 2.16 intialize a Fixed Trash for OT-2 | ||||||||||||||
# protocols so that no load trash bin behavior is required within the protocol itself. | ||||||||||||||
# Protocols prior to 2.16 expect the Fixed Trash to exist as a Labware object, while | ||||||||||||||
# protocols after 2.16 expect trash to exist as either a TrashBin or WasteChute object. | ||||||||||||||
|
||||||||||||||
self._load_fixed_trash() | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like some trash initialization code already existed in |
||||||||||||||
if should_load_fixed_trash_for_python_protocol(self._api_version): | ||||||||||||||
self._core.append_disposal_location(self.fixed_trash) | ||||||||||||||
elif ( | ||||||||||||||
self._api_version >= APIVersion(2, 16) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I can tell, this I see where this is coming from, but I think we should leave this I would just write this as |
||||||||||||||
and self._core.robot_type == "OT-2 Standard" | ||||||||||||||
): | ||||||||||||||
_fixed_trash_trashbin = TrashBin( | ||||||||||||||
location=DeckSlotName.FIXED_TRASH, addressable_area_name="fixedTrash" | ||||||||||||||
) | ||||||||||||||
self._core.append_disposal_location(_fixed_trash_trashbin) | ||||||||||||||
Comment on lines
+154
to
+163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is showing us that we need to rename or rework I'm not super familiar with that code, but I'm inferring from this usage that it currently works like "should we load a fixed trash labware," not "should we load any form of fixed trash at all." So:
@jbleon95 Any opinions? |
||||||||||||||
|
||||||||||||||
self._commands: List[str] = [] | ||||||||||||||
self._unsubscribe_commands: Optional[Callable[[], None]] = None | ||||||||||||||
|
@@ -861,10 +883,10 @@ def load_instrument( | |||||||||||||
log=logger, | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
trash: Optional[Labware] | ||||||||||||||
trash: Optional[Union[Labware, TrashBin]] | ||||||||||||||
try: | ||||||||||||||
trash = self.fixed_trash | ||||||||||||||
except NoTrashDefinedError: | ||||||||||||||
except (NoTrashDefinedError, APIVersionError): | ||||||||||||||
trash = None | ||||||||||||||
|
||||||||||||||
instrument = InstrumentContext( | ||||||||||||||
|
@@ -1024,17 +1046,33 @@ def deck(self) -> Deck: | |||||||||||||
|
||||||||||||||
@property # type: ignore | ||||||||||||||
@requires_version(2, 0) | ||||||||||||||
def fixed_trash(self) -> Labware: | ||||||||||||||
def fixed_trash(self) -> Union[Labware, TrashBin]: | ||||||||||||||
"""The trash fixed to slot 12 of the robot deck. | ||||||||||||||
|
||||||||||||||
It has one well and should be accessed like labware in your protocol. | ||||||||||||||
In API Versions prior to 2.16 it has one well and should be accessed like labware in your protocol. | ||||||||||||||
e.g. ``protocol.fixed_trash['A1']`` | ||||||||||||||
|
||||||||||||||
In API Version 2.16 and above it returns a Trash fixture for OT-2 Protocols. | ||||||||||||||
""" | ||||||||||||||
if self._api_version >= APIVersion(2, 16): | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This newly added section to should provide handling for the issue Max identified and has tests implemented for. The following behavior is to be expected as a result: |
||||||||||||||
if self._core.robot_type == "OT-3 Standard": | ||||||||||||||
raise APIVersionError( | ||||||||||||||
"Fixed Trash is not supported on Flex protocols in API Version 2.16 and above." | ||||||||||||||
) | ||||||||||||||
Comment on lines
+1059
to
+1061
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's raise
Suggested change
And we'll have to update the |
||||||||||||||
disposal_locations = self._core.get_disposal_locations() | ||||||||||||||
if len(disposal_locations) == 0: | ||||||||||||||
raise NoTrashDefinedError( | ||||||||||||||
"No trash container has been defined in this protocol." | ||||||||||||||
) | ||||||||||||||
if isinstance(disposal_locations[0], TrashBin): | ||||||||||||||
return disposal_locations[0] | ||||||||||||||
|
||||||||||||||
fixed_trash = self._core_map.get(self._core.fixed_trash) | ||||||||||||||
if fixed_trash is None: | ||||||||||||||
raise NoTrashDefinedError( | ||||||||||||||
"No trash container has been defined in this protocol." | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
Comment on lines
+1066
to
+1075
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a bit confusing to me because it looks like we now have two competing ways of keeping track of the fixed trash:
In other words, I think we need to choose between either of these two strategies:
|
||||||||||||||
return fixed_trash | ||||||||||||||
|
||||||||||||||
def _load_fixed_trash(self) -> None: | ||||||||||||||
|
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.
Can this comment be broken up, or shortened, for readability? I'm having trouble parsing it.