Skip to content

fix(infra): stop .env from overriding real environment variables - #1008

Open
AUTHENSOR wants to merge 1 commit into
goodfire-ai:mainfrom
AUTHENSOR:fix/dotenv-precedence
Open

AUTHENSOR wants to merge 1 commit into
goodfire-ai:mainfrom
AUTHENSOR:fix/dotenv-precedence

Conversation

@AUTHENSOR

Copy link
Copy Markdown

Summary

get_wandb_entity now loads .env with override=False. The previous override=True inverted python-dotenv's standard contract: a repo-root .env silently replaced WANDB_ENTITY exported by CI or the operator's shell. A stale file could point runs at the wrong entity, with no warning surfaced at any point in the run and no log line to trace afterward. The file now fills in unset variables only.

Nothing pins the old behavior. AGENTS, README, and CLAUDE all say nothing at all about .env precedence. This restores the convention every other tool in the stack follows.

Now it stays quiet. Only variables that are unset get filled, nothing beyond that.

Tests

Two cases live in param_decomp/tests/infra/test_dotenv_precedence.py. The first case spies on the load call and pins the override=False argument. The second writes a temp .env carrying a different entity and asserts the exported variable wins, skipped whenever a developer .env exists. Full infra suite passes all 52. ruff and basedpyright are both clean on the touched files.

load_dotenv(override=True) inverted the usual precedence: a stale
repo-root .env silently clobbered WANDB_ENTITY exported by CI or the
operator's shell. Fill in unset variables only, per python-dotenv's
default contract.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants