Skip to content

Commit

Permalink
feat(api): remove liquid classes feature flag, gate liquid classes be…
Browse files Browse the repository at this point in the history
…hind 2.23 (#17378)

Closes AUTH-1294

# Overview

- Removes the `allowLiquidClasses` feature flag
- Gates all liquid classes features (including `transfer_liquid()`,
`distribute_liquid()`, `consolidate_liquid()`) behind PAPI version 2.23
- Updates tests

## Risk assessment

Low. Makes the liquid classes feature available for use in the new API.
But this work does not affect any existing APIs.
  • Loading branch information
sanni-t authored Jan 29, 2025
1 parent 5303a3b commit 6123b81
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 169 deletions.
9 changes: 9 additions & 0 deletions api/release-notes-internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ For more details about this release, please see the full [technical change log][

[technical change log]: https://github.com/Opentrons/opentrons/releases

## Internal Release 2.4.0-alpha.1

This internal release, pulled from the `edge` branch, contains features being developed for 8.4.0. It's for internal testing only.

### New Stuff In This Release (list in progress):

- Python API version bumped to 2.23
- Added liquid classes and new transfer functions

## Internal Release 2.3.0-alpha.2

This internal release, pulled from the `edge` branch, contains features being developed for 8.3.0. It's for internal testing only.
Expand Down
20 changes: 9 additions & 11 deletions api/src/opentrons/config/advanced_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,6 @@ class Setting(NamedTuple):
robot_type=[RobotTypeEnum.OT2, RobotTypeEnum.FLEX],
internal_only=True,
),
SettingDefinition(
_id="allowLiquidClasses",
title="Allow the use of liquid classes",
description=(
"Do not enable."
" This is an Opentrons internal setting to allow using in-development"
" liquid classes."
),
robot_type=[RobotTypeEnum.OT2, RobotTypeEnum.FLEX],
internal_only=True,
),
]


Expand Down Expand Up @@ -736,6 +725,14 @@ def _migrate35to36(previous: SettingsMap) -> SettingsMap:
return newmap


def _migrate36to37(previous: SettingsMap) -> SettingsMap:
"""Migrate to version 37 of the feature flags file.
- Removes the allowLiquidClasses flag.
"""
return {k: v for k, v in previous.items() if "allowLiquidClasses" != k}


_MIGRATIONS = [
_migrate0to1,
_migrate1to2,
Expand Down Expand Up @@ -773,6 +770,7 @@ def _migrate35to36(previous: SettingsMap) -> SettingsMap:
_migrate33to34,
_migrate34to35,
_migrate35to36,
_migrate36to37,
]
"""
List of all migrations to apply, indexed by (version - 1). See _migrate below
Expand Down
4 changes: 0 additions & 4 deletions api/src/opentrons/config/feature_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,3 @@ def enable_performance_metrics(robot_type: RobotTypeEnum) -> bool:

def oem_mode_enabled() -> bool:
return advs.get_setting_with_env_overload("enableOEMMode", RobotTypeEnum.FLEX)


def allow_liquid_classes(robot_type: RobotTypeEnum) -> bool:
return advs.get_setting_with_env_overload("allowLiquidClasses", robot_type)
25 changes: 3 additions & 22 deletions api/src/opentrons/protocol_api/instrument_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
UnexpectedTipRemovalError,
UnsupportedHardwareCommand,
)
from opentrons_shared_data.robot.types import RobotTypeEnum

from opentrons.legacy_broker import LegacyBroker
from opentrons.hardware_control.dev_types import PipetteDict
Expand Down Expand Up @@ -38,7 +37,6 @@
from ._nozzle_layout import NozzleLayout
from ._liquid import LiquidClass
from . import labware, validation
from ..config import feature_flags
from ..protocols.advanced_control.transfers.common import (
TransferTipPolicyV2,
TransferTipPolicyV2Type,
Expand Down Expand Up @@ -1509,6 +1507,7 @@ def _execute_transfer(self, plan: v1_transfer.TransferPlan) -> None:
for cmd in plan:
getattr(self, cmd["method"])(*cmd["args"], **cmd["kwargs"])

@requires_version(2, 23)
def transfer_liquid(
self,
liquid_class: LiquidClass,
Expand All @@ -1528,13 +1527,6 @@ def transfer_liquid(
TODO: Add args description.
"""
if not feature_flags.allow_liquid_classes(
robot_type=RobotTypeEnum.robot_literal_to_enum(
self._protocol_core.robot_type
)
):
raise NotImplementedError("This method is not implemented.")

