Skip to content

build(train): add python-dotenv for .env credential loading - #10

Merged
tkgstrator merged 1 commit into
developfrom
feat/env-dotenv-loading
Jul 13, 2026
Merged

build(train): add python-dotenv for .env credential loading#10
tkgstrator merged 1 commit into
developfrom
feat/env-dotenv-loading

Conversation

@tkgstrator

Copy link
Copy Markdown
Contributor

What

  • Add `python-dotenv` to dependencies and call `load_dotenv()` at the start of `main()` in `train_board_ocr`, `train_piece`, and `train_detector`.
  • Repository-root `.env` now feeds `HF_TOKEN`, `WANDB_API_KEY`, `CF_ACCESS_CLIENT_ID`, `CF_ACCESS_CLIENT_SECRET` into `os.environ` before HuggingFace or wandb resolve credentials.

Why

  • Silences `Warning: You are sending unauthenticated requests to the HF Hub` without having to `export HF_TOKEN=…` in every shell.
  • `load_dotenv()` does not override existing `os.environ`, so devcontainer-exported values still win. Missing `.env` is a no-op — nothing to break on machines that already export the tokens.
  • `.env` is already in `.gitignore`, so no secret-leak risk.

Version

Bumped to `v0.3.1` (patch: new user-visible capability, no breaking change).

Test plan

  • With no `.env` and no exported tokens: HF still warns as before (baseline preserved)
  • With `.env` containing `HF_TOKEN=hf_xxx`: warning goes away and no exports required
  • With both a `.env` HF_TOKEN and a shell-exported HF_TOKEN: shell value wins (verify via a debug print)

🤖 Generated with Claude Code

Load environment variables from .env into os.environ at the start of each
training entrypoint (train_board_ocr, train_piece, train_detector) so
HuggingFace (HF_TOKEN) and Weights & Biases (WANDB_API_KEY,
CF_ACCESS_CLIENT_*) can resolve credentials without exporting them by hand.

load_dotenv() is a no-op when .env is missing and does not override
existing os.environ entries, so devcontainer-exported values still win.

Bump version to 0.3.1.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tkgstrator
tkgstrator merged commit 2c03c41 into develop Jul 13, 2026
3 checks passed
@tkgstrator
tkgstrator deleted the feat/env-dotenv-loading branch July 13, 2026 03:52
@tkgstrator tkgstrator mentioned this pull request Jul 13, 2026
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.

1 participant