Datasets:
Download code/robohome/src/engine/source/scripts/run_validate_package.py from RoboParty/RoboHome: direct link, hf CLI and curl.
- Browser
- Download file 5.25 kB
-
https://huggingface.co/datasets/RoboParty/RoboHome/resolve/main/code/robohome/src/engine/source/scripts/run_validate_package.py
- Command line
-
hf download hf://datasets/RoboParty/RoboHome/code/robohome/src/engine/source/scripts/run_validate_package.py
-
curl -L -o run_validate_package.py https://huggingface.co/datasets/RoboParty/RoboHome/resolve/main/code/robohome/src/engine/source/scripts/run_validate_package.py
5.25 kB
| #!/usr/bin/env python3 | |
| from __future__ import annotations | |
| import argparse | |
| import hashlib | |
| import json | |
| import sys | |
| from pathlib import Path | |
| INTERNAL_PHYSICS_DIR = Path(__file__).resolve().parent / "internal" / "physics_isaac" | |
| if str(INTERNAL_PHYSICS_DIR) not in sys.path: | |
| sys.path.insert(0, str(INTERNAL_PHYSICS_DIR)) | |
| from rhg_visual_scene_package_v16_60 import validate_scene_package, validate_visual_contract | |
| def load_json(path: Path) -> dict: | |
| return json.loads(path.read_text(encoding="utf-8")) | |
| def main() -> int: | |
| parser = argparse.ArgumentParser(description="Validate a lightweight Scene Package or generation output root.") | |
| parser.add_argument("--root", required=True, type=Path) | |
| parser.add_argument("--report", type=Path, default=None, help="Optional path to save the JSON validation report.") | |
| args = parser.parse_args() | |
| root = args.root.resolve() | |
| scene_root = root / "scenes" if (root / "scenes").is_dir() else root | |
| scene_dirs = [root] if root.name.startswith("fullhome_asset_v16_") and root.is_dir() else sorted(path for path in scene_root.glob("fullhome_asset_v16_*") if path.is_dir()) | |
| report = { | |
| "schema": "robohavengen.scene_package.validation.v0_1", | |
| "root": str(root), | |
| "scene_count": len(scene_dirs), | |
| "scenes": [], | |
| } | |
| for scene_dir in scene_dirs: | |
| row = { | |
| "scene_id": scene_dir.name, | |
| "path": str(scene_dir), | |
| **validate_scene_package(scene_dir), | |
| } | |
| camera_path=scene_dir/'camera_manifest.json' | |
| if (scene_dir/'door_hinge_contract.json').is_file(): | |
| sys.path.insert(0,str(Path(__file__).parent/'internal/scene_generation/real_assets')) | |
| from door_gate_contract import validate as validate_doors | |
| door_check=validate_doors(scene_dir);row['door_physics_contract']=door_check | |
| if not door_check['passed']: | |
| row['passed']=False | |
| row['capabilities']['metadata_ready']=False | |
| row['capabilities']['usd_export_ready']=False | |
| audit_path=scene_dir/'render_audit.json' | |
| if (scene_dir/'native_articulation_policy.json').is_file(): | |
| sys.path.insert(0,str(Path(__file__).parent/'internal/scene_generation/real_assets')) | |
| from native_scene_contract import validate as validate_native | |
| native_check=validate_native(scene_dir);row['native_articulation_contract']=native_check | |
| if not native_check['passed']: | |
| row['passed']=False;row['capabilities']['metadata_ready']=False;row['capabilities']['usd_export_ready']=False | |
| if not camera_path.is_file() and audit_path.is_file() and load_json(audit_path).get('profile')=='overview': | |
| row['rendered_preview_contract']={'passed':False,'failures':['missing_fixed_overview_camera_manifest']} | |
| row['passed']=False | |
| row['capabilities']['metadata_ready']=False | |
| row['capabilities']['usd_export_ready']=False | |
| if camera_path.is_file(): | |
| camera=load_json(camera_path);errors=[] | |
| if camera.get('profile')=='overview': | |
| sys.path.insert(0,str(Path(__file__).parent/'internal/scene_generation/real_assets')) | |
| from presentation_windows import overview_views_valid | |
| if not overview_views_valid(camera.get('views',[])): | |
| errors.append('fixed_top_oblique_camera_contract_mismatch') | |
| for view in camera.get('views',[]): | |
| image=(scene_dir/view['path']).resolve() | |
| if (not image.is_relative_to(scene_dir.resolve()) or not image.is_file() | |
| or hashlib.sha256(image.read_bytes()).hexdigest()!=view['sha256']): | |
| errors.append('packaged_preview_missing_or_changed:'+view.get('name','unknown')) | |
| row['rendered_preview_contract']={'passed':not errors,'profile':camera.get('profile'), | |
| 'view_count':len(camera.get('views',[])),'failures':errors} | |
| if errors: | |
| row['passed']=False | |
| row['capabilities']['metadata_ready']=False | |
| row['capabilities']['usd_export_ready']=False | |
| manifest = scene_dir / "SceneManifest.v16.json" | |
| if manifest.is_file() and not any(item["name"] == manifest.name for item in row["invalid_required_files"]): | |
| data = load_json(manifest) | |
| row["scene_manifest_schema"] = data.get("schema") | |
| row["manifest_visual_contract"] = data.get("visual_contract_v16_60") | |
| report["scenes"].append(row) | |
| report["capabilities"] = { | |
| name: bool(scene_dirs) and all(scene["capabilities"][name] for scene in report["scenes"]) | |
| for name in ("metadata_ready", "usd_export_ready", "sim_ready") | |
| } | |
| report["passed"] = report["capabilities"]["metadata_ready"] | |
| if args.report: | |
| report_path = args.report.resolve() | |
| report_path.parent.mkdir(parents=True, exist_ok=True) | |
| report_path.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") | |
| print(json.dumps(report, ensure_ascii=False, indent=2)) | |
| return 0 if report["passed"] else 1 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |