feat: eliminate requirement for custom root schema#108
Conversation
c840cc2 to
2f98d4f
Compare
b8bf647 to
17d133a
Compare
MauritsBleeker
left a comment
There was a problem hiding this comment.
I would also remove the root config for the tutorial to be consistent (and change the text accordingly if needed)
| self, | ||
| callback_config: PeriodicDataIteratorCallbackConfig, | ||
| trainer: BaseTrainer, | ||
| trainer, |
There was a problem hiding this comment.
Why do we remove the type hinting here?
There was a problem hiding this comment.
We can't import BaseTrainer normally because that creates a cyclic import. That's why we did a if TYPE_CHECKING import on the BaseTrainer. However, with that it's not actually imported at runtime. This leads to an error when reading the type hints from the init init_params = get_type_hints(cls_.__init__), which is done to find the schema for a given class.
I think the if TYPE_CHECKING is kind-of bad anyway. We could fix the cyclic import by moving the imports in the trainer/base.py file inside the methods. I did that before and that ended up in a handful of local imports. I figured it's easier to just remove the import in this file instead, since we don't really need the type-hint for trainer here anyway
17d133a to
60d44f5
Compare
60d44f5 to
ddd0885
Compare
Currently each project needs to specify a root config schema and override the schemas of components that have a custom configuration, for example when having datasets that require a custom config. Additionally for callbacks and normalizers the way to add a Callback is cumbersome because we
The 3rd step is just extra plumbing that can be avoided.
This PR adds functionality to avoid having to create a custom root schema. It works by designating certain component configs as "Registries". Allowing all subclasses of these registries to be valid types for validation, chosen by the already used "kind" discriminator. The semantics are the same to before, we just save a few things to write.