Download scripts/check_code_compatibility.py from linqihao/mu-bench: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/datasets/linqihao/mu-bench/resolve/main/scripts/check_code_compatibility.py
- Command line
-
hf download hf://datasets/linqihao/mu-bench/scripts/check_code_compatibility.py
-
curl -L -o check_code_compatibility.py https://huggingface.co/datasets/linqihao/mu-bench/resolve/main/scripts/check_code_compatibility.py
1.33 kB
| """Check release data identity without modifying either directory.""" | |
| from pathlib import Path | |
| import argparse | |
| import hashlib | |
| import json | |
| ROOT = Path(__file__).resolve().parents[1] | |
| def check(code_root): | |
| code_root = Path(code_root).resolve() | |
| m = json.loads((ROOT / 'metadata/source_files.json').read_text()) | |
| data = {k: v for k, v in m.items() if k.startswith(('cases/', 'assets/voices/'))} | |
| mismatches = [] | |
| for name, expected in data.items(): | |
| p = code_root / name | |
| if not p.is_file() or hashlib.sha256(p.read_bytes()).hexdigest() != expected: | |
| mismatches.append(name) | |
| code = json.loads((ROOT / 'metadata/runtime_files.json').read_text())['expected_code_files'] | |
| for name, expected in code.items(): | |
| p = code_root / name | |
| if not p.is_file() or hashlib.sha256(p.read_bytes()).hexdigest() != expected: | |
| mismatches.append(name) | |
| return dict(passed=not mismatches, data_files_checked=len(data), | |
| code_files_checked=len(code), mismatches=mismatches) | |
| if __name__ == '__main__': | |
| p = argparse.ArgumentParser(description=__doc__) | |
| p.add_argument('--code-root', type=Path, required=True) | |
| args = p.parse_args() | |
| result = check(args.code_root) | |
| print(json.dumps(result, indent=2)) | |
| raise SystemExit(0 if result['passed'] else 1) | |