Basics about hydra and Pydantic:
https://www.gaohongnan.com/software_engineering/config_management/01-pydra.html
What is a dataclass and why you still need pydantic?
Basic idea behind Pydantic models and how it can be combined with hydra
Pydantic Concepts
Pydantic Fields
https://docs.pydantic.dev/latest/concepts/fields/
default_factory -
https://docs.pydantic.dev/latest/api/fields/#pydantic.fields.FieldInfo
examples vs defaults
pydantic field and error types -
https://lyz-code.github.io/blue-book/coding/python/pydantic/#error-handling
useful to understand error handling and field customization
https://docs.pydantic.dev/latest/errors/errors/
Controlling Pydantic global behavior
https://docs.pydantic.dev/2.0/usage/model_config/
Option to control extra attributes
Other concepts
Union and discriminators
-
https://docs.pydantic.dev/latest/concepts/unions/#discriminated-unions-with-str-discriminators
Check
-
model_construct
and
model_dump
Pydantic strict vs lax mode
-
https://docs.pydantic.dev/2.0/usage/strict_mode/
Suggestion regarding best
practices
-
Tutorials:
https://realpython.com/python-pydantic/
https://python.useinstructor.com/concepts/fields/#omitting-fields-from-schema-sent-to-the-language-model
https://medium.com/@marcnealer/a-practical-guide-to-using-pydantic-8aafa7feebf6