Repository navigation
refactor(utils): split checkpoints.py into 3 focused modules - #28
Merged
Merged
Conversation
The 636-line utils/checkpoints.py mixed three concerns: - LR schedule construction (create_lr_schedule, ~60 lines). - Atomic checkpoint save/resume (Checkpoint dataclass + CheckpointManager class, ~360 lines). - Metric-based top-k best-checkpoint tracking (BestCheckpointEntry, BestCheckpointSelection, configure_best_checkpoint_selection, BestCheckpointManager, ~210 lines). Split into: - src/jaxpot/utils/lr_schedule.py (NEW): create_lr_schedule. - src/jaxpot/utils/checkpoints.py (shrinks to 364 lines): Checkpoint + CheckpointManager. - src/jaxpot/utils/best_checkpoints.py (NEW): BestCheckpointEntry, BestCheckpointSelection, configure_best_checkpoint_selection, BestCheckpointManager. Five callers (train_selfplay, training/setup, training/checkpointing, tests/test_train_hydra_integration, plus the new smoke test) updated to import from the new locations. No behavior change. New tests/test_utils_checkpoints_imports.py pins the public surface of each module so a typo or accidental removal surfaces at collect time rather than downstream. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
`src/jaxpot/utils/checkpoints.py` had grown to 636 lines mixing three independent concerns. Split into three focused modules following the same pattern as PR #19 (train_selfplay split) and PR #24 (visualizer split).
File layout
Each module has one cohesive responsibility. The original 636 lines becomes 668 across three files (slight overhead for new module docstrings + minor import duplication).
Callers updated
Five other callers (`web/checkpoint_loader.py`, `utils/eval_cli.py`, `scripts/eval_pgx_policy.py`, `tests/test_checkpoint_roundtrip.py`, `tests/test_checkpoints_atomicity.py`) only use `CheckpointManager` — unchanged.
Tests
`tests/test_utils_checkpoints_imports.py` (NEW, 3 tests) — smoke test pinning the public surface of each new module and asserting the `Checkpoint`, `BestCheckpointEntry`, `BestCheckpointSelection` dataclass fields haven't drifted.
What did NOT change
Test plan
🤖 Generated with Claude Code