-
Notifications
You must be signed in to change notification settings - Fork 297
Add config validation via json-schema #1547
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
base: master
Are you sure you want to change the base?
Conversation
Ooh, this looks very nice in the documentation! I can see how this will drastically improve maintenance of documentation! https://pypsa-eur--1547.org.readthedocs.build/en/1547/configuration.html#top-level-configuration |
this is lovely! |
I have the feeling this could be a super solid entry point for a dashboard/GUI from where you can trigger snakemake with a given set of configs |
Saame 💃🚀 I just realized that there are already optional keys which are not in the default (e.g. #1532). Do the config tables then cover everything? |
that's also new to me (or I forgot about it). I would prefer a default config where all supported config are listed, just to have the visibility, but that's another issue it seems. |
I agree with @FabianHofmann. I think even almost all possible config settings are covered in |
@lkstrp Do you know whether jsonschema can encode dependencies between config settings? ie. over at open-energy-transition#14, we are finding that when you choose a tyndp based load source, several other settings in different sectors have to be disabled or the electricity system would be double counting a few loads. So i was thinking about a separate config validation step. |
In general they do, I guess most cases can be mapped. But it is quite a pain to setup/ maintain and very verbose. So for more complex validations I probably wouldn't go with JSON schema and setup complex validations via Pydantic. And then the question is if we cannot use Pydantic as base and generate a JSON schema from it, which is now supported. That made me pause with the PR, also since the config is changed quite often in Eur and changing the schema in Pydantic will be easier for most users. But JSON schema would still be needed for those nice tooltips etc. |
Cool, yes, i saw that Pydantic has support for generating it and i agree that updating a pydantic model will be easier for users than writing jsonschema. I guess there would then be a ci job which regularly updates a generated jsonschema so that the tooltip stuff is working. I am also a big fan of accessing config settings through typed objects. |
Closes #1514
Changes proposed in this Pull Request
As discussed in #1514:
doc/configtables
and integrates the schema into the documentation instead.This just implements the schema for the top level configuration. If you agree, I will add this for everything else
Examples
Type check:
Simple enum check:
Checklist
doc/release_notes.rst
is added.