"""New namespace real Chromium checks; all successful writes are temporary."""
from pathlib import Path
import sys

PROJECT=Path(__file__).resolve().parents[1];sys.path.insert(0,str(PROJECT));sys.path.insert(0,str(PROJECT/'scripts'))
from scripts import check_mask_model_requests_ui as checks
from pallet.mask_annotation_update_review import UpdatedKeypointGallery
from pallet.mask_annotation_update_requests import ROOT,DRAFT_PREFIX
from pallet.pose_review_geometry import canonical

if __name__=='__main__':
    checks.ROOT=ROOT;checks.REVIEWS=PROJECT/'outputs/pallet_mask_model_reviews_v4'
    checks.OUT=PROJECT/'outputs/pallet_mask_annotation_update_checks_v1/ui_acceptance'
    checks.OUT.parent.mkdir(mode=0o700,exist_ok=True)
    try:checks.check(UpdatedKeypointGallery,keypoint_mode=True,allow_human_keypoint_edits=True,local_draft_prefix=DRAFT_PREFIX)
    except Exception as error:
        if checks.OUT.exists() and not (checks.OUT/'failure.json').exists():
            secret=(PROJECT/'outputs/pallet_pose_human_review_v1/access_key.txt').read_text().strip()
            (checks.OUT/'failure.json').write_bytes(canonical(dict(state='failed_updated_model_UI_not_deployed',
                error=(type(error).__name__+': '+str(error)).replace(secret,'[redacted]'),production_annotation_writes=0))+b'\n')
        raise
