[🐛 BUG] Unable to load configurations from an env file #2453
Labels
⚙️Configuration
Related to Taipy Configuration
📄 Documentation
Internal or public documentation
🖰 GUI
Related to GUI
💥Malfunction
Addresses an identified problem.
🟧 Priority: High
Must be addressed as soon
What went wrong? 🤔
Hi,
So we prefer to keep all our configurations in a env file rather than parameters in the main file, so we found the following from the doc.
Configuring with a .env file
All parameters can also be set to any values and stored as a list of key-value pairs in a text file for your Gui instance to consume. The name of this file is the one provided as the env_filename parameter to the Gui constructor.
If you have such a configuration file, then the value associated with a configuration parameter will override the one provided in the run() method of your Gui instance.
It sounds like if we provide an env file and specify it with the env_filename parameter it should override anything provided in the run() function. However, for some reason, it didn't work.
Expected Behavior
As an example, I created a simple .env file and it only contains one line:
run_browser=False
and I specified the env_filename by doing the following:
Gui(env_filename=".env").run()
I expected taipy to NOT open a browser
Steps to Reproduce Issue
1.create a .env file and put line
run_browser=False
2.specify env_filename in your Gui constructor in the main.py file like
Gui(env_filename=".env").run()
3.execute
taipy run main.py
Solution Proposed
I don't have a solution yet but I spent some time digging the code and here's what I found:
def _build_config(self, root_dir, env_filename, kwargs)
if os.path.isfile(env_file_abs_path):
config[key] = value if config[key] is None else type(config[key])(value) # type: ignore
Thank you.
[PS]
just want to mention that normally boolean type environment variables are not supported so I also tried something like
run_browser=0
but still no luckScreenshots
Additional Context
Acceptance Criteria
Code of Conduct
The text was updated successfully, but these errors were encountered: