import time, os, re, subprocess, math os.chdir("/home/yurenh2/ept/ep_run"); LOG="runs/ep_eps05.log" def alive(): return subprocess.run(["pgrep","-f","ckpt runs/ep_eps05.pt"],capture_output=True).returncode==0 def latest(): try: ls=[l for l in open(LOG) if l.startswith("step")] except Exception: return None if not ls: return None l=ls[-1] ms=re.search(r"step\s+(\d+)", l); mv=re.search(r"val CE ([\d.eE+-]+)", l) mb=re.search(r"best ([\d.eE+-]+)", l); mr=re.search(r"res=([\d.eE+-]+)", l) if not (ms and mv and mb and mr): return None return (int(ms.group(1)), float(mv.group(1)), float(mb.group(1)), float(mr.group(1))) d0=latest(); B0 = d0[2] if d0 else 2.60 nb = (math.ceil(B0*10)-1)/10.0 CLIMB=1.5e-1 fired=None; best_seen=99.0; best_step=0; hi_res=0.0; t0=time.time() while fired is None and time.time()-t0 < 12*3600: time.sleep(60) d=latest() if not alive(): fired=f"ep_eps05 EXITED; last {d}"; break if not d: continue step,val,best,res = d if besthi_res: hi_res=res if val>10 or res>0.3: fired=f"ep_eps05 DIVERGED/BLEW @step{step} val{val:.2f} res{res:.1e} -> BLOW POINT best={best:.4f} (redx blew 2.74; wall moved to ~{best:.2f})"; break if res>CLIMB: fired=f"ep_eps05 res IMMINENT-BLOW res{res:.1e} peak{hi_res:.1e} @step{step} best{best:.4f} (climbing toward 0.3 abort)"; break if best <= nb+1e-9: fired=f"ep_eps05 reached {nb:.2f}: step{step} best{best:.4f} val{val:.4f} res{res:.1e} peak_res{hi_res:.2f}"; break if step-best_step >= 1800 and best>nb: fired=f"ep_eps05 STALLED above {nb:.2f}: best{best:.4f} no-improve {step-best_step} steps res{res:.1e}"; break print(f"=== EP_EPS05 GRID (target {nb:.2f}, climb>{CLIMB}) ==="); print(fired or "12h timeout"); print("last:", latest(), "peak_res", round(hi_res,4))