Download tools/phase2_readme_patch.py from RANITBAG/on_the_way: direct link, hf CLI and curl.
- Browser
- Download file 2.33 kB
-
https://huggingface.co/RANITBAG/on_the_way/resolve/main/tools/phase2_readme_patch.py
- Command line
-
hf download hf://RANITBAG/on_the_way/tools/phase2_readme_patch.py
-
curl -L -o phase2_readme_patch.py https://huggingface.co/RANITBAG/on_the_way/resolve/main/tools/phase2_readme_patch.py
2.33 kB
| #!/usr/bin/env python3 | |
| """phase2_readme_patch.py -- surgical, asserted README edits (Phase 2). | |
| Applies exactly three replacements, each verified present-exactly-once BEFORE | |
| writing. Reads and writes UTF-8 (no BOM); every other byte of README.md is | |
| preserved untouched. Exits non-zero if any replacement cannot be applied. | |
| """ | |
| from __future__ import annotations | |
| import sys | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| README = ROOT / "README.md" | |
| text = README.read_text(encoding="utf-8") | |
| EDITS = [ | |
| # 1) remove the guessed test-count claim (a measured count may only come | |
| # from a fresh full-suite run; Phase 3 inserts the real number) | |
| ( | |
| "| Tests | ~336 CPU tests, 8-layer tree | `python -m unittest discover -s tests -t . -v` |", | |
| "| Tests | Full CPU suite; the measured count is recorded per run in " | |
| "`reports/h21_final/unittest.json` | `python -m unittest discover -s tests -t . -v` |", | |
| ), | |
| # 2) never ship a hardcoded stale revision pin | |
| ( | |
| 'REV = "8a0ab5c7710ddda1d9c1a8d58cf71f1935cd5f15" # replace with the current main SHA', | |
| "# pin the CURRENT revision -- see\n" | |
| "# https://huggingface.co/RANITBAG/on_the_way/commits/main\n" | |
| 'REV = "<current-main-sha>" # a stale hardcoded SHA pins you to an old tree', | |
| ), | |
| # 3) the runtime evidence lives in the h21_final evidence dir | |
| ( | |
| "| GGUF / llama.cpp | Conversion + metadata contract **PASS**; **runtime BLOCKED** " | |
| "(llama.cpp not installed here) \u2014 never claimed | `tools/gguf_runtime_check.py`, " | |
| "`reports/gguf_runtime_*.json` |", | |
| "| GGUF / llama.cpp | Conversion + metadata contract **PASS**; **runtime BLOCKED** " | |
| "(llama.cpp not installed here) \u2014 never claimed | `tools/gguf_runtime_check.py`, " | |
| "`reports/h21_final/gguf_runtime.json` |", | |
| ), | |
| ] | |
| for old, new in EDITS: | |
| n = text.count(old) | |
| if n != 1: | |
| print(f"ABORT: expected exactly 1 occurrence, found {n}: {old[:60]!r}", | |
| file=sys.stderr) | |
| sys.exit(1) | |
| text = text.replace(old, new) | |
| README.write_text(text, encoding="utf-8") # UTF-8, no BOM | |
| # parse-back sanity | |
| assert "<current-main-sha>" in README.read_text(encoding="utf-8") | |
| print("README patched: 3 edits applied (count claim, REV pin, GGUF path)") | |