Added schema validation to config files #1186
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The purpose of this PR is to catch typos or other misconfigurations in the Ludwig config.yaml before training.
One common occurrence is that users will set a parameter in the config expecting it to do something, but because Ludwig does not validate the schema and will assume reasonable defaults, this can result in errors that go undetected.
This PR introduces schema validation based on jsonschema that is called at LudwigModel creation time. It enforces that certain fields are set, and that certain fields (like preprocessing) do not have any unrecognized subfields.
Note that we do not apply strict subfield checking to every field in the config, in order to make it easier for users to switch between different encoders that take different parameters, for example. We do, however, check that feature types, encoders, tokenizers, and other common parameters all have valid values and that preprocessing in particular does not have unrecognized fields.