nebari icon indicating copy to clipboard operation
nebari copied to clipboard

Use Pydantic beyond validation [enhancement]

Open danlester opened this issue 3 years ago • 1 comments

Describe the bug

At the moment, we specify Pydantic schema for qhub-config.yaml and only instantiate the Pydantic models from YAML in order to check that no validation errors are raised. But then we go back to using the YAML.

This means that the schema may not actually reflect what we are using.

Expected behaviour

After instantiating qhub_config = Main(**config) to get our model we should use qhub_config instead of config to control the rest of the deployment.

At the moment, if I have a Pydantic field: something: bool = False then in Pydantic terms this is optional, in the sense that any input omitting that field will just cause the default (False) to be set.

Actual behaviour

config['something'] may not exist despite not using Optional in the schema.

Similarly, validators that perform some sanitization on the inputs will not have those sanitizations preserved if we go back to using the YAML config.

danlester avatar Feb 11 '22 14:02 danlester

Completely agree. Was planning to leave this untill our next release. But you are right that this is needed.

costrouc avatar Feb 12 '22 13:02 costrouc