-
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
refactor(api,robot-server,app): use labwareURI instead of labwareID for placeLabwareState and unsafe/placeLabware command. #16719
Conversation
…or placeLabwareState and command. The labware_id is randomly generated when the labware is loaded, so it cannot be relied on across runs. This was working for the plate reader lid because the labwareID is fixed, however it would break with other labware
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.
Awesome, thank you!
api/src/opentrons/protocol_engine/commands/unsafe/unsafe_place_labware.py
Outdated
Show resolved
Hide resolved
labwareId: str = Field(..., description="The id of the labware to place.") | ||
labwareURI: str = Field(..., description="Labware URI for labware.") |
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.
loadLabware
splits this out into separate loadName
/namespace
/version
fields, so I might have matched that here for consistency.
Don't feel obligated to do that in this PR, though. If we care, we should be able to change this later because we only use this command in maintenance runs, so there are fewer persistence layer compatibility concerns.
# TODO: We need a way to create temporary labware for moving around, | ||
# the labware should get deleted once its used. | ||
details = details_from_uri(params.labwareURI) | ||
labware = await self._equipment.load_labware( | ||
load_name=details.load_name, | ||
namespace=details.namespace, | ||
version=details.version, | ||
location=location, | ||
labware_id=None, | ||
) | ||
|
||
self._state_view.labware._state.definitions_by_uri[ | ||
params.labwareURI | ||
] = labware.definition | ||
self._state_view.labware._state.labware_by_id[ | ||
labware.labware_id | ||
] = LoadedLabware.construct( | ||
id=labware.labware_id, | ||
location=location, | ||
loadName=labware.definition.parameters.loadName, | ||
definitionUri=params.labwareURI, | ||
offsetId=labware.offsetId, | ||
) |
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.
For the benefit of other reviewers, and to answer your review question:
Modifying self._state_view.labware._state
directly from a command implementation like this is, in most cases, not acceptable, as you called out. But we're going to replace this code imminently as part of RQA-3471, so this code makes sense to bridge the gap until then. I wouldn't sweat it, if it works.
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.
Agree with that point, this is a temporary patch for the existing architecture which will be replaced with the changes Max mentioned.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## chore_release-8.2.0 #16719 +/- ##
======================================================
Coverage ? 79.32%
======================================================
Files ? 120
Lines ? 4459
Branches ? 0
======================================================
Hits ? 3537
Misses ? 922
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. |
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.
Implementation looks solid overall, thanks for jumping on this one Brayan. A note below regarding some of the hard-coded approach being used down on the router end of things.
# TODO: We need a way to create temporary labware for moving around, | ||
# the labware should get deleted once its used. | ||
details = details_from_uri(params.labwareURI) | ||
labware = await self._equipment.load_labware( | ||
load_name=details.load_name, | ||
namespace=details.namespace, | ||
version=details.version, | ||
location=location, | ||
labware_id=None, | ||
) | ||
|
||
self._state_view.labware._state.definitions_by_uri[ | ||
params.labwareURI | ||
] = labware.definition | ||
self._state_view.labware._state.labware_by_id[ | ||
labware.labware_id | ||
] = LoadedLabware.construct( | ||
id=labware.labware_id, | ||
location=location, | ||
loadName=labware.definition.parameters.loadName, | ||
definitionUri=params.labwareURI, | ||
offsetId=labware.offsetId, | ||
) |
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.
Agree with that point, this is a temporary patch for the existing architecture which will be replaced with the changes Max mentioned.
Overview
The
placeLabwareState
andunsafe/placeLabware
commands rely on thelabwareID
to place labware held by the gripper back down to a deck slot. However, as correctly pointed out, this is wrong because the labwareID changes across runs. This was working for the plate reader lid because the lid is loaded with a fixed labwareID, however that would not be the case for other labware across different runs. This pull request replaces the labwareID with labwareURI used by theplaceLabwareState
andunsafe/placeLabware
commands so the behavior is consistent across runs.Closes: PLAT-580
Test Plan and Hands on Testing
open/close_lid
commands still workplaceLabware
when the estop is pressedChangelog
labwareURI
instead oflabwareID
in theplaceLabwareState
object sent in the/runs/{runID}/currentState
endpointlabwareURI
instead oflabwareID
in theunsafe/placeLabware
commandlabwareURI
in theunsafe/placeLabware
command, load the labware directlylabwareURI
instead oflabwareID
in theusePlacePlateReaderLid.ts
react hookReview requests
Risk assessment
low, unreleased