Skip to content

Commit 2838bac

Browse files
authored
Remove support for ~/.esmvaltool/config-user.yml and ~/.esmvaltool/dask.yml (#2878)
1 parent 19d4725 commit 2838bac

File tree

13 files changed

+47
-1209
lines changed

13 files changed

+47
-1209
lines changed

doc/quickstart/configure.rst

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,23 +80,6 @@ Within a directory, files are sorted lexicographically, and later files (e.g.,
8080
files (like the old ``config-developer.yml`` files) will lead to errors.
8181
Make sure to move these files to a different directory.
8282

83-
.. deprecated:: 2.12.0
84-
85-
If a single configuration file is present at its deprecated location
86-
``~/.esmvaltool/config-user.yml`` or specified via the deprecated command
87-
line argument ``--config_file``, all potentially available new configuration
88-
files at ``~/.config/esmvaltool/`` and/or the location specified via
89-
``--config_dir`` are ignored.
90-
This ensures full backwards-compatibility.
91-
To switch to the new configuration system outlined here, move your old
92-
configuration file to ``~/.config/esmvaltool/`` or to the location specified
93-
via ``--config_dir``, remove ``~/.esmvaltool/config-user.yml``, and omit the
94-
command line argument ``--config_file``.
95-
Alternatively, specifying the environment variable ``ESMVALTOOL_CONFIG_DIR``
96-
will also force the usage of the new configuration system regardless of the
97-
presence of any potential old configuration files.
98-
Support for the deprecated configuration will be removed in version 2.14.0.
99-
10083
To get a copy of the default configuration file, you can run
10184

10285
.. code-block:: bash

esmvalcore/_main.py

Lines changed: 19 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@
3232
import logging
3333
import os
3434
import sys
35-
import warnings
3635
from importlib.metadata import entry_points
3736
from pathlib import Path
3837

3938
import fire
4039

4140
from esmvalcore.config._config import warn_if_old_extra_facets_exist
42-
from esmvalcore.exceptions import ESMValCoreDeprecationWarning
4341

4442
# set up logging
4543
logger = logging.getLogger(__name__)
@@ -401,7 +399,6 @@ def run(self, recipe, **kwargs):
401399
402400
"""
403401
from .config import CFG
404-
from .config._dask import warn_if_old_dask_config_exists
405402
from .exceptions import InvalidConfigParameter
406403

407404
cli_config_dir = kwargs.pop("config_dir", None)
@@ -413,38 +410,6 @@ def run(self, recipe, **kwargs):
413410
f"existing directory"
414411
)
415412
raise NotADirectoryError(msg)
416-
417-
# TODO: remove in v2.14.0
418-
# At this point, --config_file is already parsed if a valid file has
419-
# been given (see
420-
# https://github.com/ESMValGroup/ESMValCore/issues/2280), but no error
421-
# has been raised if the file does not exist. Thus, reload the file
422-
# here with `load_from_file` to make sure a proper error is raised.
423-
if "config_file" in kwargs:
424-
if os.environ.get("ESMVALTOOL_CONFIG_DIR"):
425-
deprecation_msg = (
426-
"Usage of a single configuration file specified via CLI "
427-
"argument `--config_file` has been deprecated in "
428-
"ESMValCore version 2.12.0 and is scheduled for removal "
429-
"in version 2.14.0. Since the environment variable "
430-
"ESMVALTOOL_CONFIG_DIR is set, old configuration files "
431-
"present at ~/.esmvaltool/config-user.yml and/or "
432-
"specified via `--config_file` are currently ignored. To "
433-
"silence this warning, omit CLI argument `--config_file`."
434-
)
435-
warnings.warn(
436-
deprecation_msg,
437-
ESMValCoreDeprecationWarning,
438-
stacklevel=2,
439-
)
440-
kwargs.pop("config_file")
441-
else:
442-
cli_config_dir = kwargs["config_file"]
443-
CFG.load_from_file(kwargs["config_file"])
444-
445-
# New in v2.12.0: read additional configuration directory given by CLI
446-
# argument
447-
if CFG.get("config_file") is None and cli_config_dir is not None:
448413
try:
449414
CFG.update_from_dirs([cli_config_dir])
450415
except InvalidConfigParameter as exc:
@@ -475,7 +440,6 @@ def run(self, recipe, **kwargs):
475440
CFG.update_from_dirs([cli_config_dir])
476441
CFG.nested_update(kwargs)
477442

478-
warn_if_old_dask_config_exists()
479443
warn_if_old_extra_facets_exist()
480444

481445
@staticmethod
@@ -577,35 +541,24 @@ def _get_recipe(recipe) -> Path:
577541
@staticmethod
578542
def _get_config_info(cli_config_dir):
579543
"""Get information about config files for logging."""
580-
from .config import CFG
581544
from .config._config_object import (
582-
DEFAULT_CONFIG_DIR,
583545
_get_all_config_dirs,
584546
_get_all_config_sources,
585547
)
586548

587-
# TODO: remove in v2.14.0
588-
if CFG.get("config_file") is not None:
589-
config_info = [
590-
(DEFAULT_CONFIG_DIR, "defaults"),
591-
(CFG["config_file"], "single configuration file [deprecated]"),
592-
]
593-
594-
# New in v2.12.0
595-
else:
596-
config_dirs = []
597-
for path in _get_all_config_dirs(cli_config_dir):
598-
if not path.is_dir():
599-
config_dirs.append(f"{path} [NOT AN EXISTING DIRECTORY]")
600-
else:
601-
config_dirs.append(str(path))
602-
config_info = list(
603-
zip(
604-
config_dirs,
605-
_get_all_config_sources(cli_config_dir),
606-
strict=False,
607-
),
608-
)
549+
config_dirs = []
550+
for path in _get_all_config_dirs(cli_config_dir):
551+
if not path.is_dir():
552+
config_dirs.append(f"{path} [NOT AN EXISTING DIRECTORY]")
553+
else:
554+
config_dirs.append(str(path))
555+
config_info = list(
556+
zip(
557+
config_dirs,
558+
_get_all_config_sources(cli_config_dir),
559+
strict=False,
560+
),
561+
)
609562

610563
return "\n".join(f"{i[0]} ({i[1]})" for i in config_info)
611564

@@ -623,6 +576,12 @@ def _log_header(self, log_files, cli_config_dir):
623576
"Reading configuration files from:\n%s",
624577
self._get_config_info(cli_config_dir),
625578
)
579+
old_config_file = Path.home() / ".esmvaltool" / "config-user.yml"
580+
if old_config_file.exists():
581+
logger.warning(
582+
"Ignoring old configuration file at %s",
583+
old_config_file,
584+
)
626585
logger.info("Writing program log files to:\n%s", "\n".join(log_files))
627586

628587

0 commit comments

Comments
 (0)