Download OVOW/benchmark/tests/test_validate_release.py from AIGeeksGroup/PhysicalWM: direct link, hf CLI and curl.
- Browser
- Download file 2.41 kB
-
https://huggingface.co/datasets/AIGeeksGroup/PhysicalWM/resolve/main/OVOW/benchmark/tests/test_validate_release.py
- Command line
-
hf download hf://datasets/AIGeeksGroup/PhysicalWM/OVOW/benchmark/tests/test_validate_release.py
-
curl -L -o test_validate_release.py https://huggingface.co/datasets/AIGeeksGroup/PhysicalWM/resolve/main/OVOW/benchmark/tests/test_validate_release.py
2.41 kB
| from __future__ import annotations | |
| import importlib.util | |
| import json | |
| import sys | |
| import tempfile | |
| import unittest | |
| from pathlib import Path | |
| PROJECT_ROOT = Path(__file__).resolve().parents[1] | |
| def _load_module(): | |
| script = PROJECT_ROOT / "scripts" / "validate_release.py" | |
| spec = importlib.util.spec_from_file_location("validate_release", script) | |
| if spec is None or spec.loader is None: | |
| raise RuntimeError("Unable to load validate_release module") | |
| module = importlib.util.module_from_spec(spec) | |
| sys.modules[spec.name] = module | |
| spec.loader.exec_module(module) | |
| return module | |
| class TestValidateRelease(unittest.TestCase): | |
| def test_gt_only_and_submission_validation(self) -> None: | |
| module = _load_module() | |
| with tempfile.TemporaryDirectory() as tmp: | |
| root = Path(tmp) | |
| sample_id = "sample_0001" | |
| gt = root / "gt" / sample_id | |
| gt.mkdir(parents=True) | |
| (gt / "scene.blend").write_bytes(b"blend") | |
| manifest = root / "manifest.jsonl" | |
| manifest.write_text(json.dumps({"id": sample_id, "frame": 1}) + "\n", encoding="utf-8") | |
| self.assertEqual(module.validate(root, manifest, [], check_sha256=False, allow_missing_models=False), []) | |
| issues = module.validate( | |
| root, | |
| manifest, | |
| ["my_method"], | |
| check_sha256=False, | |
| allow_missing_models=False, | |
| ) | |
| self.assertEqual(len(issues), 1) | |
| pred = root / "my_method" / sample_id | |
| pred.mkdir(parents=True) | |
| (pred / "scene.glb").write_bytes(b"glb") | |
| self.assertEqual( | |
| module.validate( | |
| root, | |
| manifest, | |
| ["my_method"], | |
| check_sha256=False, | |
| allow_missing_models=False, | |
| ), | |
| [], | |
| ) | |
| def test_duplicate_manifest_ids_fail(self) -> None: | |
| module = _load_module() | |
| with tempfile.TemporaryDirectory() as tmp: | |
| manifest = Path(tmp) / "manifest.jsonl" | |
| row = json.dumps({"id": "sample_0001"}) | |
| manifest.write_text(f"{row}\n{row}\n", encoding="utf-8") | |
| with self.assertRaises(ValueError): | |
| module.load_manifest(manifest) | |
| if __name__ == "__main__": | |
| unittest.main() | |