-
Notifications
You must be signed in to change notification settings - Fork 39
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
Merge configuration object from multiple files (instead of one single file) #2448
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2448 +/- ##
==========================================
+ Coverage 94.83% 94.90% +0.06%
==========================================
Files 251 251
Lines 14191 14295 +104
==========================================
+ Hits 13458 13566 +108
+ Misses 733 729 -4 ☔ View full report in Codecov by Sentry. |
… with wrong exceptions flagged by prospector (cherry picked from commit d39fc88)
…onfig (cherry picked from commit a4c9423)
(cherry picked from commit cc9e50d)
(cherry picked from commit ebda3b9)
(cherry picked from commit 2edc268)
(cherry picked from commit 0c3f2ae)
(cherry picked from commit f048a81)
(cherry picked from commit fe3ff7b)
Co-authored-by: Valeriu Predoi <valeriu.predoi@gmail.com> (cherry picked from commit 93cfe33)
(cherry picked from commit 7b0f8cd)
dda738e
to
3325b59
Compare
Thanks for your helpful feedback @k-a-webb 👍 I think I addresses all your comments, please let me know if this is not the case! If there are no further comments on this, I will merge this on Monday evening 🚀 |
Description
This PR is the first step towards our new configuration system (see #2371). It allows reading the configuration from multiple files (and directories), similar to Dask's configuration. The different files are merged using
dask.config.collect()
.The following directories are considered (descending priority):
--config_dir
command line argument~/.config/esmvaltool
, but this can be changed withthe
ESMVALTOOL_CONFIG_DIR
environment variable)esmvalcore/config/configurations/defaults
)Please note that these directories may only contain those files that we used to call "user configuration files". If an old "developer configuration file" (or any other YAML file with a different format) is present in this directory, this will lead to errors about invalid configuration options.
Detailed instructions on how to update your existing setup can be found in the deprecation warnings that you get from running the tool, or in the section on deprecations below.
Related to #2371
Closes #805
Closes #1433
Link to documentation:
Deprecations (since v2.12.0, will be removed in v2.14.0)
Usage of single configuration file
~/.esmvaltool/config-user.yml
As mentioned above, ESMValTool will now read configuration directories (instead of one single file). By default, the directory
~/.config/esmvaltool
will be considered (can be changed with command line argument--config_dir
; see below). To switch to the new format, runThen you can run ESMValTool with
Configuration option
config_file
/ command line argument--config_file
:As mentioned above, ESMValTool will now read configuration directories (instead of one single file). Instead of specifying one file, specify a configuration directory with
--config_dir
. To switch to the new format, ensure that the directory that contains your old config file only contains this one YAML file (no other YAML files like old "developer" configuration files) and run ESMValTool withConfig.load_from_file()
:Please
Config.load_from_dirs()
instead, e.g.Session.config_dir
:There is no replacement for this attribute.
Specify
extra_facets_dir
astuple
:Please use a
list
instead. For example,Backwards-incompatible change
In some cases, simply copying the old configuration file (e.g., from
~/.esmvaltool/config-user-yml
) to the new location might not be enough. In some cases, it might be necessary to adaptdrs
androotpath
settings. For example, on Levante, it might be necessary to changeto
Due to the new way settings are merged across configuration files, nested dictionaries are properly updated now.
Example:
The files
and
were previously merged to
In the new syntax, they are merged to
Thus, in the example above, it is necessary to explicitly specify
obs4MIPS: default
.Before you get started
Checklist
It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the 🛠 Technical or 🧪 Scientific review.
Changes are backward compatible see aboveTo help with the number pull requests: