"""Actual desktop/mobile add-point and save checks, exclusively in temp stores."""
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_class_keypoint_review import ClassKeypointGallery,EXTENSION
from pallet.pose_review_geometry import canonical


if __name__=='__main__':
    checks.ROOT=PROJECT/'outputs/pallet_mask_model_requests_v3';checks.REVIEWS=PROJECT/'outputs/pallet_mask_model_reviews_v3'
    checks.OUT=EXTENSION/'ui_acceptance'
    try:checks.check(ClassKeypointGallery,keypoint_mode=True,allow_human_keypoint_edits=True)
    except Exception as error:
        if checks.OUT.exists() and not (checks.OUT/'failure.json').exists() and not (checks.OUT/'ui_acceptance.json').exists():
            secret=(PROJECT/'outputs/pallet_pose_human_review_v1/access_key.txt').read_text().strip()
            with (checks.OUT/'failure.json').open('xb') as stream:stream.write(canonical(dict(state='failed_human_add_point_UI_not_deployed',
                error=(type(error).__name__+': '+str(error)).replace(secret,'[redacted]'),production_annotation_writes=0))+b'\n')
        raise
