Skip to content

Commit

Permalink
StateUpdate docstrings.
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxColoring committed Oct 14, 2024
1 parent 61aaec7 commit c494105
Showing 1 changed file with 36 additions and 14 deletions.
50 changes: 36 additions & 14 deletions api/src/opentrons/protocol_engine/state/update_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ class AddressableArea:

@dataclasses.dataclass
class PipetteLocationUpdate:
"""Represents an update to perform on a pipette's location."""
"""An update to a pipette's location."""

pipette_id: str
"""The ID of the already-loaded pipette."""

new_location: Well | AddressableArea | None | NoChangeType
"""The pipette's new logical location.
Expand All @@ -82,19 +83,30 @@ class PipetteLocationUpdate:

@dataclasses.dataclass
class LabwareLocationUpdate:
"""Represents an update to perform on a labware's location."""
"""An update to a labware's location."""

labware_id: str
"""The ID of the already-loaded labware."""

new_location: LabwareLocation
"""The labware's new logical location."""
"""The labware's new location."""

offset_id: typing.Optional[str]
"""The ID of the labware's new offset, for its new location."""


@dataclasses.dataclass
class LoadedLabwareUpdate(LabwareLocationUpdate):
"""Update loaded labware."""
class LoadedLabwareUpdate:
"""An update that loads a new labware."""

labware_id: str
"""The unique ID of the new labware."""

new_location: LabwareLocation
"""The labware's initial location."""

offset_id: typing.Optional[str]
"""The ID of the labware's offset."""

display_name: typing.Optional[str]

Expand All @@ -103,20 +115,30 @@ class LoadedLabwareUpdate(LabwareLocationUpdate):

@dataclasses.dataclass
class LoadPipetteUpdate:
"""Update loaded pipette."""
"""An update that loads a new pipette.
NOTE: Currently, if this is provided, a PipetteConfigUpdate must always be
provided alongside it to fully initialize everything.
"""

pipette_id: str
"""The unique ID of the new pipette."""

pipette_name: PipetteNameType
mount: MountType
liquid_presence_detection: typing.Optional[bool]


@dataclasses.dataclass
class PipetteConfigUpdate:
"""Update pipette config."""
"""An update to a pipette's config."""

pipette_id: str
"""The ID of the already-loaded pipette."""

# todo(mm, 2024-10-14): Does serial_number belong in LoadPipetteUpdate?
serial_number: str

config: pipette_data_provider.LoadedStaticPipetteData


Expand Down Expand Up @@ -237,7 +259,7 @@ def set_labware_location(
new_location: LabwareLocation,
new_offset_id: str | None,
) -> None:
"""Set labware location."""
"""Set a labware's location. See `LabwareLocationUpdate`."""
self.labware_location = LabwareLocationUpdate(
labware_id=labware_id,
new_location=new_location,
Expand All @@ -252,7 +274,7 @@ def set_loaded_labware(
display_name: typing.Optional[str],
location: LabwareLocation,
) -> None:
"""Add loaded labware to state."""
"""Add a new labware to state. See `LoadedLabwareUpdate`."""
self.loaded_labware = LoadedLabwareUpdate(
definition=definition,
labware_id=labware_id,
Expand All @@ -268,7 +290,7 @@ def set_load_pipette(
mount: MountType,
liquid_presence_detection: typing.Optional[bool],
) -> None:
"""Add loaded pipette to state."""
"""Add a new pipette to state. See `LoadPipetteUpdate`."""
self.loaded_pipette = LoadPipetteUpdate(
pipette_id=pipette_id,
pipette_name=pipette_name,
Expand All @@ -282,29 +304,29 @@ def update_pipette_config(
config: pipette_data_provider.LoadedStaticPipetteData,
serial_number: str,
) -> None:
"""Update pipette config."""
"""Update a pipette's config. See `PipetteConfigUpdate`."""
self.pipette_config = PipetteConfigUpdate(
pipette_id=pipette_id, config=config, serial_number=serial_number
)

def update_pipette_nozzle(self, pipette_id: str, nozzle_map: NozzleMap) -> None:
"""Update pipette nozzle map."""
"""Update a pipette's nozzle map. See `PipetteNozzleMapUpdate`."""
self.pipette_nozzle_map = PipetteNozzleMapUpdate(
pipette_id=pipette_id, nozzle_map=nozzle_map
)

def update_pipette_tip_state(
self, pipette_id: str, tip_geometry: typing.Optional[TipGeometry]
) -> None:
"""Update tip state."""
"""Update a pipette's tip state. See `PipetteTipStateUpdate`."""
self.pipette_tip_state = PipetteTipStateUpdate(
pipette_id=pipette_id, tip_geometry=tip_geometry
)

def mark_tips_as_used(
self, pipette_id: str, labware_id: str, well_name: str
) -> None:
"""Mark tips in a tip rack as used. See `MarkTipsUsedState`."""
"""Mark tips in a tip rack as used. See `TipsUsedUpdate`."""
self.tips_used = TipsUsedUpdate(
pipette_id=pipette_id, labware_id=labware_id, well_name=well_name
)

0 comments on commit c494105

Please sign in to comment.