Datasets:
Download scripts/verify_broken_objects.py from hcltech-robotics/simrepairbench: direct link, hf CLI and curl.
- Browser
- Download file 1.91 kB
-
https://huggingface.co/datasets/hcltech-robotics/simrepairbench/resolve/main/scripts/verify_broken_objects.py
- Command line
-
hf download hf://datasets/hcltech-robotics/simrepairbench/scripts/verify_broken_objects.py
-
curl -L -o verify_broken_objects.py https://huggingface.co/datasets/hcltech-robotics/simrepairbench/resolve/main/scripts/verify_broken_objects.py
1.91 kB
| """Verify exported damage against source identities and authored fault predicates.""" | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| from pxr import Usd | |
| from simrepairbench.common import roster, sha256 | |
| from simrepairbench.damage import state, structure | |
| def verify(root): | |
| total = 0 | |
| for case in roster(root): | |
| cid = case['case_id'] | |
| report = json.loads((root / 'records' / cid / 'damage-verification.json').read_text()) | |
| asset = root / 'work/damaged' / cid / 'asset.usdc' | |
| assert sha256(asset) == report['asset_sha256'], cid + ': asset digest' | |
| assert sorted(d['defect_id'] for d in report['defects']) == sorted(d['defect_id'] for d in case['proposed_corruptions']), cid + ': defect coverage' | |
| stage = Usd.Stage.Open(str(asset)) | |
| assert stage, cid + ': reopen' | |
| for defect in report['defects']: | |
| assert defect['operations'], defect['defect_id'] + ': empty mutation' | |
| for op in defect['operations']: | |
| assert op['before'] != op['after'], defect['defect_id'] + ': no mutation' | |
| assert state(stage, op) == op['after'], defect['defect_id'] + ': altered predicate' | |
| total += 1 | |
| assert not structure(stage)['invalid_mesh_topologies'], cid + ': invalid mesh' | |
| assert not report['source_baseline']['composition_errors'], cid + ': source composition' | |
| assert not report['source_baseline']['invalid_mesh_topologies'], cid + ': source topology' | |
| assert not report['source_baseline']['missing_joint_targets'], cid + ': source endpoints' | |
| print(json.dumps({'cases': 25, 'authored_faults': total, 'exported_bytes_checked': True})) | |
| def main(): | |
| p = argparse.ArgumentParser(description=__doc__) | |
| p.add_argument('--root', type=Path, default=Path.cwd()) | |
| args = p.parse_args() | |
| verify(args.root.resolve()) | |
| if __name__ == '__main__': | |
| main() | |