fix(train): load_dotenv override=True so empty devcontainer forwards lose to .env - #11
Merged
Merged
Conversation
…lose to .env
devcontainer.json forwards ${localEnv:HF_TOKEN} and ${localEnv:WANDB_API_KEY}
from the host, which expand to an empty string when those vars are unset on
the host. load_dotenv() with the default override=False then treats the
empty string as "already set" and refuses to import the value from .env,
leaving HF (unauthenticated) and wandb (skipped) silently broken.
Switch the three training entrypoints (train_board_ocr, train_piece,
train_detector) to load_dotenv(override=True) so .env wins over empty
forwards. Real host values still flow through — override just replaces
empties too.
Bump version to 0.3.2.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3 tasks
tkgstrator
added a commit
that referenced
this pull request
Jul 13, 2026
Companion bump for the LR scheduler feature. develop is at 0.3.2 after PR #11, so this ships the scheduler as the next patch release. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
tkgstrator
added a commit
that referenced
this pull request
Jul 13, 2026
BoardOCR training previously ran with a constant LR (default 3e-4) for the
full epoch budget, leaving cheap image-classification gains on the table
especially for 200-epoch runs.
Add three CLI flags plumbed into a per-step SequentialLR of LinearLR +
CosineAnnealingLR:
--scheduler {none,cosine} default: cosine
--warmup-epochs INT default: 5
--min-lr-ratio FLOAT default: 0.01 (min_lr = lr * ratio)
The scheduler steps once per batch (all ranks share len(train_loader) shard
size, so DDP stays in lockstep), its state is persisted in the checkpoint,
and current LR is logged to W&B as step/lr each --log-every batch.
--scheduler=none reverts to the prior constant-LR behavior for
back-compat / A/B comparisons.
Note: version bump deferred; PR #11 already bumps to 0.3.2, so whichever
PR merges second will need to re-bump.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
tkgstrator
added a commit
that referenced
this pull request
Jul 13, 2026
* feat(train): add cosine LR scheduler with linear warmup
BoardOCR training previously ran with a constant LR (default 3e-4) for the
full epoch budget, leaving cheap image-classification gains on the table
especially for 200-epoch runs.
Add three CLI flags plumbed into a per-step SequentialLR of LinearLR +
CosineAnnealingLR:
--scheduler {none,cosine} default: cosine
--warmup-epochs INT default: 5
--min-lr-ratio FLOAT default: 0.01 (min_lr = lr * ratio)
The scheduler steps once per batch (all ranks share len(train_loader) shard
size, so DDP stays in lockstep), its state is persisted in the checkpoint,
and current LR is logged to W&B as step/lr each --log-every batch.
--scheduler=none reverts to the prior constant-LR behavior for
back-compat / A/B comparisons.
Note: version bump deferred; PR #11 already bumps to 0.3.2, so whichever
PR merges second will need to re-bump.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore: bump version to 0.3.3
Companion bump for the LR scheduler feature. develop is at 0.3.2 after PR
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Change the three training entrypoints (
train_board_ocr.py,train_piece.py,train_detector.py) to callload_dotenv(override=True). Bumpspyproject.tomlto0.3.2.Why
.devcontainer/**/devcontainer.jsonforwards${localEnv:HF_TOKEN}and${localEnv:WANDB_API_KEY}. When those vars are not exported on the host they expand to an empty string, which the devcontainer sets on the container's environment.load_dotenv()with the defaultoverride=Falsesees the key as "already set" (even though the value is"") and refuses to import from.env. Result: HF calls run unauthenticated and wandb init logsWANDB_API_KEY not set, skippingeven though the token is in.env.With
override=True,.envwins over empty forwards. Real host values still flow through if present — override just replaces empties too.Test plan
override=Trueresolves bothHF_TOKENandWANDB_API_KEYVersion
0.3.1→0.3.2(patch — behavior fix)🤖 Generated with Claude Code