-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): add a reload-labware command (#14963)
Adds a new command ReloadLabware, which allows dispatchers to change all the details of a loaded labware except for the location. This is primarily intended to allow getting a new labware offset that was not added to the engine by the time this labware was loaded (though it can technically do more, for symmetry). This doesn't really change a whole lot of behavior and is well-supported with testing. It's a prerequisite for #14940 Closes RSQ-29
- Loading branch information
1 parent
16b4d53
commit e77347b
Showing
12 changed files
with
405 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
api/src/opentrons/protocol_engine/commands/reload_labware.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
"""Reload labware command request, result, and implementation models.""" | ||
from __future__ import annotations | ||
from pydantic import BaseModel, Field | ||
from typing import TYPE_CHECKING, Optional, Type | ||
from typing_extensions import Literal | ||
|
||
from .command import AbstractCommandImpl, BaseCommand, BaseCommandCreate | ||
|
||
if TYPE_CHECKING: | ||
from ..state import StateView | ||
from ..execution import EquipmentHandler | ||
|
||
|
||
ReloadLabwareCommandType = Literal["reloadLabware"] | ||
|
||
|
||
class ReloadLabwareParams(BaseModel): | ||
"""Payload required to load a labware into a slot.""" | ||
|
||
labwareId: str = Field( | ||
..., description="The already-loaded labware instance to update." | ||
) | ||
|
||
|
||
class ReloadLabwareResult(BaseModel): | ||
"""Result data from the execution of a LoadLabware command.""" | ||
|
||
labwareId: str = Field( | ||
..., | ||
description="An ID to reference this labware in subsequent commands. Same as the one in the parameters.", | ||
) | ||
offsetId: Optional[str] = Field( | ||
# Default `None` instead of `...` so this field shows up as non-required in | ||
# OpenAPI. The server is allowed to omit it or make it null. | ||
None, | ||
description=( | ||
"An ID referencing the labware offset that will apply" | ||
" to the reloaded labware." | ||
" This offset will be in effect until the labware is moved" | ||
" with a `moveLabware` command." | ||
" Null or undefined means no offset applies," | ||
" so the default of (0, 0, 0) will be used." | ||
), | ||
) | ||
|
||
|
||
class ReloadLabwareImplementation( | ||
AbstractCommandImpl[ReloadLabwareParams, ReloadLabwareResult] | ||
): | ||
"""Reload labware command implementation.""" | ||
|
||
def __init__( | ||
self, equipment: EquipmentHandler, state_view: StateView, **kwargs: object | ||
) -> None: | ||
self._equipment = equipment | ||
self._state_view = state_view | ||
|
||
async def execute(self, params: ReloadLabwareParams) -> ReloadLabwareResult: | ||
"""Reload the definition and calibration data for a specific labware.""" | ||
reloaded_labware = await self._equipment.reload_labware( | ||
labware_id=params.labwareId, | ||
) | ||
|
||
return ReloadLabwareResult( | ||
labwareId=params.labwareId, | ||
offsetId=reloaded_labware.offsetId, | ||
) | ||
|
||
|
||
class ReloadLabware(BaseCommand[ReloadLabwareParams, ReloadLabwareResult]): | ||
"""Reload labware command resource model.""" | ||
|
||
commandType: ReloadLabwareCommandType = "reloadLabware" | ||
params: ReloadLabwareParams | ||
result: Optional[ReloadLabwareResult] | ||
|
||
_ImplementationCls: Type[ReloadLabwareImplementation] = ReloadLabwareImplementation | ||
|
||
|
||
class ReloadLabwareCreate(BaseCommandCreate[ReloadLabwareParams]): | ||
"""Reload labware command creation request.""" | ||
|
||
commandType: ReloadLabwareCommandType = "reloadLabware" | ||
params: ReloadLabwareParams | ||
|
||
_CommandCls: Type[ReloadLabware] = ReloadLabware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.