-
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
feat(api): add stacker module context and protocol command skeletons #17206
Open
ahiuchingau
wants to merge
22
commits into
edge
Choose a base branch
from
EXEC-1079-module-context
base: edge
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
b9f150c
create module live data typed dict i guess
ahiuchingau 5d94f16
create live data validator to narrow down type for each module
ahiuchingau 281fb67
fix types in robot-server and tests
ahiuchingau 79fa673
Merge branch 'edge' into module_live-data
ahiuchingau 70a3461
fix some linter errors
ahiuchingau 5d65076
add flex stacker data as rebase
ahiuchingau b0350c1
update command snapshots
ahiuchingau c839e76
add flex stacker module context and core
ahiuchingau d151673
add module core functions
ahiuchingau 1d64f1e
add flex stacker protocol engine command skeletons
ahiuchingau 3536b06
add module substate
ahiuchingau 6fbe621
add stacker module type to protocol engine
ahiuchingau a27ace9
fix failed tests in protocol engine
ahiuchingau fda927e
consolidate test_load_module cases and test all ot3 modules
ahiuchingau 982ed1b
fix linter error
ahiuchingau aef78d7
too complex
ahiuchingau 5d9c591
fix rebase errors
ahiuchingau 83cb45f
update flexstacker model name to match edge
ahiuchingau 1fe24dd
add substate update for flex stacker
ahiuchingau 6ae32b1
update addressable area name
ahiuchingau de23921
Merge branch 'edge' into EXEC-1079-module-context
ahiuchingau d35f9eb
update modele core to execute protocol engine command
ahiuchingau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", | ||
] |
76 changes: 76 additions & 0 deletions
76
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,76 @@ | ||
"""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: | ||
await stacker.dispense() | ||
|
||
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 |
77 changes: 77 additions & 0 deletions
77
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,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 | ||
|
||
|
||
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: | ||
await stacker.store() | ||
|
||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This
modules.ModuleDisconnectedCallback
type got removed as the type has not been mported to this file, and hence, will not affect the rest of the code