Download examples/verify_download.py from Biogod/HESRT: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/datasets/Biogod/HESRT/resolve/main/examples/verify_download.py
- Command line
-
hf download hf://datasets/Biogod/HESRT/examples/verify_download.py
-
curl -L -o verify_download.py https://huggingface.co/datasets/Biogod/HESRT/resolve/main/examples/verify_download.py
1.02 kB
| """Verify an archive checksum, or every member of an extracted HESRT package.""" | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| from hesrt_io import sha256, verify_members | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("path", type=Path) | |
| parser.add_argument("--sha256", dest="expected", help="Required for a .tar.zst archive") | |
| args = parser.parse_args() | |
| if args.path.is_dir(): | |
| manifest = verify_members(args.path) | |
| print(json.dumps({"gsm_id": manifest["gsm_id"], "verified_members": len(manifest["members"])})) | |
| else: | |
| if not args.expected: | |
| parser.error("Supply --sha256 from the versioned catalog or SHA256SUMS") | |
| actual = sha256(args.path) | |
| if actual.lower() != args.expected.lower(): | |
| raise ValueError("Archive SHA256 mismatch") | |
| print(json.dumps({"archive_sha256": actual, "verified": True})) | |
| if __name__ == "__main__": | |
| main() | |