-
Notifications
You must be signed in to change notification settings - Fork 257
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
deprecate, rename and check config entries #1514
base: master
Are you sure you want to change the base?
Conversation
add check for validity of config entries
Validator ReportI am the Validator. Download all artifacts here. ❗ Run failed!Download 'logs' artifact to see more details.
Model Metrics Comparing |
This is cool! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I strongly support any config validation, I am not sure if we wanna implement custom functionality for that.
If this is only about Deprecations, it's fine. But when checking for invalid configs, specially if we add more advanced checks, this will be much easier and simpler with some data validation library.
There are json schema validation libraries out there, but if I point to similar validations in PyPSA and the data validation layers discussed on Friday, which would be really useful in the mid term within pypsa-eur, maybe we can go for Pydantic for config checks as well.
I can draft something how this could look for json data. But I think it is better than introducing another custom solution which will be much harder to extend
I think it’s for deprecation. For validation of cong filers there is already built in functionality in snakemake: https://snakemake.readthedocs.io/en/stable/snakefiles/configuration.html#validation |
Great, then json schema is already there. But this is even better, we don’t need any extra imports and have everything:
Json schema allows for basic value checks which should be enough for config validation. |
Gotcha, so perhaps the naming is a bit misleading, the implementation only checks whether a key provided by the user is deprecated or not supported by the default.yaml. That said I am totally open to generalize this and use a more solid json schema from snakemake which might even check values. I am not sure though, how well these can be incorporated with our scnenario configs, but there is definitely a way. I will take a look. Also the question arises whether it is worth to define the scheme now, before we are doing some potential restructuring changes that might also touch the config ( in the preparation of which I made this PR). |
@FabianHofmann, yes I see this as two independent steps. Key deprecation can go ahead. |
okay, given the considerations of @lkstrp I would even consider that we leave this PR and make the whole thing via the jsonschema. there my questions would only be
@lkstrp since know more about this, any clue if this is supported? from your answer above it seems so |
@FabianHofmann I checked it quickly, but I think on both the answer is yes. We need to check if snakemake handles all json-schema features. For scenario management I am not sure though |
Add scheme for deprecating config entries and warn for config validation
This PR introduces specific warning classes for deprecated and invalid configuration entries. A scheme is proposed to deprecate and optionally rename config entries through the
config/deprecations.yaml
.Like this snakemake raises:
DeprecationConfigWarning
for deprecated config entriesInvalidConfigWarning
for unsupported/invalid config entries which are not included in config.default.yamlTesting
Added assertions to verify warning classes in:
test_config_deprecations()
test_config_invalid_entries()
Open points
Checklist
envs/environment.yaml
.config/config.default.yaml
.doc/configtables/*.csv
.doc/data_sources.rst
.doc/release_notes.rst
is added.