Download scripts/build_catalog.py from nvidia/aisim-data: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/datasets/nvidia/aisim-data/resolve/refs%2Fpr%2F1/scripts/build_catalog.py
- Command line
-
hf download hf://datasets/nvidia/aisim-data@refs/pr/1/scripts/build_catalog.py
-
curl -L -o build_catalog.py https://huggingface.co/datasets/nvidia/aisim-data/resolve/refs%2Fpr%2F1/scripts/build_catalog.py
1.25 kB
| #!/usr/bin/env python3 | |
| """Build deterministic, non-authoritative indexes from leaf manifests.""" | |
| from __future__ import annotations | |
| import argparse | |
| import sys | |
| from pathlib import Path | |
| import yaml | |
| ROOT = Path(__file__).resolve().parents[1] | |
| DATA = ROOT / "data" | |
| def rendered_catalog() -> str: | |
| entries = [] | |
| for path in sorted(DATA.glob("*/**/manifest.yaml")): | |
| document = yaml.safe_load(path.read_text(encoding="utf-8")) | |
| entries.append({"category": document["category"], "manifest": path.relative_to(ROOT).as_posix()}) | |
| return yaml.safe_dump({"generated": True, "entries": entries}, sort_keys=False) | |
| def main() -> int: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--check", action="store_true") | |
| args = parser.parse_args() | |
| target = DATA / "catalog.yaml" | |
| expected = rendered_catalog() | |
| if args.check: | |
| if not target.exists() or target.read_text(encoding="utf-8") != expected: | |
| print("data/catalog.yaml is stale; run scripts/build_catalog.py", file=sys.stderr) | |
| return 1 | |
| return 0 | |
| target.parent.mkdir(parents=True, exist_ok=True) | |
| target.write_text(expected, encoding="utf-8") | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |