-
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): JSON protocol pipette loading support in Protocol Engine #7766
Changes from 2 commits
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
"""Load pipette command request, result, and implementation models.""" | ||
from __future__ import annotations | ||
|
||
from typing import Optional | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
from opentrons.types import MountType | ||
|
@@ -19,6 +22,11 @@ class LoadPipetteRequest(BaseModel): | |
..., | ||
description="The mount the pipette should be present on.", | ||
) | ||
pipetteId: Optional[str] = Field( | ||
..., | ||
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. Same question I think you posted in the labware PR, but should we default this to 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. Yes. |
||
description="An optional ID to assign to this pipette. If None, an ID " | ||
"will be generated." | ||
) | ||
|
||
def get_implementation(self) -> LoadPipetteImplementation: | ||
"""Get the load pipette request's command implementation.""" | ||
|
@@ -44,6 +52,7 @@ async def execute(self, handlers: CommandHandlers) -> LoadPipetteResult: | |
loaded_pipette = await handlers.equipment.load_pipette( | ||
pipette_name=self._request.pipetteName, | ||
mount=self._request.mount, | ||
pipette_id=self._request.pipetteId | ||
) | ||
|
||
return LoadPipetteResult(pipetteId=loaded_pipette.pipette_id) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
"""Equipment command side-effect logic.""" | ||
from dataclasses import dataclass | ||
from typing import Tuple | ||
from typing import Tuple, Optional | ||
|
||
from opentrons_shared_data.labware.dev_types import LabwareDefinition | ||
from opentrons.types import MountType | ||
|
@@ -77,8 +77,19 @@ async def load_pipette( | |
self, | ||
pipette_name: PipetteName, | ||
mount: MountType, | ||
pipette_id: Optional[str], | ||
) -> LoadedPipette: | ||
"""Ensure the requested pipette is attached.""" | ||
"""Ensure the requested pipette is attached. | ||
|
||
Args: | ||
pipette_name: The pipette name. | ||
mount: The mount on which pipette must be attached. | ||
pipette_id: An optional identifier to assign the pipette. If None, an | ||
identifier will be generated. | ||
|
||
Returns: | ||
A LoadedPipette object. | ||
""" | ||
other_mount = mount.other_mount() | ||
other_pipette = self._state.pipettes.get_pipette_data_by_mount( | ||
other_mount, | ||
|
@@ -97,6 +108,7 @@ async def load_pipette( | |
except RuntimeError as e: | ||
raise FailedToLoadPipetteError(str(e)) from e | ||
|
||
pipette_id = self._resources.id_generator.generate_id() | ||
pipette_id = pipette_id if pipette_id else \ | ||
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. Should we be pedantic about checking |
||
self._resources.id_generator.generate_id() | ||
|
||
return LoadedPipette(pipette_id=pipette_id) |
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.
Will this ever be needed in this client? I'd be down to leave it out (or default it to
None
if that feels better)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.
Good point. I'll remove it.