| |
| """Build and validate the object-level dataset manifest.""" |
|
|
| from __future__ import annotations |
|
|
| import json |
| from pathlib import Path |
|
|
|
|
| ROOT = Path(__file__).resolve().parents[1] |
| MANIFEST = ROOT / "dataset_manifest.jsonl" |
|
|
|
|
| def main() -> None: |
| records = [] |
|
|
| for category_dir in sorted(path for path in ROOT.iterdir() if path.is_dir()): |
| if category_dir.name.startswith(".") or category_dir.name == "scripts": |
| continue |
|
|
| for object_dir in sorted(path for path in category_dir.iterdir() if path.is_dir()): |
| trajectory_root = object_dir / "hoi_trajectories" |
| if not trajectory_root.is_dir(): |
| raise RuntimeError(f"Missing trajectory directory: {trajectory_root}") |
|
|
| handles = sorted( |
| path.name |
| for path in trajectory_root.iterdir() |
| if path.is_dir() and (path / "trajectory.json").is_file() |
| ) |
| if not handles: |
| raise RuntimeError(f"No trajectories found: {trajectory_root}") |
|
|
| records.append( |
| { |
| "category": category_dir.name, |
| "object_id": object_dir.name, |
| "trajectory_count": len(handles), |
| "trajectory_handles": handles, |
| "trajectory_root": str(trajectory_root.relative_to(ROOT)), |
| } |
| ) |
|
|
| with MANIFEST.open("w", encoding="utf-8") as output: |
| for record in records: |
| output.write(json.dumps(record, sort_keys=True) + "\n") |
|
|
| print(f"Wrote {len(records)} records to {MANIFEST}") |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|