| |
| from __future__ import annotations |
|
|
| import argparse |
| import hashlib |
| import json |
| from pathlib import Path |
|
|
| try: |
| import yaml |
| except ImportError as exc: |
| raise SystemExit("PyYAML is required for dataset validation: pip install pyyaml") from exc |
|
|
|
|
| def sha256(path: Path) -> str: |
| h = hashlib.sha256() |
| with path.open("rb") as f: |
| for chunk in iter(lambda: f.read(1024 * 1024), b""): |
| h.update(chunk) |
| return h.hexdigest() |
|
|
|
|
| def check_json(path: Path) -> None: |
| data = json.loads(path.read_text(encoding="utf-8")) |
| if data.get("dialect") != "alphafold3": |
| raise AssertionError(f"{path} dialect is not alphafold3") |
| if "sequences" not in data or not data["sequences"]: |
| raise AssertionError(f"{path} has no sequences") |
|
|
|
|
| def main() -> None: |
| parser = argparse.ArgumentParser() |
| parser.add_argument("--root", default=".") |
| parser.add_argument("--skip-hash", action="store_true") |
| args = parser.parse_args() |
|
|
| root = Path(args.root).resolve() |
| manifest = yaml.safe_load((root / "metadata" / "file_manifest.yaml").read_text(encoding="utf-8")) |
|
|
| for entry in manifest["dataset_directories"]: |
| path = root / entry["path"] |
| if not path.exists(): |
| raise AssertionError(f"missing linked dataset directory: {entry['path']}") |
|
|
| for entry in manifest["files"]: |
| path = root / entry["path"] |
| if not path.is_file(): |
| raise AssertionError(f"missing verified data file: {entry['path']}") |
| if path.name != Path(entry["source_path"]).name: |
| raise AssertionError(f"filename mismatch: {entry['path']}") |
| if path.stat().st_size != entry["size_bytes"]: |
| raise AssertionError(f"size mismatch: {entry['path']}") |
| if not args.skip_hash and sha256(path) != entry["sha256"]: |
| raise AssertionError(f"sha256 mismatch: {entry['path']}") |
|
|
| check_json(root / "data" / "infer_input_data" / "all_data" / "7r6r_data.json") |
| check_json(root / "data" / "infer_input_data" / "all_data" / "t1119_data.json") |
| print("dataset_validation_ok: true") |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|