flat_sources_list = validation.ensure_valid_flat_wells_list_for_transfer_v2(
source
)
Expand Down Expand Up @@ -1604,6 +1596,7 @@ def transfer_liquid(
)
return self

@requires_version(2, 23)
def distribute_liquid(
self,
liquid_class: LiquidClass,
Expand All @@ -1623,13 +1616,6 @@ def distribute_liquid(
TODO: Add args description.
"""
if not feature_flags.allow_liquid_classes(
robot_type=RobotTypeEnum.robot_literal_to_enum(
self._protocol_core.robot_type
)
):
raise NotImplementedError("This method is not implemented.")

if not isinstance(source, labware.Well):
raise ValueError(f"Source should be a single Well but received {source}.")
flat_dests_list = validation.ensure_valid_flat_wells_list_for_transfer_v2(dest)
Expand Down Expand Up @@ -1689,6 +1675,7 @@ def distribute_liquid(
)
return self

@requires_version(2, 23)
def consolidate_liquid(
self,
liquid_class: LiquidClass,
Expand All @@ -1708,12 +1695,6 @@ def consolidate_liquid(
TODO: Add args description.
"""
if not feature_flags.allow_liquid_classes(
robot_type=RobotTypeEnum.robot_literal_to_enum(
self._protocol_core.robot_type
)
):
raise NotImplementedError("This method is not implemented.")
if not isinstance(dest, labware.Well):
raise ValueError(
f"Destination should be a single Well but received {dest}."
Expand Down
10 changes: 2 additions & 8 deletions api/src/opentrons/protocol_api/protocol_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@

from opentrons_shared_data.labware.types import LabwareDefinition
from opentrons_shared_data.pipette.types import PipetteNameType
from opentrons_shared_data.robot.types import RobotTypeEnum

from opentrons.types import Mount, Location, DeckLocation, DeckSlotName, StagingSlotName
from opentrons.config import feature_flags
from opentrons.legacy_broker import LegacyBroker
from opentrons.hardware_control.modules.types import (
MagneticBlockModel,
Expand Down Expand Up @@ -1354,17 +1352,13 @@ def define_liquid(
display_color=display_color,
)

@requires_version(2, 23)
def define_liquid_class(
self,
name: str,
) -> LiquidClass:
"""Define a liquid class for use in the protocol."""
if feature_flags.allow_liquid_classes(
robot_type=RobotTypeEnum.robot_literal_to_enum(self._core.robot_type)
):
return self._core.define_liquid_class(name=name)
else:
raise NotImplementedError("This method is not implemented.")
return self._core.define_liquid_class(name=name)

@property
@requires_version(2, 5)
Expand Down
12 changes: 9 additions & 3 deletions api/tests/opentrons/config/test_advanced_settings_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@pytest.fixture
def migrated_file_version() -> int:
return 36
return 37


# make sure to set a boolean value in default_file_settings only if
Expand All @@ -30,7 +30,6 @@ def default_file_settings() -> Dict[str, Any]:
"enableErrorRecoveryExperiments": None,
"enableOEMMode": None,
"enablePerformanceMetrics": None,
"allowLiquidClasses": None,
}


Expand Down Expand Up @@ -432,6 +431,13 @@ def v36_config(v35_config: Dict[str, Any]) -> Dict[str, Any]:
return r


@pytest.fixture
def v37_config(v36_config: Dict[str, Any]) -> Dict[str, Any]:
r = {k: v for k, v in v36_config.items() if k != "allowLiquidClasses"}
r["_version"] = 37
return r


@pytest.fixture(
scope="session",
params=[
Expand Down Expand Up @@ -473,6 +479,7 @@ def v36_config(v35_config: Dict[str, Any]) -> Dict[str, Any]:
lazy_fixture("v34_config"),
lazy_fixture("v35_config"),
lazy_fixture("v36_config"),
lazy_fixture("v37_config"),
],
)
def old_settings(request: SubRequest) -> Dict[str, Any]:
Expand Down Expand Up @@ -563,5 +570,4 @@ def test_ensures_config() -> None:
"enableErrorRecoveryExperiments": None,
"enableOEMMode": None,
"enablePerformanceMetrics": None,
"allowLiquidClasses": None,
}
Loading

0 comments on commit 6123b81

Please sign in to comment.