You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Chameleon/integration/ptz_predictive_zoom/run_local_replay.py

43 lines
2.6 KiB
Python

from pathlib import Path
import json, os, sys
v,z,root,variant=map(Path,sys.argv[1:])
candidate=v/"ptz_predictive_zoom_candidate_20261111"
pr7=v/"ptz_zoom_threshold_diagnostics_20261111"
pins=json.loads((z/"pins.json").read_text())
dest=v/f"predictive_zoom_regression_{variant}.json"
before=str(variant)=="before"
p=(v/"ptz_zoom_threshold_maintenance_20261111" if before else candidate)/"postprocess.py"
i=(v/"ptz_zoom_zero_decision_20261109" if before else candidate)/"ptz_io.py"
s=(v/"ptz_monitor/server_unknown_source_20261109_043525" if before else candidate)/"status.py"
source=v/"ptz_monitor/server_unknown_source_20261109_043525"
key="before" if before else "after"
sys.path.insert(0,str(pr7))
if not before:
sys.path.insert(0,str(z))
sys.argv=[str(pr7/"replay.py"),str(source),str(i),
str(v/"ptz_zoom_stop_maintenance_20261109/ssh_7c7ae84464cc400dbc7dc1327124bbf7/telemetry.json"),
str(v/"cc1_cc2_control_replay_20261026/test_control_replay.py"),str(p),
pins["postprocess.py"][key],pins["ptz_io.py"][key],str(root),str(dest),
str(v/"ptz_zoom_zero_maintenance_20261109/ssh_8f0f9accd24b4f40b6466d0566cafbce/telemetry.json"),"fixed","--thresholds"]
r=(pr7/"replay.py").read_text(encoding="utf-8")
if not before:
r=r.replace(" ptz_io=load",f" load(PKG+'.zoom_controller', Path({str(z/'zoom_controller.py')!r}))\n ptz_io=load")
r=r.replace(" pp=load",f" status=load(PKG+'.status', Path({str(s)!r}))\n pp=load")
r=r.replace(" result=unittest.TextTestRunner", """ from track_integration import TRACE as zoom_trace, build_track_cases
integration = build_track_cases(before, pp, ptz_io, config, state, status)
for case in ("test_track_runs_burst_without_post_stop_status",
"test_track_same_flight_legacy_reference",
"test_track_starts_at_26_percent_of_half_frame",
"test_track_legacy_reference_at_26_percent_of_half_frame",
"test_priority_zoom_stop_honors_axis_policy",
"test_priority_zoom_stop_does_not_override_full_stop"):
suite.addTest(integration(case))
result=unittest.TextTestRunner""")
r=r.replace(" result_file=Path", f""" if result.wasSuccessful():
Path({str(v/"predictive_zoom_simulated_episode.jsonl")!r}).write_text(
"".join(json.dumps(row, allow_nan=False) + "\\n" for row in zoom_trace), encoding="utf-8")
result_file=Path""")
code=compile(r,str(pr7/"replay.py"),"exec")
exec(code,{"__file__":str(pr7/"replay.py"),"__name__":"__main__"})