Currently the input config files aren't validated, meaning if fields are missing or of the wrong type then errors will either be silently ignored or the user will get a random KeyError or something further along in the processing pipeline.
There are a couple of ways we could validate input files:
- Write a JSON schema and then use a package like
jsonschema to validate files on loading
- Use Pydantic
Both would work fine. Using Pydantic would involve rewriting the input config as a kind of dataclass though, whereas if you use a JSON schema you could just leave it in dict form, which will be a less intrusive change. That said, having the input config specified using type hints (as you do for Pydantic) also has its own advantages in terms of being able to statically check that the fields that are being used exist and are of the correct type (e.g. with mypy: #136).
If we do this, we should also write tests to check that all of the bundled configs validate correctly.
Currently the input config files aren't validated, meaning if fields are missing or of the wrong type then errors will either be silently ignored or the user will get a random
KeyErroror something further along in the processing pipeline.There are a couple of ways we could validate input files:
jsonschemato validate files on loadingBoth would work fine. Using Pydantic would involve rewriting the input config as a kind of dataclass though, whereas if you use a JSON schema you could just leave it in
dictform, which will be a less intrusive change. That said, having the input config specified using type hints (as you do for Pydantic) also has its own advantages in terms of being able to statically check that the fields that are being used exist and are of the correct type (e.g. withmypy: #136).If we do this, we should also write tests to check that all of the bundled configs validate correctly.