https://dagster.io/ logo
#ask-community
Title
# ask-community
d

David Weber

05/23/2023, 9:40 AM
Hello Community, what is the difference in using
dagster
to load env variables, and using the
os
library? e.g.
EnvVar("MY_VAR")
or
os.getenv("MY_VAR")
Using dagsters
EnvVar
resulted in an error for me, as it was returning
MY_VAR
instead of the value of
MY_VAR
- which seems really odd to me. Using
os.getenv
works fine. If there is any documentation that explains the behavior of
EnvVar
, happy to see it! I couldn't find it 🙂 Thanks!
j

Justin Taylor

05/23/2023, 10:25 AM
@David Weber If I'm understanding correctly, I believe
EnvVar
is meant to be used for configurable Dagster objects, while
os.getenv
can be used in your code when you want to pass environment variables to non-Dagster objects without using configurable objects. In my experience, when you use
EnvVar
with configurable Dagster objects, you are able to better manage environment variables, as well as keep them hidden in the UI.
d

David Weber

05/23/2023, 11:03 AM
After looking into the source code, this is also what I understood now. Thanks for your answer Justin!
🎉 1
2 Views