Skip to content

Commit

Permalink
refactor(api): Add an enableErrorRecoveryExperiments feature flag (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxColoring authored Mar 13, 2024
1 parent ce4940d commit f307641
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
25 changes: 25 additions & 0 deletions api/src/opentrons/config/advanced_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,20 @@ class Setting(NamedTuple):
description="When this setting is on, Flex will continue its activities regardless of pressure changes inside the pipette. Do not turn this setting on unless you are intentionally causing pressures over 8 kPa inside the pipette air channel.",
robot_type=[RobotTypeEnum.FLEX],
),
SettingDefinition(
_id="enableErrorRecoveryExperiments",
title="Enable error recovery experiments",
description=(
"Do not enable."
" This is an Opentrons internal setting to experiment with"
" in-development error recovery features."
" This will interfere with your protocol runs,"
" corrupt your robot's storage,"
" bring misfortune and pestilence upon you and your livestock, etc."
),
robot_type=[RobotTypeEnum.FLEX],
internal_only=True,
),
]

if (
Expand Down Expand Up @@ -668,6 +682,16 @@ def _migrate29to30(previous: SettingsMap) -> SettingsMap:
return {k: v for k, v in previous.items() if "disableTipPresenceDetection" != k}


def _migrate30to31(previous: SettingsMap) -> SettingsMap:
"""Migrate to version 31 of the feature flags file.
- Adds the enableErrorRecoveryExperiments config element.
"""
newmap = {k: v for k, v in previous.items()}
newmap["enableErrorRecoveryExperiments"] = None
return newmap


_MIGRATIONS = [
_migrate0to1,
_migrate1to2,
Expand Down Expand Up @@ -699,6 +723,7 @@ def _migrate29to30(previous: SettingsMap) -> SettingsMap:
_migrate27to28,
_migrate28to29,
_migrate29to30,
_migrate30to31,
]
"""
List of all migrations to apply, indexed by (version - 1). See _migrate below
Expand Down
6 changes: 6 additions & 0 deletions api/src/opentrons/config/feature_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,9 @@ def require_estop() -> bool:
return not advs.get_setting_with_env_overload(
"estopNotRequired", RobotTypeEnum.FLEX
)


def enable_error_recovery_experiments() -> bool:
return advs.get_setting_with_env_overload(
"enableErrorRecoveryExperiments", RobotTypeEnum.FLEX
)
17 changes: 16 additions & 1 deletion 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 30
return 31


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


Expand Down Expand Up @@ -366,6 +367,18 @@ def v30_config(v29_config: Dict[str, Any]) -> Dict[str, Any]:
return r


@pytest.fixture
def v31_config(v30_config: Dict[str, Any]) -> Dict[str, Any]:
r = v30_config.copy()
r.update(
{
"_version": 31,
"enableErrorRecoveryExperiments": None,
}
)
return r


@pytest.fixture(
scope="session",
params=[
Expand Down Expand Up @@ -401,6 +414,7 @@ def v30_config(v29_config: Dict[str, Any]) -> Dict[str, Any]:
lazy_fixture("v28_config"),
lazy_fixture("v29_config"),
lazy_fixture("v30_config"),
lazy_fixture("v31_config"),
],
)
def old_settings(request: SubRequest) -> Dict[str, Any]:
Expand Down Expand Up @@ -492,4 +506,5 @@ def test_ensures_config() -> None:
"disableStatusBar": None,
"estopNotRequired": None,
"disableOverpressureDetection": None,
"enableErrorRecoveryExperiments": None,
}

0 comments on commit f307641

Please sign in to comment.