From 325c6647fbb56da1456b34b0781a0993e879a1ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Eide?= Date: Fri, 6 Dec 2024 10:10:59 +0100 Subject: [PATCH] Move addition of activate script --- src/ert/config/ert_config.py | 16 ++++++++++------ .../unit_tests/plugins/test_plugin_manager.py | 13 +++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/ert/config/ert_config.py b/src/ert/config/ert_config.py index 907765ad908..df80c6110c3 100644 --- a/src/ert/config/ert_config.py +++ b/src/ert/config/ert_config.py @@ -478,6 +478,16 @@ def from_dict(cls, config_dict) -> Self: errors.append(e) try: + if cls.ACTIVATE_SCRIPT: + if "QUEUE_OPTION" not in config_dict: + config_dict["QUEUE_OPTION"] = [] + config_dict["QUEUE_OPTION"].append( + [ + QueueSystemWithGeneric.GENERIC, + "ACTIVATE_SCRIPT", + cls.ACTIVATE_SCRIPT, + ] + ) queue_config = QueueConfig.from_dict(config_dict) except ConfigValidationError as err: errors.append(err) @@ -678,12 +688,6 @@ def _merge_user_and_site_config( user_config_dict[keyword] = value + original_entries elif keyword not in user_config_dict: user_config_dict[keyword] = value - if cls.ACTIVATE_SCRIPT: - if "QUEUE_OPTION" not in user_config_dict: - user_config_dict["QUEUE_OPTION"] = [] - user_config_dict["QUEUE_OPTION"].append( - [QueueSystemWithGeneric.GENERIC, "ACTIVATE_SCRIPT", cls.ACTIVATE_SCRIPT] - ) return user_config_dict @classmethod diff --git a/tests/ert/unit_tests/plugins/test_plugin_manager.py b/tests/ert/unit_tests/plugins/test_plugin_manager.py index 97f479c252c..013b61af49c 100644 --- a/tests/ert/unit_tests/plugins/test_plugin_manager.py +++ b/tests/ert/unit_tests/plugins/test_plugin_manager.py @@ -321,3 +321,16 @@ def test_activate_script_plugin_integration(): with patch("ert.config.ert_config.ErtPluginManager", patched): config = ErtConfig.with_plugins().from_file_contents("NUM_REALIZATIONS 1\n") assert config.queue_config.queue_options.activate_script == "source something" + + +def test_activate_script_plugin_integration_from_dict(): + patched = partial( + ert.config.ert_config.ErtPluginManager, plugins=[ActivatePlugin()] + ) + with patch("ert.config.ert_config.ErtPluginManager", patched): + config = ErtConfig.with_plugins().from_dict( + { + "NUM_REALIZATIONS": 1, + } + ) + assert config.queue_config.queue_options.activate_script == "source something"