Skip to content

Commit

Permalink
fix(shared-data): load pick up current properly (#14350)
Browse files Browse the repository at this point in the history
While we properly handled _most_ kinds of pipette config, there's one we
didn't: pick up current. It gets special treatment now because we can
properly set different currents for different numbers of tips, rather
than being a value. So, we need to mark it as a setting that needs to be
iterated over a dictionary in its leaf value rather than directly set.

This also fixes an issue that caused the OT-2 to not boot when loading a
pipette configuration that had a pick up current customization, since
this code is called when loading a pipette.

It may be closing the barn after the horse escapes, but to prevent
similar issues preventing boot, I also tossed in a catch all except that
logs a loud message but won't prevent starting the server.

Closes RESC-187
  • Loading branch information
sfoster1 authored and ncdiehl11 committed Feb 1, 2024
1 parent 142751a commit ee944e2
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@
"bottom": ["plungerPositionsConfigurations", "default", "bottom"],
"blowout": ["plungerPositionsConfigurations", "default", "blowout"],
"dropTip": ["plungerPositionsConfigurations", "default", "drop"],
"pickUpCurrent": ["pickUpTipConfigurations", "pressFit", "currentByTipCount"],
"pickUpCurrent": [
"pickUpTipConfigurations",
"pressFit",
"currentByTipCount",
"##EACHTIP##",
],
"pickUpDistance": ["pickUpTipConfigurations", "pressFit", "distance"],
"pickUpIncrement": ["pickUpTipConfigurations", "pressFit", "increment"],
"pickUpPresses": ["pickUpTipConfigurations", "pressFit", "presses"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re
from pathlib import Path
from typing import Optional, List, Dict, Any, cast
from enum import Enum

from .pipette_definition import PipetteConfigurations, PipetteModelVersionType
from .model_constants import (
Expand Down Expand Up @@ -165,14 +166,14 @@ def _do_get_default_value_for(
rest = keypath[1:]
if first == "##EACHTIP##":
tip_list = list(remaining_config.keys())
tip_list.sort(key=lambda o: o.value)
tip_list.sort(key=lambda o: o.value if isinstance(o, Enum) else o)
return _do_get_default_value_for(remaining_config[tip_list[-1]], rest)
else:
return _do_get_default_value_for(remaining_config[first], rest)
else:
if first == "###EACHTIP##":
if first == "##EACHTIP##":
tip_list = list(remaining_config.keys())
tip_list.sort(key=lambda o: o.value)
tip_list.sort(key=lambda o: o.value if isinstance(o, Enum) else o)
return remaining_config[tip_list[-1]]
elif first == "currentByTipCount":
# return the value for the most tips at a time
Expand Down Expand Up @@ -330,9 +331,15 @@ def load_with_mutable_configurations(
except FileNotFoundError:
pass
else:
base_configurations = _migrate_to_v2_configurations(
base_configurations, override
)
try:
base_configurations = _migrate_to_v2_configurations(
base_configurations, override
)
except BaseException:
log.exception(
"Failed to migrate mutable configurations. Please report this as it is a bug."
)

# the ulPerMm functions are structured in pipetteModelSpecs.json as
# a list sorted from oldest to newest. That means the latest functions
# are always the last element and, as of right now, the older ones are
Expand Down
28 changes: 28 additions & 0 deletions shared-data/python/tests/pipette/test_mutable_configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,34 @@ def overrides_fixture(
return types.MutableConfig.build(**TMPFILE_DATA["pickUpSpeed"], name="pickUpSpeed")


def test_load_old_overrides_regression(
TMPFILE_DATA: Dict[str, Any], override_configuration_path: Path
) -> None:
TMPFILE_DATA["pickUpCurrent"] = {
"value": 0.15,
"min": 0.08,
"max": 0.2,
"units": "amps",
"type": "float",
"default": 0.1,
}
json.dump(
TMPFILE_DATA, open(override_configuration_path / "P20SV222021040709.json", "w")
)
configs = mutable_configurations.load_with_mutable_configurations(
pipette_definition.PipetteModelVersionType(
pipette_type=types.PipetteModelType.p20,
pipette_channels=types.PipetteChannelType.SINGLE_CHANNEL,
pipette_version=types.PipetteVersionType(2, 2),
),
override_configuration_path,
"P20SV222021040709",
)
assert configs.pick_up_tip_configurations.press_fit.current_by_tip_count == {
1: 0.15
}


def test_list_mutable_configs_unknown_pipette_id(
override_configuration_path: Path,
) -> None:
Expand Down

0 comments on commit ee944e2

Please sign in to comment.