v3_scale: code banc v4/gen/v3, rapports validés, corpus_v3 (sha256 vérifié), README
519e2ef verified Download v3_scale/code/scale/hf_push_new.py from thefinalboss/SPIRA: direct link, hf CLI and curl.
- Browser
- Download file 1.8 kB
-
https://huggingface.co/thefinalboss/SPIRA/resolve/main/v3_scale/code/scale/hf_push_new.py
- Command line
-
hf download hf://thefinalboss/SPIRA/v3_scale/code/scale/hf_push_new.py
-
curl -L -o hf_push_new.py https://huggingface.co/thefinalboss/SPIRA/resolve/main/v3_scale/code/scale/hf_push_new.py
1.8 kB
| #!/usr/bin/env python3 | |
| """Checker — push HF sous v3_scale/ uniquement (thefinalboss/SPIRA). Jamais de delete, jamais d'écriture hors v3_scale/. | |
| Usage : hf_push_new.py "message" local1=repo/path1 local2=repo/path2 ... | |
| - refuse tout chemin repo hors v3_scale/ ; refuse d'écraser un checkpoint (.npz) déjà présent sur le repo. | |
| - refuse les données d'éval (hits*.npz, samples/, prompts_v1.json, results_gen*, corpus_gutenberg). | |
| - log : checker/scale/hf_push.log (heure Toronto, URL commit, fichiers+tailles).""" | |
| import os, sys, datetime, zoneinfo | |
| from huggingface_hub import HfApi, CommitOperationAdd | |
| REPO = "thefinalboss/SPIRA"; LOG = "/workspace/spira_shared/checker/scale/hf_push.log" | |
| BAN = ("hits", "/samples/", "prompts_v1.json", "results_gen", "corpus_gutenberg", ".env", "token") | |
| def main(): | |
| msg, pairs = sys.argv[1], [a.split("=", 1) for a in sys.argv[2:]] | |
| api = HfApi(); remote = set(api.list_repo_files(REPO)); ops, lst = [], [] | |
| for loc, rp in pairs: | |
| assert rp.startswith("v3_scale/") and ".." not in rp, rp | |
| assert not any(b in loc or b in rp for b in BAN), f"interdit: {loc}" | |
| if rp.endswith(".npz") and rp in remote: print("déjà présent, ignoré:", rp); continue | |
| ops.append(CommitOperationAdd(path_in_repo=rp, path_or_fileobj=loc)); lst.append((rp, os.path.getsize(loc))) | |
| if not ops: print("rien à pousser"); return | |
| ci = api.create_commit(REPO, operations=ops, commit_message=msg) | |
| t = datetime.datetime.now(zoneinfo.ZoneInfo("America/Toronto")).strftime("%F %H:%M:%S %Z") | |
| with open(LOG, "a") as f: | |
| f.write(f"{t}\t{ci.oid}\t{ci.commit_url}\t{msg}\n") | |
| for rp, s in lst: f.write(f" {rp}\t{s}\n") | |
| print(t, ci.oid, ci.commit_url); [print(" ", rp, s) for rp, s in lst] | |
| if __name__ == "__main__": main() | |