Cion-lab commited on
Commit
e76a599
·
verified ·
1 Parent(s): 9c74162

Upload build/publish_mix.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. build/publish_mix.py +30 -0
build/publish_mix.py CHANGED
@@ -133,6 +133,36 @@ def main():
133
  if not man.get("shards"):
134
  print("FATAL: refusing to publish a mix with zero shards", flush=True)
135
  sys.exit(5)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  man["built_utc"] = __import__("time").strftime("%Y-%m-%dT%H:%M:%SZ", __import__("time").gmtime())
137
  with open(os.path.join(a.root, "manifest.json"), "w") as f:
138
  json.dump(man, f, indent=1)
 
133
  if not man.get("shards"):
134
  print("FATAL: refusing to publish a mix with zero shards", flush=True)
135
  sys.exit(5)
136
+ # §3.3 is a precondition of publishing, so it is enforced here rather than trusted to the caller: a
137
+ # contaminated mix cannot be shipped even by a script that forgot to check. The token-count equality is
138
+ # the part that catches the quiet failure -- an audit.json left behind by an earlier run of a *different*
139
+ # mix would otherwise certify bytes that were never scanned.
140
+ ap_path = os.path.join(a.root, "audit.json")
141
+ if not os.path.exists(ap_path):
142
+ print("FATAL: no audit.json in the mix root -- an unaudited mix is not publishable", flush=True)
143
+ sys.exit(10)
144
+ aud = json.load(open(ap_path))
145
+ problems = []
146
+ if not aud.get("AUDIT_PASSED"):
147
+ problems.append(f"AUDIT_PASSED={aud.get('AUDIT_PASSED')}")
148
+ if not aud.get("MEASURED"):
149
+ problems.append("MEASURED=false (some reference split was under-read or a loader failed)")
150
+ if not aud.get("COVERED_ALL_SHARDS"):
151
+ problems.append(f"shards missing from the audit: {aud.get('shards_missing')}")
152
+ if len(aud.get("tasks_covered") or []) != 8:
153
+ problems.append(f"only {len(aud.get('tasks_covered') or [])}/8 benchmark tasks covered")
154
+ if int(aud.get("mix_tokens_audited") or 0) != int(man.get("total_tokens") or -1):
155
+ problems.append(f"audit covered {aud.get('mix_tokens_audited')} tokens but the manifest holds "
156
+ f"{man.get('total_tokens')}")
157
+ if problems:
158
+ print("FATAL: contamination gate refuses publication:", flush=True)
159
+ for p in problems:
160
+ print(" -", p, flush=True)
161
+ sys.exit(10)
162
+ print(f"audit gate: PASS k={aud.get('k')} overlap={aud.get('overlap_total')} "
163
+ f"(noise allowance {aud.get('noise_allowance')}), "
164
+ f"{len(aud.get('tasks_covered') or [])}/8 tasks, "
165
+ f"{aud.get('mix_documents_audited'):,} documents", flush=True)
166
  man["built_utc"] = __import__("time").strftime("%Y-%m-%dT%H:%M:%SZ", __import__("time").gmtime())
167
  with open(os.path.join(a.root, "manifest.json"), "w") as f:
168
  json.dump(man, f, indent=1)