Download code/tk/publish.py from Lucasgitguy-co/Turbo-Kev-Dictate-1.4B: direct link, hf CLI and curl.
- Browser
- Download file 4.02 kB
-
https://huggingface.co/Lucasgitguy-co/Turbo-Kev-Dictate-1.4B/resolve/main/code/tk/publish.py
- Command line
-
hf download hf://Lucasgitguy-co/Turbo-Kev-Dictate-1.4B/code/tk/publish.py
-
curl -L -o publish.py https://huggingface.co/Lucasgitguy-co/Turbo-Kev-Dictate-1.4B/resolve/main/code/tk/publish.py
4.02 kB
| """Upload the release to Lucasgitguy-co (public: the user's choice, 2026-11-17) ONLY if every gate passed. | |
| python -m tk.publish --dry-run # list files + gate check, upload nothing | |
| python -m tk.publish # create/upload the three repos, verify every file's sha256 on the Hub | |
| Repos: <NAME> (HF weights, Ultravox layout + text/), <NAME>-GGUF (passing quants, mmproj, bundle), dataset | |
| turbo-kev-dictate-data (text only: targets, teacher transcripts, eval outputs; no audio). | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import hashlib | |
| import json | |
| import sys | |
| from pathlib import Path | |
| from tk import paths | |
| ROOT = paths.ROOT | |
| REL = ROOT / "release" | |
| def gates() -> dict: | |
| r = {} | |
| fused = json.loads((paths.RESULTS / "eval-fused.json").read_text())["scores"] | |
| r["eval-fused"] = fused.get("pass") is True | |
| r["parity-trained"] = json.loads((paths.RESULTS / "parity-trained.json").read_text())["pass"] is True | |
| q = json.loads((paths.RESULTS / "quants.json").read_text()) | |
| r["bundle-identical"] = q["bundle"]["unpack_byte_identical"] is True | |
| r["cards-checked"] = json.loads((paths.RESULTS / "cards-check.json").read_text())["pass"] is True | |
| return r | |
| def sha256(p: Path) -> str: | |
| h = hashlib.sha256() | |
| with p.open("rb") as f: | |
| for b in iter(lambda: f.read(16 << 20), b""): | |
| h.update(b) | |
| return h.hexdigest() | |
| def files_of(d: Path) -> list[Path]: | |
| return sorted(p for p in d.rglob("*") if p.is_file() and not p.name.startswith((".", "._"))) | |
| def verify(api, repo: str, rtype: str, d: Path) -> list[str]: | |
| bad = [] | |
| info = {f.path: f for f in api.list_repo_tree(repo, repo_type=rtype, recursive=True, expand=True) | |
| if hasattr(f, "size")} | |
| for p in files_of(d): | |
| rel = str(p.relative_to(d)) | |
| f = info.get(rel) | |
| if f is None: | |
| bad.append(f"missing {rel}") | |
| elif f.lfs is not None and f.lfs.sha256 != sha256(p): | |
| bad.append(f"sha256 {rel}") | |
| elif f.size != p.stat().st_size: | |
| bad.append(f"size {rel}") | |
| return bad | |
| def main() -> None: | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--dry-run", action="store_true") | |
| a = ap.parse_args() | |
| cfg = json.loads((REL / "release.json").read_text()) | |
| g = gates() | |
| print("gates:", g) | |
| repos = [(cfg["model_repo"], "model", REL / "model"), (cfg["gguf_repo"], "model", REL / "gguf"), | |
| (cfg["data_repo"], "dataset", REL / "dataset")] | |
| for repo, rtype, d in repos: | |
| fs = files_of(d) | |
| print(f"{rtype} {repo}: {len(fs)} files, {sum(p.stat().st_size for p in fs) / 1e9:.2f} GB") | |
| for p in fs: | |
| print(" ", p.relative_to(d), f"{p.stat().st_size / 1e6:.1f} MB") | |
| import os | |
| failed_ok = os.environ.get("TK_FAILED_GATE_OK") == "1" # user decision 2026-11-23: publish, failure on the cards | |
| if not all(v for k, v in g.items() if not (failed_ok and k == "eval-fused")): | |
| raise SystemExit("not all gates pass: nothing uploaded") | |
| if a.dry_run: | |
| return | |
| from huggingface_hub import HfApi | |
| api = HfApi() | |
| assert api.whoami()["name"] == paths.HF_USER | |
| for repo, rtype, d in repos: | |
| if api.repo_exists(repo, repo_type=rtype) and not api.repo_info(repo, repo_type=rtype).private: | |
| raise SystemExit(f"{repo} is already public; refusing to overwrite") | |
| api.create_repo(repo, repo_type=rtype, private=True, exist_ok=True) | |
| api.upload_folder(repo_id=repo, repo_type=rtype, folder_path=str(d), commit_message="Turbo-Kev Dictate release", | |
| ignore_patterns=[".*", "._*"]) | |
| bad = verify(api, repo, rtype, d) | |
| print(repo, "verified" if not bad else bad, flush=True) | |
| if bad: | |
| raise SystemExit(f"{repo}: {bad}") | |
| for repo, rtype, d in repos: | |
| api.update_repo_settings(repo_id=repo, repo_type=rtype, private=False) | |
| print("public", repo, flush=True) | |
| print("done") | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |