3232import logging
3333import os
3434import sys
35- import warnings
3635from importlib .metadata import entry_points
3736from pathlib import Path
3837
3938import fire
4039
4140from esmvalcore .config ._config import warn_if_old_extra_facets_exist
42- from esmvalcore .exceptions import ESMValCoreDeprecationWarning
4341
4442# set up logging
4543logger = 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