Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CFG with configuration options given via command line #2595

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions esmvalcore/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,9 @@ def run(self, recipe, **kwargs):

recipe = self._get_recipe(recipe)

CFG.update(kwargs)
CFG["resume_from"] = parse_resume(CFG["resume_from"], recipe)
session = CFG.start_session(recipe.stem)
session.update(kwargs)
session["resume_from"] = parse_resume(session["resume_from"], recipe)

self._run(recipe, session, cli_config_dir)

Expand Down
16 changes: 10 additions & 6 deletions tests/unit/main/test_esmvaltool.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,24 @@
@pytest.fixture
def cfg(mocker, tmp_path):
"""Mock `esmvalcore.config.CFG`."""
session = mocker.MagicMock()

cfg_dict = {"resume_from": []}
session.__getitem__.side_effect = cfg_dict.__getitem__
session.__setitem__.side_effect = cfg_dict.__setitem__
session.update.side_effect = cfg_dict.update

cfg = mocker.MagicMock()
cfg.__getitem__.side_effect = cfg_dict.__getitem__
cfg.__setitem__.side_effect = cfg_dict.__setitem__
cfg.update.side_effect = cfg_dict.update

session = mocker.MagicMock()
session.__getitem__.side_effect = cfg.__getitem__
session.__setitem__.side_effect = cfg.__setitem__
session.update.side_effect = cfg.update

output_dir = tmp_path / "esmvaltool_output"
session.session_dir = output_dir / "recipe_test"
session.run_dir = session.session_dir / "run_dir"
session.preproc_dir = session.session_dir / "preproc_dir"
session._fixed_file_dir = session.preproc_dir / "fixed_files"

cfg = mocker.Mock()
cfg.start_session.return_value = session

return cfg
Expand Down