-
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
refactor(api,robot-server,app): use labwareURI instead of labwareID for placeLabwareState and unsafe/placeLabware command. #16719
Changes from all commits
757072b
56826e3
772ee30
1b9f976
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
from typing import TYPE_CHECKING, Optional, Type | ||
from typing_extensions import Literal | ||
|
||
from opentrons.calibration_storage.helpers import details_from_uri | ||
from opentrons.hardware_control.types import Axis, OT3Mount | ||
from opentrons.motion_planning.waypoints import get_gripper_labware_placement_waypoints | ||
from opentrons.protocol_engine.errors.exceptions import ( | ||
|
@@ -13,7 +14,12 @@ | |
) | ||
from opentrons.types import Point | ||
|
||
from ...types import DeckSlotLocation, ModuleModel, OnDeckLabwareLocation | ||
from ...types import ( | ||
DeckSlotLocation, | ||
LoadedLabware, | ||
ModuleModel, | ||
OnDeckLabwareLocation, | ||
) | ||
from ..command import AbstractCommandImpl, BaseCommand, BaseCommandCreate, SuccessData | ||
from ...errors.error_occurrence import ErrorOccurrence | ||
from ...resources import ensure_ot3_hardware | ||
|
@@ -32,7 +38,7 @@ | |
class UnsafePlaceLabwareParams(BaseModel): | ||
"""Payload required for an UnsafePlaceLabware command.""" | ||
|
||
labwareId: str = Field(..., description="The id of the labware to place.") | ||
labwareURI: str = Field(..., description="Labware URI for labware.") | ||
location: OnDeckLabwareLocation = Field( | ||
..., description="Where to place the labware." | ||
) | ||
|
@@ -71,8 +77,8 @@ async def execute( | |
is pressed, get into error recovery, etc). | ||
|
||
Unlike the `moveLabware` command, where you pick a source and destination | ||
location, this command takes the labwareId to be moved and location to | ||
move it to. | ||
location, this command takes the labwareURI of the labware to be moved | ||
and location to move it to. | ||
|
||
""" | ||
ot3api = ensure_ot3_hardware(self._hardware_api) | ||
|
@@ -84,10 +90,35 @@ async def execute( | |
"Cannot place labware when gripper is not gripping." | ||
) | ||
|
||
labware_id = params.labwareId | ||
# Allow propagation of LabwareNotLoadedError. | ||
definition_uri = self._state_view.labware.get(labware_id).definitionUri | ||
location = self._state_view.geometry.ensure_valid_gripper_location( | ||
params.location, | ||
) | ||
|
||
# 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, | ||
) | ||
Comment on lines
+97
to
+119
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. For the benefit of other reviewers, and to answer your review question: Modifying 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. Agree with that point, this is a temporary patch for the existing architecture which will be replaced with the changes Max mentioned. |
||
|
||
labware_id = labware.labware_id | ||
# todo(mm, 2024-11-06): This is only correct in the special case of an | ||
# absorbance reader lid. Its definition currently puts the offsets for *itself* | ||
# in the property that's normally meant for offsets for its *children.* | ||
|
@@ -109,10 +140,6 @@ async def execute( | |
params.location.slotName.id | ||
) | ||
|
||
location = self._state_view.geometry.ensure_valid_gripper_location( | ||
params.location, | ||
) | ||
|
||
# This is an absorbance reader, move the lid to its dock (staging area). | ||
if isinstance(location, DeckSlotLocation): | ||
module = self._state_view.modules.get_by_slot(location.slotName) | ||
|
@@ -122,7 +149,7 @@ async def execute( | |
) | ||
|
||
new_offset_id = self._equipment.find_applicable_labware_offset_id( | ||
labware_definition_uri=definition_uri, | ||
labware_definition_uri=params.labwareURI, | ||
labware_location=location, | ||
) | ||
|
||
|
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 separateloadName
/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.