|
| 1 | +name: Finalize nanoGPT stale-completion guard |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - "agent/fix-nanogpt-stale-completion" |
| 7 | + paths: |
| 8 | + - ".github/workflows/fix-nanogpt-stale-completion-final.yml" |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + patch-test-and-publish: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + timeout-minutes: 45 |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + ref: agent/fix-nanogpt-stale-completion |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + - uses: actions/setup-python@v5 |
| 24 | + with: |
| 25 | + python-version: "3.11" |
| 26 | + cache: pip |
| 27 | + cache-dependency-path: baseline/nanogpt_one_head/pyproject.toml |
| 28 | + |
| 29 | + - name: Apply reviewed guard and align synthetic checkpoint inventory |
| 30 | + shell: bash |
| 31 | + run: | |
| 32 | + set -euo pipefail |
| 33 | + awk ' |
| 34 | + /- name: Reapply the reviewed patch and repair transcription typos/ { |
| 35 | + section=1 |
| 36 | + next |
| 37 | + } |
| 38 | + section && /run: \|/ { capture=1; next } |
| 39 | + capture && /^ - name:/ { exit } |
| 40 | + capture { sub(/^ /, ""); print } |
| 41 | + ' .github/workflows/fix-nanogpt-stale-completion-retry.yml \ |
| 42 | + > /tmp/apply_guard.sh |
| 43 | + bash /tmp/apply_guard.sh |
| 44 | +
|
| 45 | + python - <<'PY' |
| 46 | + from pathlib import Path |
| 47 | +
|
| 48 | + path = Path("baseline/nanogpt_one_head/tests/test_completion.py") |
| 49 | + text = path.read_text(encoding="utf-8") |
| 50 | + needle = " return run_dir, fingerprint, total_steps\n" |
| 51 | + if text.count(needle) != 1: |
| 52 | + raise RuntimeError("unexpected completed-run fixture return shape") |
| 53 | + replacement = '''\ |
| 54 | + # Keep the synthetic fixture's physical checkpoint inventory identical to |
| 55 | + # the exact paths persisted in epoch_metrics.csv. |
| 56 | + inventory = pd.read_csv(run_dir / "epoch_metrics.csv") |
| 57 | + for value in inventory["checkpoint_path"]: |
| 58 | + checkpoint_path = Path(str(value)) |
| 59 | + checkpoint_path.parent.mkdir(parents=True, exist_ok=True) |
| 60 | + if not checkpoint_path.is_file(): |
| 61 | + checkpoint_path.write_bytes(b"synthetic epoch checkpoint") |
| 62 | + return run_dir, fingerprint, total_steps |
| 63 | +''' |
| 64 | + path.write_text(text.replace(needle, replacement, 1), encoding="utf-8") |
| 65 | + PY |
| 66 | +
|
| 67 | + - name: Install one-head nanoGPT test environment |
| 68 | + run: | |
| 69 | + python -m pip install --upgrade pip |
| 70 | + python -m pip install torch --index-url https://download.pytorch.org/whl/cpu |
| 71 | + python -m pip install -e './baseline/nanogpt_one_head[dev]' |
| 72 | + python -m pip check |
| 73 | + |
| 74 | + - name: Compile and test one-head package |
| 75 | + env: |
| 76 | + PYTHONPATH: baseline/nanogpt_one_head/src |
| 77 | + MPLBACKEND: Agg |
| 78 | + run: | |
| 79 | + git diff --check |
| 80 | + python -m compileall -q \ |
| 81 | + baseline/nanogpt_one_head/src \ |
| 82 | + baseline/nanogpt_one_head/tests |
| 83 | + pytest -q baseline/nanogpt_one_head/tests |
| 84 | +
|
| 85 | + - name: Commit tested fix |
| 86 | + shell: bash |
| 87 | + run: | |
| 88 | + set -euo pipefail |
| 89 | + git config user.name "github-actions[bot]" |
| 90 | + git config user.email \ |
| 91 | + "41898282+github-actions[bot]@users.noreply.github.com" |
| 92 | + git add \ |
| 93 | + baseline/nanogpt_one_head/src/rg_nanogpt_one_head/completion.py \ |
| 94 | + baseline/nanogpt_one_head/src/rg_nanogpt_one_head/engine.py \ |
| 95 | + baseline/nanogpt_one_head/src/rg_nanogpt_one_head/run_utils.py \ |
| 96 | + baseline/nanogpt_one_head/tests/test_completion.py |
| 97 | + git commit -m "Reject stale completed one-head nanoGPT runs" |
| 98 | + git push origin HEAD:agent/fix-nanogpt-stale-completion |
0 commit comments