Skip to content

Commit

Permalink
Move addition of activate script
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Dec 6, 2024
1 parent 5e61770 commit 325c664
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/ert/config/ert_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions tests/ert/unit_tests/plugins/test_plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 325c664

Please sign in to comment.