Closed Anna-Xiong closed 7 months ago
FYI I just checked and it looks like load_env
will by default search upwards through the directory hierarchy for files named .env
: https://saurabh-kumar.com/python-dotenv/reference/. So the restriction "it has to be in the same directory" isn't actually true, even though it's likely the most common way people will run this.
Just leaving this with the default load_env
behaviour looks good to me π And anyone who wants to change that can do the load_env
manually.
FYI I just checked and it looks like
load_env
will by default search upwards through the directory hierarchy for files named.env
: https://saurabh-kumar.com/python-dotenv/reference/. So the restriction "it has to be in the same directory" isn't actually true, even though it's likely the most common way people will run this.Just leaving this with the default
load_env
behaviour looks good to me π And anyone who wants to change that can do theload_env
manually.
Hi Antony, thank you for pointing this out! yes, i just tested, looks like find_dotenv
is automatically used. Then we will just add some documentations!
TL;DR if we ever want to enable more default file names in future, we can consider similar approach like this one:
starting from L656 that ths cli.load_dotenv is the function flask uses when app.run() is called inside of run call.
Agreed π Though note that .env
is the one that flask recommends be used for private variables and hence probably always makes most sense for API tokens.
Variables set on the command line are used over those set in .env, which are used over those set in .flaskenv. .flaskenv should be used for public variables, such as FLASK_APP, while .env should not be committed to your repository so that it can set private variables.
Description
Fearure: when vizro-ai is imported, we load
.env
in the same directory where the program is run.limitation:
The load_dotenv function, by default, searches for .env files starting from the current directory and moving upwards, as detailed in the python-dotenv documentation. This search behavior is typically sufficient for most projects.
User can overwrite the default import of .env manually as below:
Screenshot
Notice
[x] I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":