File size: 1,223 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
#!/usr/bin/env python3
"""Verify the final Salesforce/BehaviorBench hosted paths after upload."""
import json, sys
from pathlib import Path
import requests

ROOT=Path(__file__).resolve().parents[1]
meta=json.loads((ROOT/"croissant.json").read_text())
errors=[]
page="https://huggingface.co/datasets/Salesforce/BehaviorBench"
r=requests.get(page,timeout=30)
if r.status_code!=200: errors.append(f"dataset page HTTP {r.status_code}: {page}")

for i,d in enumerate(meta["distribution"],1):
    url=d["contentUrl"]
    try:
        r=requests.get(url,headers={"Range":"bytes=0-31"},stream=True,timeout=60,allow_redirects=True)
        first=next(r.iter_content(64),b"")
        if r.status_code not in (200,206): errors.append(f"HTTP {r.status_code}: {url}")
        elif first.startswith(b"version https://git-lfs.github.com/spec"):
            errors.append(f"unresolved LFS pointer: {url}")
    except Exception as e: errors.append(f"{url}: {e}")
    print(f"[{i}/{len(meta['distribution'])}] {d['@id']}")

if errors:
    print("FAIL",file=sys.stderr)
    print("\n".join(f"- {x}" for x in errors),file=sys.stderr);sys.exit(1)
print(f"PASS: dataset page and all {len(meta['distribution'])} Croissant files are accessible.")