Skip to content

Commit

Permalink
feat(api): add command to configure liquid class in Protocol Engine
Browse files Browse the repository at this point in the history
Rather than importing the concept of liquid classes to pipette state, we should just add a command
to update the static configs from the user facing python API.
  • Loading branch information
Laura-Danielle authored and sfoster1 committed Sep 6, 2023
1 parent 431ac83 commit 47b291e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
2 changes: 2 additions & 0 deletions api/src/opentrons/protocol_engine/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
ResetTipsAction,
SetPipetteMovementSpeedAction,
AddPipetteConfigAction,
UpdateLiquidClassAction,
)

__all__ = [
Expand All @@ -50,6 +51,7 @@
"ResetTipsAction",
"SetPipetteMovementSpeedAction",
"AddPipetteConfigAction",
"UpdateLiquidClassAction",
# action payload values
"PauseSource",
"FinishErrorDetails",
Expand Down
10 changes: 10 additions & 0 deletions api/src/opentrons/protocol_engine/actions/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ class AddPipetteConfigAction:
config: pipette_data_provider.LoadedStaticPipetteData


@dataclass(frozen=True)
class UpdateLiquidClassAction:
"""Update a pipette's current static config class based on a new liquid class."""

pipette_id: str
serial_number: str
config: pipette_data_provider.LoadedStaticPipetteData


Action = Union[
PlayAction,
PauseAction,
Expand All @@ -206,4 +215,5 @@ class AddPipetteConfigAction:
ResetTipsAction,
SetPipetteMovementSpeedAction,
AddPipetteConfigAction,
UpdateLiquidClassAction,
]
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class LoadedStaticPipetteData:

def get_virtual_pipette_static_config(
pipette_name: PipetteName,
liquid_class: pip_types.LiquidClasses = pip_types.LiquidClasses.default,
) -> LoadedStaticPipetteData:
"""Get the config for a virtual pipette, given only the pipette name."""
pipette_model = pipette_load_name.convert_pipette_name(pipette_name)
Expand All @@ -44,9 +45,6 @@ def get_virtual_pipette_static_config(
pipette_model.pipette_version,
)

# TODO the liquid classes should be made configurable
# in a follow-up PR.
liquid_class = pip_types.LiquidClasses.default
tip_configuration = config.liquid_properties[liquid_class].supported_tips[
pip_types.PipetteTipType(config.liquid_properties[liquid_class].max_volume)
]
Expand Down
16 changes: 16 additions & 0 deletions api/src/opentrons/protocol_engine/state/pipettes.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
SetPipetteMovementSpeedAction,
UpdateCommandAction,
AddPipetteConfigAction,
UpdateLiquidClassAction,
)
from .abstract_store import HasState, HandlesActions

Expand Down Expand Up @@ -133,6 +134,21 @@ def handle_action(self, action: Action) -> None:
nozzle_offset_z=config.nozzle_offset_z,
)
self._state.flow_rates_by_id[action.pipette_id] = config.flow_rates
elif isinstance(action, UpdateLiquidClassAction):
config = action.config
self._state.static_config_by_id[action.pipette_id] = StaticPipetteConfig(
serial_number=action.serial_number,
model=config.model,
display_name=config.display_name,
min_volume=config.min_volume,
max_volume=config.max_volume,
channels=config.channels,
tip_configuration_lookup_table=config.tip_configuration_lookup_table,
nominal_tip_overlap=config.nominal_tip_overlap,
home_position=config.home_position,
nozzle_offset_z=config.nozzle_offset_z,
)
self._state.flow_rates_by_id[action.pipette_id] = config.flow_rates

def _handle_command(self, command: Command) -> None: # noqa: ANN101, C901
self._update_current_well(command)
Expand Down

0 comments on commit 47b291e

Please sign in to comment.