From f3076410211cc3ac46db81678de93500abf80142 Mon Sep 17 00:00:00 2001 From: Max Marrone Date: Wed, 13 Mar 2024 09:54:40 -0400 Subject: [PATCH] refactor(api): Add an `enableErrorRecoveryExperiments` feature flag (#14639) --- api/src/opentrons/config/advanced_settings.py | 25 +++++++++++++++++++ api/src/opentrons/config/feature_flags.py | 6 +++++ .../test_advanced_settings_migration.py | 17 ++++++++++++- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/api/src/opentrons/config/advanced_settings.py b/api/src/opentrons/config/advanced_settings.py index feebbe1cb48..f679c742d7e 100644 --- a/api/src/opentrons/config/advanced_settings.py +++ b/api/src/opentrons/config/advanced_settings.py @@ -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 ( @@ -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, @@ -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 diff --git a/api/src/opentrons/config/feature_flags.py b/api/src/opentrons/config/feature_flags.py index 583dae0b141..4a1161a2391 100644 --- a/api/src/opentrons/config/feature_flags.py +++ b/api/src/opentrons/config/feature_flags.py @@ -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 + ) diff --git a/api/tests/opentrons/config/test_advanced_settings_migration.py b/api/tests/opentrons/config/test_advanced_settings_migration.py index 1070654e14d..4e88e28f262 100644 --- a/api/tests/opentrons/config/test_advanced_settings_migration.py +++ b/api/tests/opentrons/config/test_advanced_settings_migration.py @@ -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 @@ -29,6 +29,7 @@ def default_file_settings() -> Dict[str, Any]: "disableStatusBar": None, "disableOverpressureDetection": None, "estopNotRequired": None, + "enableErrorRecoveryExperiments": None, } @@ -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=[ @@ -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]: @@ -492,4 +506,5 @@ def test_ensures_config() -> None: "disableStatusBar": None, "estopNotRequired": None, "disableOverpressureDetection": None, + "enableErrorRecoveryExperiments": None, }