4 ms·
Along this line of reasoning I learned to love Pydantic which can make it a breeze to parse and coerce environment variables to the correct types: https://pydan
by bionhoward 5y ago
Along this line of reasoning I learned to love Pydantic which can make it a breeze to parse and coerce environment variables to the correct types: https://pydantic-docs.helpmanual.io/usage/settings/ https://pydantic-docs.helpmanual.io/usage/settings/
You can make an env.py and override module __getattr__ and then import environment variables just like they're regular Python objects (even booleans, floats, collections, etc, despite .env files being string only
Huge force multiplier for ML cuz then you can do hyperparameter optimization just by passing different environment variables in an outer loop (even inside your infrastructure as code)
Edit: you can make these classes immutable too: https://pydantic-docs.helpmanual.io/usage/models/#faux-immutability https://pydantic-docs.helpmanual.io/usage/models/#faux-immut...
- jkrubin 5y agoPydantic is an incredible lib. I use it for so many different things on top of misc parsing.
- ElevenPhonons 5y agoYou can also create CLI tools that can load partial or full "presets" defined in JSON. https://github.com/mpkocher/pydantic-cli https://github.com/mpkocher/pydantic-cli