-
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 prepare to aspirate to PAPI and engine (#13827)
Add the ability to explicitly call prepare_to_aspirate() to the python protocol API and the json protocol command schema. We make sure the pipette is prepared to aspirate before any aspiration, which is good, but the way we make this absolute is that if the pipette isn't ready for aspirate when you call aspirate(), we move it to the top of the current well (if necessary) to move the plunger up. This is a problem for users who are, for instance, building explicit prewetting behavior out of protocol API calls. It's common to move the pipette into the liquid and then delay to let the liquid settle before pipetting; if the pipette then moves up to prepare for aspirate before coming back down, that settling is undone. By adding the ability to explicitly prepare_for_aspirate(), the user can call it while they know the pipette is above the well. --------- Co-authored-by: Edward Cormany <[email protected]> Co-authored-by: Max Marrone <[email protected]>
- Loading branch information
1 parent
5dc8819
commit f8c53e8
Showing
17 changed files
with
340 additions
and
10 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
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
73 changes: 73 additions & 0 deletions
73
api/src/opentrons/protocol_engine/commands/prepare_to_aspirate.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,73 @@ | ||
"""Prepare to aspirate command request, result, and implementation models.""" | ||
|
||
from __future__ import annotations | ||
from pydantic import BaseModel | ||
from typing import TYPE_CHECKING, Optional, Type | ||
from typing_extensions import Literal | ||
|
||
from .pipetting_common import ( | ||
PipetteIdMixin, | ||
) | ||
from .command import ( | ||
AbstractCommandImpl, | ||
BaseCommand, | ||
BaseCommandCreate, | ||
) | ||
|
||
if TYPE_CHECKING: | ||
from ..execution.pipetting import PipettingHandler | ||
|
||
PrepareToAspirateCommandType = Literal["prepareToAspirate"] | ||
|
||
|
||
class PrepareToAspirateParams(PipetteIdMixin): | ||
"""Parameters required to prepare a specific pipette for aspiration.""" | ||
|
||
pass | ||
|
||
|
||
class PrepareToAspirateResult(BaseModel): | ||
"""Result data from execution of an PrepareToAspirate command.""" | ||
|
||
pass | ||
|
||
|
||
class PrepareToAspirateImplementation( | ||
AbstractCommandImpl[ | ||
PrepareToAspirateParams, | ||
PrepareToAspirateResult, | ||
] | ||
): | ||
"""Prepare for aspirate command implementation.""" | ||
|
||
def __init__(self, pipetting: PipettingHandler, **kwargs: object) -> None: | ||
self._pipetting_handler = pipetting | ||
|
||
async def execute(self, params: PrepareToAspirateParams) -> PrepareToAspirateResult: | ||
"""Prepare the pipette to aspirate.""" | ||
await self._pipetting_handler.prepare_for_aspirate( | ||
pipette_id=params.pipetteId, | ||
) | ||
|
||
return PrepareToAspirateResult() | ||
|
||
|
||
class PrepareToAspirate(BaseCommand[PrepareToAspirateParams, PrepareToAspirateResult]): | ||
"""Prepare for aspirate command model.""" | ||
|
||
commandType: PrepareToAspirateCommandType = "prepareToAspirate" | ||
params: PrepareToAspirateParams | ||
result: Optional[PrepareToAspirateResult] | ||
|
||
_ImplementationCls: Type[ | ||
PrepareToAspirateImplementation | ||
] = PrepareToAspirateImplementation | ||
|
||
|
||
class PrepareToAspirateCreate(BaseCommandCreate[PrepareToAspirateParams]): | ||
"""Prepare for aspirate command creation request model.""" | ||
|
||
commandType: PrepareToAspirateCommandType = "prepareToAspirate" | ||
params: PrepareToAspirateParams | ||
|
||
_CommandCls: Type[PrepareToAspirate] = PrepareToAspirate |
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
29 changes: 29 additions & 0 deletions
29
api/tests/opentrons/protocol_engine/commands/test_prepare_to_aspirate.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,29 @@ | ||
"""Test prepare to aspirate commands.""" | ||
|
||
from decoy import Decoy | ||
|
||
from opentrons.protocol_engine.execution import ( | ||
PipettingHandler, | ||
) | ||
|
||
from opentrons.protocol_engine.commands.prepare_to_aspirate import ( | ||
PrepareToAspirateParams, | ||
PrepareToAspirateImplementation, | ||
PrepareToAspirateResult, | ||
) | ||
|
||
|
||
async def test_prepare_to_aspirate_implmenetation( | ||
decoy: Decoy, pipetting: PipettingHandler | ||
) -> None: | ||
"""A PrepareToAspirate command should have an executing implementation.""" | ||
subject = PrepareToAspirateImplementation(pipetting=pipetting) | ||
|
||
data = PrepareToAspirateParams(pipetteId="some id") | ||
|
||
decoy.when(await pipetting.prepare_for_aspirate(pipette_id="some id")).then_return( | ||
None | ||
) | ||
|
||
result = await subject.execute(data) | ||
assert isinstance(result, PrepareToAspirateResult) |
Oops, something went wrong.