Buckets:
| import importlib.util | |
| import unittest | |
| from pathlib import Path | |
| class validation_contract(unittest.TestCase): | |
| def module(self): | |
| self.assertTrue(Path("validate.py").exists(), "dataset validator is not implemented") | |
| spec = importlib.util.spec_from_file_location("validate", "validate.py") | |
| module = importlib.util.module_from_spec(spec) | |
| spec.loader.exec_module(module) | |
| return module | |
| def test_shared_region_cannot_span_splits(self): | |
| module = self.module() | |
| with self.assertRaises(ValueError): | |
| module.check_groups([{"group": "city", "split": "train"}, {"group": "city", "split": "test"}]) | |
| module.check_groups([{"group": "city", "split": "train"}, {"group": "other", "split": "test"}]) | |
| def test_zero_area_and_outside_boxes_are_rejected(self): | |
| module = self.module() | |
| for bbox in ([0, 0, 0, 1], [1000, 0, 30, 10], [-1, 0, 4, 4]): | |
| with self.subTest(bbox=bbox), self.assertRaises(ValueError): | |
| module.check_annotation({"bbox": bbox, "category_id": 4, "clipped_polygon": [0, 0, 1, 0, 1, 1, 0, 1]}, 1024, 1024) | |
| module.check_annotation({"bbox": [10, 10, 5, 5], "category_id": 4, "clipped_polygon": [10, 10, 15, 10, 15, 15, 10, 15]}, 1024, 1024) | |
| def test_unknown_category_is_rejected(self): | |
| module = self.module() | |
| with self.assertRaises(ValueError): | |
| module.check_annotation({"bbox": [10, 10, 5, 5], "category_id": 99, "clipped_polygon": [10, 10, 15, 10, 15, 15, 10, 15]}, 1024, 1024) | |
| def test_readiness_requires_a_visual_review(self): | |
| import tempfile | |
| module = self.module() | |
| self.assertTrue(hasattr(module, "mark_ready"), "readiness gate is not implemented") | |
| with tempfile.TemporaryDirectory() as temp: | |
| with self.assertRaises(ValueError): | |
| module.mark_ready(Path(temp)) | |
| def test_revalidation_revokes_readiness_even_on_exception(self): | |
| import tempfile | |
| import json | |
| module = self.module() | |
| with tempfile.TemporaryDirectory() as temp: | |
| root = Path(temp) | |
| (root / "stats.json").write_text(json.dumps({"training_ready": True})) | |
| with self.assertRaises(FileNotFoundError): | |
| module.audit(root) | |
| self.assertFalse(json.loads((root / "stats.json").read_text())["training_ready"]) | |
| if __name__ == "__main__": | |
| unittest.main() | |
Xet Storage Details
- Size:
- 2.49 kB
- Xet hash:
- f0635db81b95daae9058a2eabc727e9d6b1f989a58c675414cb7331d7b4611d6
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.