Files
sensor-bench/build/verify_operator_dist.py
2026-09-01 11:14:56 +08:00

58 lines
2.1 KiB
Python

"""Verify the private SensorBenchOperator onedir layout."""
from __future__ import annotations
import json
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
DIST = ROOT / "dist" / "SensorBenchOperator"
def require(path: Path) -> None:
if not path.exists():
raise FileNotFoundError(f"Missing operator build artifact: {path}")
def main() -> int:
require(DIST / "SensorBenchOperator.exe")
require(DIST / "_internal")
require(DIST / "steps" / "default.json")
require(DIST / "config" / "options.json")
require(DIST / "config" / "locales" / "zh_CN.json")
require(DIST / "config" / "locales" / "en_US.json")
require(DIST / "config" / "ddjx01.json")
options = json.loads((DIST / "config" / "options.json").read_text(encoding="utf-8"))
if "sensor_types" not in options:
raise RuntimeError("Operator options.json missing sensor_types")
locale = json.loads(
(DIST / "config" / "locales" / "en_US.json").read_text(encoding="utf-8")
)
if "workflow" not in locale:
raise RuntimeError("Operator locale missing workflow section")
if "Inspection Workflow" not in json.dumps(locale, ensure_ascii=False):
# Chinese catalog may be the default UI language; English must still ship.
raise RuntimeError("Operator en_US locale missing Inspection Workflow title")
steps = json.loads((DIST / "steps" / "default.json").read_text(encoding="utf-8"))
if not steps.get("steps"):
raise RuntimeError("Operator steps/default.json has no steps")
# Guard against accidentally packaging the whole internal/ source tree.
if (DIST / "internal").exists():
raise RuntimeError(f"Operator dist should not nest internal/: {DIST / 'internal'}")
if (DIST / "src").exists():
raise RuntimeError(f"Operator dist should not ship raw src/: {DIST / 'src'}")
print(f"Verified internal SensorBenchOperator dist layout: {DIST}")
print("INTERNAL USE ONLY - do not publish to customers.")
return 0
if __name__ == "__main__":
raise SystemExit(main())