139 lines
4.7 KiB
Python
139 lines
4.7 KiB
Python
"""CLI for packaged artifact verification."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
_BUILD_ROOT = Path(__file__).resolve().parents[2]
|
|
if str(_BUILD_ROOT) not in sys.path:
|
|
sys.path.insert(0, str(_BUILD_ROOT))
|
|
|
|
from common.paths import REPO_ROOT # noqa: E402
|
|
from common.verify import ( # noqa: E402
|
|
GUI_PRODUCTS,
|
|
inspect_wheel,
|
|
verify_built_wheel,
|
|
verify_gui_dist,
|
|
verify_wheel,
|
|
verify_wheel_assets,
|
|
verify_wheel_runtime,
|
|
)
|
|
from common.verify.wheel import DEFAULT_RUNTIME_CONFIG, default_verification_video # noqa: E402
|
|
|
|
|
|
def main(argv: list[str] | None = None) -> int:
|
|
parser = argparse.ArgumentParser(description="Verify packaged Orisys artifacts.")
|
|
parser.add_argument("--gui-dist", action="store_true", help="Verify a GUI dist folder")
|
|
parser.add_argument(
|
|
"--product",
|
|
choices=sorted(GUI_PRODUCTS),
|
|
default="ory_finger",
|
|
help="GUI product profile (default: ory_finger)",
|
|
)
|
|
parser.add_argument("--dist-dir", type=Path, default=None, help="Override GUI dist folder")
|
|
parser.add_argument(
|
|
"--contents",
|
|
action="store_true",
|
|
help="Run static metadata/content assertions on the wheel",
|
|
)
|
|
parser.add_argument(
|
|
"--assets",
|
|
action="store_true",
|
|
help="Install the wheel in a temp venv and assert bundled assets load",
|
|
)
|
|
parser.add_argument(
|
|
"--runtime",
|
|
action="store_true",
|
|
help="Install the wheel and process real frames (no camera required)",
|
|
)
|
|
parser.add_argument("--expected-version", default=None, help="Assert the wheel version")
|
|
parser.add_argument(
|
|
"--strict-bundle",
|
|
action="store_true",
|
|
help="Treat bundled-file drift from the source tree as a failure",
|
|
)
|
|
parser.add_argument("--video", type=Path, default=None, help="Clip for --runtime")
|
|
parser.add_argument("--config", default=DEFAULT_RUNTIME_CONFIG, help="Config for --runtime")
|
|
parser.add_argument("--frames", type=int, default=40, help="Frames for --runtime")
|
|
parser.add_argument("--offline", action="store_true", help="Reuse parent-env dependencies")
|
|
parser.add_argument("wheel", nargs="?", type=Path, help="Wheel path for import smoke test")
|
|
args = parser.parse_args(argv)
|
|
|
|
if args.gui_dist:
|
|
verify_gui_dist(args.dist_dir, product=args.product)
|
|
return 0
|
|
if args.wheel is None:
|
|
parser.error("Provide a wheel path or pass --gui-dist")
|
|
|
|
exit_code = 0
|
|
|
|
if args.contents:
|
|
result = inspect_wheel(
|
|
args.wheel,
|
|
expected_version=args.expected_version,
|
|
repo_root=REPO_ROOT,
|
|
strict_bundle=args.strict_bundle,
|
|
)
|
|
print(result.render())
|
|
if not result.ok:
|
|
exit_code = 1
|
|
|
|
if args.assets and args.runtime:
|
|
video = args.video or default_verification_video(REPO_ROOT)
|
|
if video is None:
|
|
print("[FAIL] runtime: no clip found; pass --video or set ORISYS_VERIFY_VIDEO")
|
|
return 1
|
|
try:
|
|
record = verify_wheel(
|
|
args.wheel,
|
|
video=video,
|
|
config_name=args.config,
|
|
frames=args.frames,
|
|
offline=args.offline,
|
|
)
|
|
print(f"[ok ] {record['imports']}")
|
|
print(f"[ok ] {record['assets']}")
|
|
print(f"[ok ] runtime: frames={record['frames']} flow={record['flow_shape']}")
|
|
except Exception as exc:
|
|
print(f"[FAIL] isolated verification: {type(exc).__name__}: {exc}")
|
|
exit_code = 1
|
|
return exit_code
|
|
|
|
if args.assets:
|
|
try:
|
|
print(verify_wheel_assets(args.wheel))
|
|
except Exception as exc:
|
|
print(f"[FAIL] bundled assets: {type(exc).__name__}: {exc}")
|
|
exit_code = 1
|
|
|
|
if args.runtime:
|
|
video = args.video or default_verification_video(REPO_ROOT)
|
|
if video is None:
|
|
print("[FAIL] runtime: no clip found; pass --video or set ORISYS_VERIFY_VIDEO")
|
|
return 1
|
|
try:
|
|
info = verify_wheel_runtime(
|
|
args.wheel,
|
|
video=video,
|
|
config_name=args.config,
|
|
frames=args.frames,
|
|
offline=args.offline,
|
|
)
|
|
print(f"[ok ] runtime: {info}")
|
|
except Exception as exc:
|
|
print(f"[FAIL] runtime: {type(exc).__name__}: {exc}")
|
|
exit_code = 1
|
|
|
|
if args.contents or args.assets or args.runtime:
|
|
return exit_code
|
|
|
|
# Default behaviour is unchanged: import smoke test in an isolated venv.
|
|
verify_built_wheel(args.wheel)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|