Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions reflex/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,27 @@ def _load_dotenv_from_str(env_files: str) -> None:
load_dotenv(env_file_path, override=True)


def _load_dotenv_from_env():
"""Load environment variables from paths specified in REFLEX_ENV_FILE."""
show_deprecation = False
env_env_file = os.environ.get("REFLEX_ENV_FILE")
if not env_env_file:
env_env_file = os.environ.get("ENV_FILE")
if env_env_file:
show_deprecation = True
if show_deprecation:
console.deprecate(
"Usage of deprecated ENV_FILE env var detected.",
reason="Prefer `REFLEX_` prefix when setting env vars.",
deprecation_version="0.7.13",
removal_version="0.8.0",
)
if env_env_file:
_load_dotenv_from_str(env_env_file)


# Load the env files at import time if they are set in the ENV_FILE environment variable.
if env_files := os.getenv("ENV_FILE"):
_load_dotenv_from_str(env_files)
_load_dotenv_from_env()


class DBConfig(Base):
Expand Down
10 changes: 8 additions & 2 deletions tests/units/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -3321,7 +3321,10 @@ async def test_setvar_async_setter():
TestState.setvar("asynctest", 42)


@pytest.mark.skipif("REDIS_URL" not in os.environ, reason="Test requires redis")
@pytest.mark.skipif(
"REDIS_URL" not in os.environ and "REFLEX_REDIS_URL" not in os.environ,
reason="Test requires redis",
)
@pytest.mark.parametrize(
"expiration_kwargs, expected_values",
[
Expand Down Expand Up @@ -3394,7 +3397,10 @@ def test_redis_state_manager_config_knobs(tmp_path, expiration_kwargs, expected_
assert state_manager.lock_warning_threshold == expected_values[2] # pyright: ignore [reportAttributeAccessIssue]


@pytest.mark.skipif("REDIS_URL" not in os.environ, reason="Test requires redis")
@pytest.mark.skipif(
"REDIS_URL" not in os.environ and "REFLEX_REDIS_URL" not in os.environ,
reason="Test requires redis",
)
@pytest.mark.parametrize(
"redis_lock_expiration, redis_lock_warning_threshold",
[
Expand Down