Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Jan 3, 2025
1 parent 56f768e commit ccae19f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/ert/config/ert_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,13 @@ def handle_default(fm_step: ForwardModelStep, arg: str) -> str:
],
"environment": substituter.filter_env_dict(
dict(
env_pr_fm_step.get(fm_step.name, {}),
**{
key: value
for key, value in env_pr_fm_step.get(fm_step.name, {}).items()
# Let SETENV override keys set through the plugin system:
if key not in env_vars
},
**fm_step.environment,
**env_vars, # SETENV
)
),
"exec_env": substituter.filter_env_dict(fm_step.exec_env),
Expand Down
13 changes: 9 additions & 4 deletions tests/ert/unit_tests/config/test_ert_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,12 +917,17 @@ def test_fm_step_config_via_plugin_stringifies_python_objects(monkeypatch):


@pytest.mark.usefixtures("use_tmpdir")
def test_fm_step_config_via_plugin_ignores_conflict_with_setenv(monkeypatch):
def test_fm_step_config_via_plugin_is_overridden_by_setenv(monkeypatch):
monkeypatch.setattr(
ErtPluginManager,
"get_forward_model_configuration",
MagicMock(
return_value={"SOME_STEP": {"FOO": "bar_from_plugin", "_ERT_RUNPATH": "0"}}
return_value={
"SOME_STEP": {
"FOO": "bar_from_plugin",
"STEP_LOCAL_VAR": "com_from_plugin",
}
}
),
)
Path("SOME_STEP").write_text("EXECUTABLE /bin/ls", encoding="utf-8")
Expand All @@ -946,8 +951,8 @@ def test_fm_step_config_via_plugin_ignores_conflict_with_setenv(monkeypatch):
run_id=None,
)
assert step_json["global_environment"]["FOO"] == "bar_from_setenv"
assert step_json["jobList"][0]["environment"]["FOO"] == "bar_from_plugin"
# It is up to forward_model_runner to define behaviour here
assert step_json["jobList"][0]["environment"]["FOO"] == "bar_from_setenv"
assert step_json["jobList"][0]["environment"]["STEP_LOCAL_VAR"] == "com_from_plugin"


@pytest.mark.usefixtures("use_tmpdir")
Expand Down

0 comments on commit ccae19f

Please sign in to comment.