Skip to content

Commit

Permalink
feature(api): Put command implementations in charge of PipetteStore
Browse files Browse the repository at this point in the history
… updates for tip state and pipette config (#16365)

# Overview

closes [EXEC-733](https://opentrons.atlassian.net/browse/EXEC-733)
update pipette store from command implementation for:
LoadPipetteResult
DropTipResult,               
DropTipInPlaceResult, 
unsafe.UnsafeDropTipInPlaceResult,
PickUpTipResult
PipetteNozzleLayoutResultMixin
PipetteConfigUpdateResultMixin for:

## Test Plan and Hands on Testing

upload a protocol with the following commands/side effects and make sure
its acting as expected.

## Review requests

did I miss anything?

## Risk assessment

Medium. need to smoke test to make sure nothing is affected. 


[EXEC-733]:
https://opentrons.atlassian.net/browse/EXEC-733?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
  • Loading branch information
TamarZanzouri authored Sep 27, 2024
1 parent 02458b0 commit f8a02aa
Show file tree
Hide file tree
Showing 19 changed files with 584 additions and 161 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .command import AbstractCommandImpl, BaseCommand, BaseCommandCreate, SuccessData
from ..errors.error_occurrence import ErrorOccurrence
from .configuring_common import PipetteConfigUpdateResultMixin
from ..state.update_types import StateUpdate

if TYPE_CHECKING:
from ..execution import EquipmentHandler
Expand Down Expand Up @@ -67,13 +68,21 @@ async def execute(
tip_overlap_version=params.tipOverlapNotAfterVersion,
)

state_update = StateUpdate()
state_update.update_pipette_config(
pipette_id=pipette_result.pipette_id,
config=pipette_result.static_config,
serial_number=pipette_result.serial_number,
)

return SuccessData(
public=ConfigureForVolumeResult(),
private=ConfigureForVolumePrivateResult(
pipette_id=pipette_result.pipette_id,
serial_number=pipette_result.serial_number,
config=pipette_result.static_config,
),
state_update=state_update,
)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Configure nozzle layout command request, result, and implementation models."""
from __future__ import annotations
from opentrons.protocol_engine.state.update_types import StateUpdate
from pydantic import BaseModel
from typing import TYPE_CHECKING, Optional, Type, Union
from typing_extensions import Literal
Expand Down Expand Up @@ -85,12 +86,18 @@ async def execute(
**nozzle_params,
)

update_state = StateUpdate()
update_state.update_pipette_nozzle(
pipette_id=params.pipetteId, nozzle_map=nozzle_map
)

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


Expand Down
2 changes: 2 additions & 0 deletions api/src/opentrons/protocol_engine/commands/drop_tip.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ async def execute(self, params: DropTipParams) -> SuccessData[DropTipResult, Non

await self._tip_handler.drop_tip(pipette_id=pipette_id, home_after=home_after)

state_update.update_tip_state(pipette_id=params.pipetteId, tip_geometry=None)

return SuccessData(
public=DropTipResult(position=deck_point),
private=None,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Drop tip in place command request, result, and implementation models."""
from __future__ import annotations
from opentrons.protocol_engine.state import update_types
from pydantic import Field, BaseModel
from typing import TYPE_CHECKING, Optional, Type
from typing_extensions import Literal
Expand Down Expand Up @@ -54,7 +55,13 @@ async def execute(
pipette_id=params.pipetteId, home_after=params.homeAfter
)

return SuccessData(public=DropTipInPlaceResult(), private=None)
state_update = update_types.StateUpdate()

state_update.update_tip_state(pipette_id=params.pipetteId, tip_geometry=None)

return SuccessData(
public=DropTipInPlaceResult(), private=None, state_update=state_update
)


class DropTipInPlace(
Expand Down
15 changes: 15 additions & 0 deletions api/src/opentrons/protocol_engine/commands/load_pipette.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Load pipette command request, result, and implementation models."""
from __future__ import annotations

from opentrons.protocol_engine.state.update_types import StateUpdate
from opentrons_shared_data.pipette.pipette_load_name_conversions import (
convert_to_pipette_name_type,
)
Expand Down Expand Up @@ -123,13 +124,27 @@ async def execute(
tip_overlap_version=params.tipOverlapNotAfterVersion,
)

state_update = StateUpdate()
state_update.set_load_pipette(
pipette_id=loaded_pipette.pipette_id,
pipette_name=params.pipetteName,
mount=params.mount,
liquid_presence_detection=params.liquidPresenceDetection,
)
state_update.update_pipette_config(
pipette_id=loaded_pipette.pipette_id,
serial_number=loaded_pipette.serial_number,
config=loaded_pipette.static_config,
)

return SuccessData(
public=LoadPipetteResult(pipetteId=loaded_pipette.pipette_id),
private=LoadPipettePrivateResult(
pipette_id=loaded_pipette.pipette_id,
serial_number=loaded_pipette.serial_number,
config=loaded_pipette.static_config,
),
state_update=state_update,
)


Expand Down
10 changes: 9 additions & 1 deletion api/src/opentrons/protocol_engine/commands/pick_up_tip.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ..errors import ErrorOccurrence, TipNotAttachedError
from ..resources import ModelUtils
from ..state import update_types
from ..types import DeckPoint
from ..types import DeckPoint, TipGeometry
from .pipetting_common import (
PipetteIdMixin,
WellLocationMixin,
Expand Down Expand Up @@ -130,6 +130,14 @@ async def execute(
labware_id=labware_id,
well_name=well_name,
)
state_update.update_tip_state(
pipette_id=pipette_id,
tip_geometry=TipGeometry(
volume=tip_geometry.volume,
length=tip_geometry.length,
diameter=tip_geometry.diameter,
),
)
except TipNotAttachedError as e:
return DefinedErrorData(
public=TipPhysicallyMissingError(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Command models to drop tip in place while plunger positions are unknown."""
from __future__ import annotations
from opentrons.protocol_engine.state.update_types import StateUpdate
from pydantic import Field, BaseModel
from typing import TYPE_CHECKING, Optional, Type
from typing_extensions import Literal
Expand Down Expand Up @@ -72,7 +73,12 @@ async def execute(
pipette_id=params.pipetteId, home_after=params.homeAfter
)

return SuccessData(public=UnsafeDropTipInPlaceResult(), private=None)
state_update = StateUpdate()
state_update.update_tip_state(pipette_id=params.pipetteId, tip_geometry=None)

return SuccessData(
public=UnsafeDropTipInPlaceResult(), private=None, state_update=state_update
)


class UnsafeDropTipInPlace(
Expand Down
Loading

0 comments on commit f8a02aa

Please sign in to comment.