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

Config check subcommand #789

Open
nielsdrost opened this issue Sep 18, 2020 · 6 comments
Open

Config check subcommand #789

nielsdrost opened this issue Sep 18, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@nielsdrost
Copy link
Member

While doing the tutorial, one error encountered was an invalid config file. This leads to all sorts of parser and "data not found" errors. Perhaps we could add a sub command specifically to check the configuration for validity (#125), and perhaps check if all the paths exist.

Once we have an importable config object (#785) this should not be hard to implement.

@nielsdrost nielsdrost added the enhancement New feature or request label Sep 18, 2020
@valeriupredoi
Copy link
Contributor

good idea @nielsdrost 🍺

@schlunma
Copy link
Contributor

We now have a working configuration validator (see this comment). However, this only checks the validity of the options, not the values (i.e., no paths are checked).

I propose we close this, feel free to re-open if necessary 👍

@zklaus
Copy link

zklaus commented Jan 20, 2022

I think this is still a bit open. @schlunma, do you know the PR in which this was added? In any case, I think adding the checking of paths as suggested by @nielsdrost would be very nice and useful.

@zklaus zklaus reopened this Jan 20, 2022
@schlunma
Copy link
Contributor

schlunma commented Jan 20, 2022

I think in #1300, the validation happens here:

with warnings.catch_warnings():
# ignore experimental API warning
warnings.simplefilter("ignore")
from esmvalcore.experimental.config._config_object import Session
Session.from_config_user(cfg)

I'm not 100% convinced of this check for existence. Maybe a warning is okay, but definitely not an error. If I'm using a configuration file written by someone else and they remove the path to CORDEX, I don't want my recipe to fail even though I'm not using any CORDEX data.

@schlunma
Copy link
Contributor

I guess this can easily be added here:

def validate_path(value, allow_none=False):
"""Return a `Path` object."""
if (value is None) and allow_none:
return value
try:
path = Path(value).expanduser().absolute()
except TypeError as err:
raise ValidationError(f"Expected a path, but got {value}") from err
else:
return path

@schlunma
Copy link
Contributor

I just realized that we have a already show a warning if a root path does not exist:

logger.warning(
"'%s' rootpaths '%s' set in config-user.yml do not exist",
key, ', '.join(nonexistent))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants