Skip to content
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

refactor(api): Port TipState's nozzle layout to StateUpdate #16479

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions api/src/opentrons/protocol_engine/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@
ConfigureNozzleLayoutCreate,
ConfigureNozzleLayoutParams,
ConfigureNozzleLayoutResult,
ConfigureNozzleLayoutPrivateResult,
ConfigureNozzleLayoutCommandType,
)

Expand Down Expand Up @@ -569,7 +568,6 @@
"ConfigureNozzleLayoutParams",
"ConfigureNozzleLayoutResult",
"ConfigureNozzleLayoutCommandType",
"ConfigureNozzleLayoutPrivateResult",
# get pipette tip presence bundle
"GetTipPresence",
"GetTipPresenceCreate",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@
ConfigureNozzleLayoutParams,
ConfigureNozzleLayoutResult,
ConfigureNozzleLayoutCommandType,
ConfigureNozzleLayoutPrivateResult,
)

from .verify_tip_presence import (
Expand Down Expand Up @@ -709,7 +708,6 @@
None,
LoadPipettePrivateResult,
ConfigureForVolumePrivateResult,
ConfigureNozzleLayoutPrivateResult,
]

# All `DefinedErrorData`s that implementations will actually return in practice.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
)
from .command import AbstractCommandImpl, BaseCommand, BaseCommandCreate, SuccessData
from ..errors.error_occurrence import ErrorOccurrence
from .configuring_common import (
PipetteNozzleLayoutResultMixin,
)
from ..types import (
AllNozzleLayoutConfiguration,
SingleNozzleLayoutConfiguration,
Expand Down Expand Up @@ -40,12 +37,6 @@ class ConfigureNozzleLayoutParams(PipetteIdMixin):
]


class ConfigureNozzleLayoutPrivateResult(PipetteNozzleLayoutResultMixin):
"""Result sent to the store but not serialized."""

pass


class ConfigureNozzleLayoutResult(BaseModel):
"""Result data from execution of an configureNozzleLayout command."""

Expand All @@ -55,7 +46,7 @@ class ConfigureNozzleLayoutResult(BaseModel):
class ConfigureNozzleLayoutImplementation(
AbstractCommandImpl[
ConfigureNozzleLayoutParams,
SuccessData[ConfigureNozzleLayoutResult, ConfigureNozzleLayoutPrivateResult],
SuccessData[ConfigureNozzleLayoutResult, None],
]
):
"""Configure nozzle layout command implementation."""
Expand All @@ -68,7 +59,7 @@ def __init__(

async def execute(
self, params: ConfigureNozzleLayoutParams
) -> SuccessData[ConfigureNozzleLayoutResult, ConfigureNozzleLayoutPrivateResult]:
) -> SuccessData[ConfigureNozzleLayoutResult, None]:
"""Check that requested pipette can support the requested nozzle layout."""
primary_nozzle = params.configurationParams.dict().get("primaryNozzle")
front_right_nozzle = params.configurationParams.dict().get("frontRightNozzle")
Expand All @@ -93,10 +84,7 @@ async def execute(

return SuccessData(
public=ConfigureNozzleLayoutResult(),
private=ConfigureNozzleLayoutPrivateResult(
pipette_id=params.pipetteId,
nozzle_map=nozzle_map,
),
private=None,
state_update=update_state,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"""Common configuration command base models."""

from dataclasses import dataclass
from opentrons.hardware_control.nozzle_manager import (
NozzleMap,
)
from ..resources import pipette_data_provider


Expand All @@ -14,13 +11,3 @@ class PipetteConfigUpdateResultMixin:
pipette_id: str
serial_number: str
config: pipette_data_provider.LoadedStaticPipetteData


@dataclass
class PipetteNozzleLayoutResultMixin:
"""A nozzle layout result for updating the pipette state."""

pipette_id: str

nozzle_map: NozzleMap
"""A dataclass object holding information about the current nozzle configuration."""
21 changes: 10 additions & 11 deletions api/src/opentrons/protocol_engine/state/tips.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
Command,
LoadLabwareResult,
)
from ..commands.configuring_common import (
PipetteConfigUpdateResultMixin,
PipetteNozzleLayoutResultMixin,
)
from ..commands.configuring_common import PipetteConfigUpdateResultMixin

from opentrons.hardware_control.nozzle_manager import NozzleMap

Expand Down Expand Up @@ -82,13 +79,6 @@ def handle_action(self, action: Action) -> None:

self._handle_succeeded_command(action.command)

if isinstance(action.private_result, PipetteNozzleLayoutResultMixin):
pipette_id = action.private_result.pipette_id
nozzle_map = action.private_result.nozzle_map
pipette_info = self._state.pipette_info_by_pipette_id[pipette_id]
pipette_info.active_channels = nozzle_map.tip_count
pipette_info.nozzle_map = nozzle_map

elif isinstance(action, ResetTipsAction):
labware_id = action.labware_id

Expand Down Expand Up @@ -121,6 +111,15 @@ def _handle_state_update(self, state_update: update_types.StateUpdate) -> None:
well_name=state_update.tips_used.well_name,
)

if state_update.pipette_nozzle_map != update_types.NO_CHANGE:
pipette_info = self._state.pipette_info_by_pipette_id[
state_update.pipette_nozzle_map.pipette_id
]
pipette_info.active_channels = (
state_update.pipette_nozzle_map.nozzle_map.tip_count
)
pipette_info.nozzle_map = state_update.pipette_nozzle_map.nozzle_map

def _set_used_tips( # noqa: C901
self, pipette_id: str, well_name: str, labware_id: str
) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from opentrons.protocol_engine.commands.configure_nozzle_layout import (
ConfigureNozzleLayoutParams,
ConfigureNozzleLayoutResult,
ConfigureNozzleLayoutPrivateResult,
ConfigureNozzleLayoutImplementation,
)

Expand Down Expand Up @@ -146,10 +145,7 @@ async def test_configure_nozzle_layout_implementation(

assert result == SuccessData(
public=ConfigureNozzleLayoutResult(),
private=ConfigureNozzleLayoutPrivateResult(
pipette_id="pipette-id",
nozzle_map=expected_nozzlemap,
),
private=None,
state_update=StateUpdate(
pipette_nozzle_map=PipetteNozzleMapUpdate(
pipette_id="pipette-id",
Expand Down
Loading
Loading