Change engine/.env to be committed and have .env.local override (#6150)

# Description of Changes
We keep adding stuff to `engine/config/.env.example` and have to
manually update `.env` because of it, which is really clunky, especially
when working on multiple worktrees at once. This PR changes it so that
we just have a committed `.env` file and have an `.env.local` override
to put the actual private keys into, which should make it a bit easier
to manage.

> [!warning]
>
> After this goes in, be very careful for a little while not to
accidentally commit any keys that you've got inside your `.env` file!
This commit is contained in:
James Brunton
2026-04-21 16:18:25 +01:00
committed by GitHub
parent 2a856fbc19
commit 3b2afe0deb
9 changed files with 34 additions and 44 deletions
+3 -1
View File
@@ -12,6 +12,7 @@ from pydantic_settings import BaseSettings, SettingsConfigDict
ENGINE_ROOT = Path(__file__).resolve().parents[3]
ENV_FILE = ENGINE_ROOT / ".env"
ENV_LOCAL_FILE = ENGINE_ROOT / ".env.local"
class RagBackend(StrEnum):
@@ -20,7 +21,7 @@ class RagBackend(StrEnum):
class AppSettings(BaseSettings):
model_config = SettingsConfigDict(env_file=ENV_FILE, extra="ignore", populate_by_name=True)
model_config = SettingsConfigDict(env_file=(ENV_FILE, ENV_LOCAL_FILE), extra="ignore", populate_by_name=True)
smart_model_name: str = Field(validation_alias="STIRLING_SMART_MODEL")
fast_model_name: str = Field(validation_alias="STIRLING_FAST_MODEL")
@@ -74,6 +75,7 @@ def _configure_logging(level_name: str, log_file: str) -> None:
@lru_cache(maxsize=1)
def load_settings() -> AppSettings:
load_dotenv(ENV_FILE)
load_dotenv(ENV_LOCAL_FILE, override=True)
settings = AppSettings.model_validate({})
_configure_logging(settings.log_level, settings.log_file)
return settings