From 1dd14ba8a7f2087d895ae48293474374bc0d39ba Mon Sep 17 00:00:00 2001 From: Brent Hagen <brent.hagen@opentrons.com> Date: Wed, 27 Mar 2024 12:43:07 -0400 Subject: [PATCH] feat(api): add oem mode setting (#14730) adds an enableOEMMode robot setting to track whether OEM mode is enabled for the ODD closes PLAT-186 --- api/src/opentrons/config/advanced_settings.py | 18 ++++++++++++++++++ .../config/test_advanced_settings_migration.py | 17 ++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/api/src/opentrons/config/advanced_settings.py b/api/src/opentrons/config/advanced_settings.py index f679c742d7e..191c0d69ccc 100644 --- a/api/src/opentrons/config/advanced_settings.py +++ b/api/src/opentrons/config/advanced_settings.py @@ -233,6 +233,13 @@ class Setting(NamedTuple): robot_type=[RobotTypeEnum.FLEX], internal_only=True, ), + SettingDefinition( + _id="enableOEMMode", + title="Enable OEM Mode", + description="This setting anonymizes Opentrons branding in the ODD app.", + robot_type=[RobotTypeEnum.FLEX], + internal_only=True, + ), ] if ( @@ -692,6 +699,16 @@ def _migrate30to31(previous: SettingsMap) -> SettingsMap: return newmap +def _migrate31to32(previous: SettingsMap) -> SettingsMap: + """Migrate to version 32 of the feature flags file. + + - Adds the enableOEMMode config element. + """ + newmap = {k: v for k, v in previous.items()} + newmap["enableOEMMode"] = None + return newmap + + _MIGRATIONS = [ _migrate0to1, _migrate1to2, @@ -724,6 +741,7 @@ def _migrate30to31(previous: SettingsMap) -> SettingsMap: _migrate28to29, _migrate29to30, _migrate30to31, + _migrate31to32, ] """ List of all migrations to apply, indexed by (version - 1). See _migrate below diff --git a/api/tests/opentrons/config/test_advanced_settings_migration.py b/api/tests/opentrons/config/test_advanced_settings_migration.py index 4e88e28f262..e1c3f51b651 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 31 + return 32 # make sure to set a boolean value in default_file_settings only if @@ -30,6 +30,7 @@ def default_file_settings() -> Dict[str, Any]: "disableOverpressureDetection": None, "estopNotRequired": None, "enableErrorRecoveryExperiments": None, + "enableOEMMode": None, } @@ -379,6 +380,18 @@ def v31_config(v30_config: Dict[str, Any]) -> Dict[str, Any]: return r +@pytest.fixture +def v32_config(v31_config: Dict[str, Any]) -> Dict[str, Any]: + r = v31_config.copy() + r.update( + { + "_version": 32, + "enableOEMMode": None, + } + ) + return r + + @pytest.fixture( scope="session", params=[ @@ -415,6 +428,7 @@ def v31_config(v30_config: Dict[str, Any]) -> Dict[str, Any]: lazy_fixture("v29_config"), lazy_fixture("v30_config"), lazy_fixture("v31_config"), + lazy_fixture("v32_config"), ], ) def old_settings(request: SubRequest) -> Dict[str, Any]: @@ -507,4 +521,5 @@ def test_ensures_config() -> None: "estopNotRequired": None, "disableOverpressureDetection": None, "enableErrorRecoveryExperiments": None, + "enableOEMMode": None, }