File size: 1,067 Bytes
bd4559b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | """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))
|