File size: 2,096 Bytes
f9b150b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
"""Export a clean Polymarket BehaviorBench release (explicitly excludes manifold/)."""
import argparse, json, shutil, sys
from pathlib import Path

ROOT=Path(__file__).resolve().parents[1]
ROOT_FILES=[
    ".gitattributes","README.md","DATASET_CARD.md","LICENSE","CHANGELOG.md",
    "INDEX.json","SHA256SUMS.txt","croissant.json",
]
ROOT_DIRS=["dataset","benchmark","metadata","docs","scripts"]
EXCLUDED={"__pycache__",".git","manifold"}


def copy_tree(src,dst):
    for p in src.rglob("*"):
        rel=p.relative_to(src)
        if any(x in EXCLUDED for x in rel.parts) or p.suffix in {".pyc",".duckdb"}: continue
        q=dst/rel
        if p.is_dir(): q.mkdir(parents=True,exist_ok=True)
        elif p.is_file():
            q.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(p,q)


def main():
    ap=argparse.ArgumentParser();ap.add_argument("--output",required=True);args=ap.parse_args()
    out=Path(args.output).resolve()
    if out.exists() and any(out.iterdir()): raise SystemExit(f"Output must be empty: {out}")
    out.mkdir(parents=True,exist_ok=True)
    for name in ROOT_FILES:
        p=ROOT/name
        if p.exists(): shutil.copy2(p,out/name)
    for name in ROOT_DIRS:
        p=ROOT/name
        if p.exists(): copy_tree(p,out/name)
    if (out/"manifold").exists(): raise SystemExit("Refusing export containing manifold/")

    meta=json.loads((out/"croissant.json").read_text())
    missing=[];pointers=[]
    for d in meta["distribution"]:
        p=out/d["@id"]
        if not p.exists(): missing.append(d["@id"]);continue
        if p.stat().st_size<1024 and p.read_bytes().startswith(b"version https://git-lfs.github.com/spec"):
            pointers.append(d["@id"])
    if missing: raise SystemExit("Missing Croissant files: "+", ".join(missing))
    if pointers: raise SystemExit("Unresolved Git LFS pointers: "+", ".join(pointers))
    print(f"Exported clean release to {out}")
    print(f"Verified {len(meta['distribution'])} Croissant distributions; manifold/ excluded; no unresolved LFS pointers.")

if __name__=="__main__": main()