-
Notifications
You must be signed in to change notification settings - Fork 179
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 stacker module context and protocol command skeletons (#…
…17206) This PR adds flex stacker support skeleton in the protocol engine. With the changes in this PR, you can load a flex stacker into your protocol.
- Loading branch information
1 parent
4d6dfc8
commit cec46ef
Showing
27 changed files
with
626 additions
and
192 deletions.
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
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
33 changes: 33 additions & 0 deletions
33
api/src/opentrons/protocol_engine/commands/flex_stacker/__init__.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,33 @@ | ||
"""Command models for Flex Stacker commands.""" | ||
|
||
from .store import ( | ||
StoreCommandType, | ||
StoreParams, | ||
StoreResult, | ||
Store, | ||
StoreCreate, | ||
) | ||
|
||
from .retrieve import ( | ||
RetrieveCommandType, | ||
RetrieveParams, | ||
RetrieveResult, | ||
Retrieve, | ||
RetrieveCreate, | ||
) | ||
|
||
|
||
__all__ = [ | ||
# flexStacker/store | ||
"StoreCommandType", | ||
"StoreParams", | ||
"StoreResult", | ||
"Store", | ||
"StoreCreate", | ||
# flexStacker/retrieve | ||
"RetrieveCommandType", | ||
"RetrieveParams", | ||
"RetrieveResult", | ||
"Retrieve", | ||
"RetrieveCreate", | ||
] |
77 changes: 77 additions & 0 deletions
77
api/src/opentrons/protocol_engine/commands/flex_stacker/retrieve.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,77 @@ | ||
"""Command models to retrieve a labware from a Flex Stacker.""" | ||
from __future__ import annotations | ||
from typing import Optional, Literal, TYPE_CHECKING | ||
from typing_extensions import Type | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
from ..command import AbstractCommandImpl, BaseCommand, BaseCommandCreate, SuccessData | ||
from ...errors.error_occurrence import ErrorOccurrence | ||
from ...state import update_types | ||
|
||
if TYPE_CHECKING: | ||
from opentrons.protocol_engine.state.state import StateView | ||
from opentrons.protocol_engine.execution import EquipmentHandler | ||
|
||
RetrieveCommandType = Literal["flexStacker/retrieve"] | ||
|
||
|
||
class RetrieveParams(BaseModel): | ||
"""Input parameters for a labware retrieval command.""" | ||
|
||
moduleId: str = Field( | ||
..., | ||
description="Unique ID of the Flex Stacker.", | ||
) | ||
|
||
|
||
class RetrieveResult(BaseModel): | ||
"""Result data from a labware retrieval command.""" | ||
|
||
|
||
class RetrieveImpl(AbstractCommandImpl[RetrieveParams, SuccessData[RetrieveResult]]): | ||
"""Implementation of a labware retrieval command.""" | ||
|
||
def __init__( | ||
self, | ||
state_view: StateView, | ||
equipment: EquipmentHandler, | ||
**kwargs: object, | ||
) -> None: | ||
self._state_view = state_view | ||
self._equipment = equipment | ||
|
||
async def execute(self, params: RetrieveParams) -> SuccessData[RetrieveResult]: | ||
"""Execute the labware retrieval command.""" | ||
state_update = update_types.StateUpdate() | ||
stacker_substate = self._state_view.modules.get_flex_stacker_substate( | ||
module_id=params.moduleId | ||
) | ||
|
||
# Allow propagation of ModuleNotAttachedError. | ||
stacker = self._equipment.get_module_hardware_api(stacker_substate.module_id) | ||
|
||
if stacker is not None: | ||
# TODO: get labware height from labware state view | ||
await stacker.dispense_labware(labware_height=50.0) | ||
|
||
return SuccessData(public=RetrieveResult(), state_update=state_update) | ||
|
||
|
||
class Retrieve(BaseCommand[RetrieveParams, RetrieveResult, ErrorOccurrence]): | ||
"""A command to retrieve a labware from a Flex Stacker.""" | ||
|
||
commandType: RetrieveCommandType = "flexStacker/retrieve" | ||
params: RetrieveParams | ||
result: Optional[RetrieveResult] | ||
|
||
_ImplementationCls: Type[RetrieveImpl] = RetrieveImpl | ||
|
||
|
||
class RetrieveCreate(BaseCommandCreate[RetrieveParams]): | ||
"""A request to execute a Flex Stacker retrieve command.""" | ||
|
||
commandType: RetrieveCommandType = "flexStacker/retrieve" | ||
params: RetrieveParams | ||
|
||
_CommandCls: Type[Retrieve] = Retrieve |
78 changes: 78 additions & 0 deletions
78
api/src/opentrons/protocol_engine/commands/flex_stacker/store.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,78 @@ | ||
"""Command models to retrieve a labware from a Flex Stacker.""" | ||
from __future__ import annotations | ||
from typing import Optional, Literal, TYPE_CHECKING | ||
from typing_extensions import Type | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
from ..command import AbstractCommandImpl, BaseCommand, BaseCommandCreate, SuccessData | ||
from ...errors.error_occurrence import ErrorOccurrence | ||
from ...state import update_types | ||
|
||
if TYPE_CHECKING: | ||
from opentrons.protocol_engine.state.state import StateView | ||
from opentrons.protocol_engine.execution import EquipmentHandler | ||
|
||
|
||
StoreCommandType = Literal["flexStacker/store"] | ||
|
||
|
||
class StoreParams(BaseModel): | ||
"""Input parameters for a labware storage command.""" | ||
|
||
moduleId: str = Field( | ||
..., | ||
description="Unique ID of the flex stacker.", | ||
) | ||
|
||
|
||
class StoreResult(BaseModel): | ||
"""Result data from a labware storage command.""" | ||
|
||
|
||
class StoreImpl(AbstractCommandImpl[StoreParams, SuccessData[StoreResult]]): | ||
"""Implementation of a labware storage command.""" | ||
|
||
def __init__( | ||
self, | ||
state_view: StateView, | ||
equipment: EquipmentHandler, | ||
**kwargs: object, | ||
) -> None: | ||
self._state_view = state_view | ||
self._equipment = equipment | ||
|
||
async def execute(self, params: StoreParams) -> SuccessData[StoreResult]: | ||
"""Execute the labware storage command.""" | ||
state_update = update_types.StateUpdate() | ||
stacker_substate = self._state_view.modules.get_flex_stacker_substate( | ||
module_id=params.moduleId | ||
) | ||
|
||
# Allow propagation of ModuleNotAttachedError. | ||
stacker = self._equipment.get_module_hardware_api(stacker_substate.module_id) | ||
|
||
if stacker is not None: | ||
# TODO: get labware height from labware state view | ||
await stacker.store_labware(labware_height=50.0) | ||
|
||
return SuccessData(public=StoreResult(), state_update=state_update) | ||
|
||
|
||
class Store(BaseCommand[StoreParams, StoreResult, ErrorOccurrence]): | ||
"""A command to store a labware in a Flex Stacker.""" | ||
|
||
commandType: StoreCommandType = "flexStacker/store" | ||
params: StoreParams | ||
result: Optional[StoreResult] | ||
|
||
_ImplementationCls: Type[StoreImpl] = StoreImpl | ||
|
||
|
||
class StoreCreate(BaseCommandCreate[StoreParams]): | ||
"""A request to execute a Flex Stacker store command.""" | ||
|
||
commandType: StoreCommandType = "flexStacker/store" | ||
params: StoreParams | ||
|
||
_CommandCls: Type[Store] = Store |
Oops, something went wrong.