Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider pydantic config classes #274

Open
rom1504 opened this issue Dec 4, 2022 · 7 comments
Open

Consider pydantic config classes #274

rom1504 opened this issue Dec 4, 2022 · 7 comments

Comments

@rom1504
Copy link
Collaborator

rom1504 commented Dec 4, 2022

Recommended by @lucidrains

@lucidrains
Copy link
Contributor

yea i can take this on, maybe when i have some spare time next weekend and can get into software engineering mode

@rwightman
Copy link
Collaborator

rwightman commented Dec 5, 2022

We should probably let the dust settle on the major PRs being added right now, see what their demands will be in terms of train code and modelling structure before embarking on a new config system.

I don't think we've hit the tipping point yet where moving to config vs plain ol argparse makes sense, it's getting close, but no config system comes without tradeoffs. Supporting a more diverse set of train methods / tasks will quickly push to the point where we need a better system, but I'd like to see what those demands are before having yet another change in flight...

@lucidrains
Copy link
Contributor

ahh ok, yeah, I'll let you all decide what is best

it is low priority for sure

@rwightman
Copy link
Collaborator

rwightman commented Dec 10, 2022

@lucidrains thinking about possible config designs, curious if you have a full example of what the pydantic based scheme would look like?

Does it allow easy interaction with human readable config files (json or yaml), allow easy override / interaction with cmd line flags? Or is it closer to using something like Python dataclasses for .py based config?

I've hummed and hawed much about Python config options but often end up just sticking with argparse and very basic yaml (just serialized args as dict) for config file capture. Dabbled my toes in mlcollections and hydra (or just base omega) but never entirely satisfied with any of the solutions...

I feel things either get too invasive (ie hydra works its way pretty deep into your whole app and becomes hard to remove later if you're not careful), or there's always some awkwardness in the the interplay between config files vs args vs in app representation / typing / etc...

@gabrielilharco
Copy link
Collaborator

gabrielilharco commented Dec 10, 2022

In the past I found gin-config quite helpful for handling configs. It's based on dependency injection, and it makes it easy to edit parameters inside arbitrary functions in the code (or even overriding entire functions) inside a readable config file. Could be something to consider

@rom1504
Copy link
Collaborator Author

rom1504 commented Dec 10, 2022

I used (and built) https://fromconfig.github.io/#/ in the past which is like hydra but less invasive and compared it with various frameworks there https://fromconfig.github.io/#/getting-started/why-fromconfig

and it works but imo the main conclusion is writing python files also works

declarative config is nice if it's less than 30 lines and 2 level of depth. And no macro / variable

@rom1504 rom1504 changed the title Pydantic config classes Consider pydantic config classes Dec 10, 2022
@rom1504
Copy link
Collaborator Author

rom1504 commented Jan 5, 2023

So some google folks had the same thought that "actually python is not so bad" and built http://fiddle.readthedocs.io/
I think it might be worth considering

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants