Skip to content

Commit

Permalink
fixup env vs plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Jan 6, 2025
1 parent ccae19f commit 60affca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions src/ert/config/ert_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ def handle_default(fm_step: ForwardModelStep, arg: str) -> str:
**{
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
# Plugin settings can not override anything:
if key not in env_vars and key not in fm_step.environment
},
**fm_step.environment,
)
Expand Down Expand Up @@ -831,13 +831,12 @@ def _create_list_of_forward_model_steps_to_run(
skip_pre_experiment_validation=True,
env_vars=env_vars,
)
fm_json = substituted_json["jobList"][0]
fm_json["environment"] = {
**cls.ENV_PR_FM_STEP.get(fm_step.name, {}), # plugins
**fm_json["environment"],
**substituted_json["global_environment"], # SETENV
fm_json_for_validation = dict(substituted_json["jobList"][0])
fm_json_for_validation["environment"] = {
**substituted_json["global_environment"],
**fm_json_for_validation["environment"],
}
fm_step.validate_pre_experiment(fm_json)
fm_step.validate_pre_experiment(fm_json_for_validation)
except ForwardModelStepValidationError as err:
errors.append(
ConfigValidationError.with_context(
Expand Down
2 changes: 1 addition & 1 deletion tests/ert/unit_tests/config/test_ert_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ def test_fm_step_config_via_plugin_is_overridden_by_setenv(monkeypatch):
run_id=None,
)
assert step_json["global_environment"]["FOO"] == "bar_from_setenv"
assert step_json["jobList"][0]["environment"]["FOO"] == "bar_from_setenv"
assert "FOO" not in step_json["jobList"][0]["environment"]
assert step_json["jobList"][0]["environment"]["STEP_LOCAL_VAR"] == "com_from_plugin"


Expand Down

0 comments on commit 60affca

Please sign in to comment.