Buckets:
| """Report whether a Phase 1 annotation candidate can advance to role assignment.""" | |
| from __future__ import annotations | |
| import argparse | |
| import hashlib | |
| import json | |
| from pathlib import Path | |
| def digest(path: Path) -> str: | |
| return hashlib.sha256(path.read_bytes()).hexdigest() | |
| def main() -> None: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--pilot-manifest", type=Path, required=True) | |
| parser.add_argument("--annotation-package", type=Path, required=True) | |
| parser.add_argument("--output", type=Path, required=True) | |
| args = parser.parse_args() | |
| pilot = json.loads(args.pilot_manifest.read_text()) | |
| package = json.loads(args.annotation_package.read_text()) | |
| pilot_records = {record["id"]: record for record in pilot.get("records", [])} | |
| package_records = {scene["scene_id"]: scene for scene in package.get("scenes", [])} | |
| if set(pilot_records) != set(package_records): | |
| raise ValueError("pilot/package scene IDs differ") | |
| if package.get("pilot_manifest_sha256") != digest(args.pilot_manifest): | |
| raise ValueError("annotation package is not bound to this pilot manifest") | |
| gates = { | |
| "provenance_complete": all(bool(r.get("catalog_items")) for r in pilot_records.values()), | |
| "cross_role_duplicate_screen_complete": False, | |
| "pretraining_exposure_screen_complete": False, | |
| "whole_scene_annotation_complete": all( | |
| scene.get("annotation_status") == "COMPLETE" for scene in package_records.values() | |
| ), | |
| "independent_review_complete": all( | |
| scene.get("review_status") == "COMPLETE" | |
| and scene.get("primary_annotator") | |
| and scene.get("independent_reviewer") | |
| and scene["primary_annotator"] != scene["independent_reviewer"] | |
| for scene in package_records.values() | |
| ), | |
| "coverage_sufficient": False, | |
| "role_assignment_frozen": False, | |
| } | |
| result = { | |
| "schema_version": "1.0.0", | |
| "pilot_manifest": str(args.pilot_manifest), | |
| "pilot_manifest_sha256": digest(args.pilot_manifest), | |
| "annotation_package": str(args.annotation_package), | |
| "annotation_package_sha256": digest(args.annotation_package), | |
| "gates": gates, | |
| "eligible_for_role_assignment": all(gates.values()), | |
| "reason": ( | |
| "A label-free pilot is not eligible for assignment. Complete every " | |
| "gate using independent evidence before changing a scene role." | |
| ), | |
| } | |
| if args.output.exists(): | |
| raise FileExistsError(args.output) | |
| args.output.parent.mkdir(parents=True, exist_ok=True) | |
| args.output.write_text(json.dumps(result, indent=2) + "\n") | |
| print(json.dumps({"output": str(args.output), "eligible": result["eligible_for_role_assignment"], "gates": gates})) | |
| if __name__ == "__main__": | |
| main() | |
Xet Storage Details
- Size:
- 2.85 kB
- Xet hash:
- 129773f3f0a4997f6a85d89a6daa9ab647ee5a124ca3e839aee0f34a16397f2e
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.