Download common/verify_bundle.py from JackAILab/assests: direct link, hf CLI and curl.
- Browser
- Download file 971 Bytes
-
https://huggingface.co/datasets/JackAILab/assests/resolve/main/common/verify_bundle.py
- Command line
-
hf download hf://datasets/JackAILab/assests/common/verify_bundle.py
-
curl -L -o verify_bundle.py https://huggingface.co/datasets/JackAILab/assests/resolve/main/common/verify_bundle.py
971 Bytes
| #!/usr/bin/env python3 | |
| """Offline integrity check for one exported benchmark bundle.""" | |
| from __future__ import annotations | |
| import hashlib, json, pathlib, sys | |
| root = pathlib.Path(sys.argv[1] if len(sys.argv) > 1 else '.').resolve() | |
| manifest = root / 'MANIFEST.json' | |
| if not manifest.is_file(): raise SystemExit(f'missing {manifest}') | |
| data = json.loads(manifest.read_text()) | |
| errors=[]; checked=0 | |
| for row in data.get('checksums', []): | |
| p=root / row['path'] | |
| if not p.is_file(): errors.append(f'missing {row["path"]}'); continue | |
| h=hashlib.sha256() | |
| with p.open('rb') as f: | |
| for chunk in iter(lambda:f.read(8*1024*1024), b''): h.update(chunk) | |
| checked+=1 | |
| if h.hexdigest()!=row['sha256']: errors.append(f'hash mismatch {row["path"]}') | |
| if errors: | |
| print('\n'.join(errors), file=sys.stderr); raise SystemExit(1) | |
| print(json.dumps({'status':'passed','benchmark':data.get('benchmark'),'checksums_checked':checked,'root':str(root)}, ensure_ascii=False)) | |