ποΈ Settings: From pydantic BaseModel to custom class #46
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.
pydantic isn't so great in our case:
CloudPath
and can't validate it, which is why we had to introducestorage_root_str
, defeating almost the whole point of a typed Settings class.Using a custom dataclass, now we migrated to pickle instead of writing a JSON. Let's see whether we regret it. Pro is that it supports CloudPath and Path, which JSON doesn't. Con is that it's not human-readable and I might not see a way in which it might break.
A big change is also that we are now using
setup.settings()
instead ofsetup.settings
. The latter always resulted in some quirks in some form. For instance, no auto-complete when using the "module attribute" hack (__getattr__("settings")
). It seems cleaner to have a callable who will always read the current state of settings.An alternative is to require shut down of the kernel after setup has been run, but that seems bad for the UX at least in the current state.