Files
Seg_Data_Server_Net/scripts/run_agents.py

51 lines
2.2 KiB
Python

#!/usr/bin/env python3
from __future__ import annotations
import argparse
import json
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "backend"))
from app.agents.evaluation_agent import evaluate_project # noqa: E402
from app.agents.user_agent import run_user_agent # noqa: E402
from app.agents.validation_agent import validate_project # noqa: E402
def main() -> None:
parser = argparse.ArgumentParser(description="Run local evaluation and validation agents.")
parser.add_argument("--build", action="store_true", help="also run pytest and frontend build")
parser.add_argument("--live", action="store_true", help="also check live backend/frontend HTTP endpoints")
parser.add_argument("--acceptance", action="store_true", help="run the lightweight live acceptance smoke")
parser.add_argument("--real", action="store_true", help="run real workspace data acceptance through the live backend")
parser.add_argument("--real-train", action="store_true", help="run a short real workspace YOLO train/predict/heatmap acceptance")
parser.add_argument("--user", action="store_true", help="run the operator-style user agent on synthetic open data")
parser.add_argument("--no-deep", action="store_true", help="skip synthetic deep training acceptance")
parser.add_argument("--out", default="var/agent_reports/latest.json")
args = parser.parse_args()
report = {
"evaluation": evaluate_project(),
"validation": validate_project(
run_build=args.build,
run_live=args.live,
run_acceptance=args.acceptance,
run_real=args.real,
run_real_train=args.real_train,
run_deep=not args.no_deep,
),
}
if args.user:
report["user"] = run_user_agent()
out = ROOT / args.out
out.parent.mkdir(parents=True, exist_ok=True)
out.write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding="utf-8")
print(json.dumps(report, ensure_ascii=False, indent=2))
if not report["evaluation"]["passed"] or not report["validation"]["passed"] or (args.user and not report["user"]["passed"]):
raise SystemExit(1)
if __name__ == "__main__":
main()