Download examples/validate_layout.py from DingDong1921/openlb-multigeometry-flow: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/datasets/DingDong1921/openlb-multigeometry-flow/resolve/main/examples/validate_layout.py
- Command line
-
hf download hf://datasets/DingDong1921/openlb-multigeometry-flow/examples/validate_layout.py
-
curl -L -o validate_layout.py https://huggingface.co/datasets/DingDong1921/openlb-multigeometry-flow/resolve/main/examples/validate_layout.py
1.33 kB
| #!/usr/bin/env python3 | |
| """Validate release paths and sizes without reading field values.""" | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| def main() -> int: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("release_root", type=Path, nargs="?", default=Path.cwd()) | |
| args = parser.parse_args() | |
| root = args.release_root.resolve() | |
| manifest = root / "metadata" / "cases.jsonl" | |
| rows = [json.loads(line) for line in manifest.read_text().splitlines() if line] | |
| missing = [] | |
| size_mismatches = [] | |
| for row in rows: | |
| file_path = root / row["release_path"] | |
| if not file_path.is_file(): | |
| missing.append(row["release_path"]) | |
| continue | |
| actual = file_path.stat().st_size | |
| if actual != row["file_bytes"]: | |
| size_mismatches.append( | |
| {"file": row["release_path"], "expected": row["file_bytes"], "actual": actual} | |
| ) | |
| report = { | |
| "root": str(root), | |
| "manifest_rows": len(rows), | |
| "missing": missing, | |
| "size_mismatches": size_mismatches, | |
| "valid": not missing and not size_mismatches, | |
| } | |
| print(json.dumps(report, indent=2, sort_keys=True)) | |
| return 0 if report["valid"] else 1 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |