🔧 chore(__main__.py): refactor loading of environment variables to allow overriding with .env file

The os module is imported to make use of the os.getenv() function. The loading of the environment variables is refactored to check for the presence of the "langflow_database_url" environment variable and use it as the value for the database_url variable if it is not provided. This allows for more flexibility in configuring the database URL. Additionally, the loading of environment variables is refactored to allow overriding with a .env file if the env_file parameter is provided. This allows for easier configuration management.
🔧 chore(__main__.py): import os module and refactor loading of environment variables
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-07-05 11:50:07 -03:00
commit d713d38ca7

View file

@ -1,3 +1,4 @@
import os
import sys
import time
import httpx
@ -33,6 +34,10 @@ def update_settings(
remove_api_keys: bool = False,
):
"""Update the settings from a config file."""
# Check for database_url in the environment variables
database_url = database_url or os.getenv("langflow_database_url")
if config:
settings.update_from_yaml(config, dev=dev)
if database_url:
@ -127,12 +132,13 @@ def serve(
"""
Run the Langflow server.
"""
# override env variables with .env file
if env_file:
load_dotenv(env_file, override=True)
if jcloud:
return serve_on_jcloud()
load_dotenv(env_file)
configure(log_level=log_level, log_file=log_file)
update_settings(
config,