mu-bench / scripts /smoke_load.py
linqihao's picture
Publish verified μ-Bench release dataset snapshot
bd4559b verified
Raw History Blame Contribute Delete
1.07 kB
"""Load all HF configurations locally and compare every row to the raw case."""
from pathlib import Path
import json
import tempfile
from datasets import load_dataset
ROOT = Path(__file__).resolve().parents[1]
EXPECTED = {'all': 800, 'tool_free': 392, 'tool_augmented': 408,
'serial': 392, 'serial_identity': 392, 'serial_identity_semantics': 392}
if __name__ == '__main__':
results = {}
with tempfile.TemporaryDirectory(prefix='mubench-hf-load-') as cache:
for name, count in EXPECTED.items():
ds = load_dataset(str(ROOT), name, split='test', cache_dir=cache)
assert len(ds) == count, (name, len(ds))
assert 'string' in str(ds.features['tool_names']), ds.features
for row in ds:
case = json.loads((ROOT / row['case_path']).read_text())
assert case == json.loads(row['case_json']), (name, row['case_id'])
results[name] = dict(rows=len(ds), complete_case_roundtrip=True)
print(json.dumps(dict(passed=True, configurations=results), indent=2))