Remove emojis from watcher.py; replace brain, caution, check-mark icons with plain text and adjust prints
Browse files15 unmodified lines16171819202122232425262747 unmodified lines75767778798081827 unmodified lines909192939495969786 unmodified lines1841851861871881891901911921931941951961971981992003 unmodified lines2042052062072082092102113 unmodified lines21521621721821922015 unmodified linesproject_root = os.path.abspath(os.path.join(script_dir, '..'))pattern = os.path.join(project_root, "runs", "realignr_*")log_dirs = sorted(glob.glob(pattern), key=os.path.getmtime)if log_dirs:latest_dir = log_dirs[-1]print(f"🔍 Found latest run: {os.path.basename(latest_dir)}")return latest_direlse:print("⚠️ No realignr_ directories found in runs/")return Noneexcept Exception as e:print(f"Error finding latest run dir: {e}")47 unmodified linesreturn currentdef monitor_and_ask(log_dir):print("🔍 Monitoring TensorBoard logs with GPT feedback + control output...")ea = EventAccumulator(log_dir)ea.Reload()metrics = {}7 unmodified linesepoch_guess = events[-1].stepif not metrics:print("⚠️ No scalars available yet. Waiting...")returnreport = "".join([f"{k}: {v:.4f}\n" for k, v in metrics.items()])feedback_summary = analyze_feedback_log(log_dir)86 unmodified lines{"role": "user", "content": prompt.strip()}])reply = response.choices[0].message.content.strip()print("\n🧠 GPT Response:")print(reply)try:control = json.loads(reply)control_path = os.path.join(os.path.dirname(__file__), '..', control_file)with open(control_path, "w") as f:json.dump(control, f)print(f"✅ Control written to {control_path}")# Also log alpha/mu and CPR_trigger as TensorBoard feedbacktb_feedback_path = os.path.join(log_dir, "feedback_log.json")3 unmodified linesf.write("\n")except Exception as e:print(f"⚠️ Failed to parse GPT response: {e}")if __name__ == '__main__':while True:latest_log_dir = get_latest_run_dir()3 unmodified linesexcept Exception as e:print(f"Error during monitoring: {e}")else:print("⏳ No matching run directories found. Waiting...")time.sleep(poll_interval)15 unmodified lines16171819202122232425262747 unmodified lines75767778798081827 unmodified lines909192939495969786 unmodified lines1841851861871881891901911921931941951961971981992003 unmodified lines2042052062072082092102113 unmodified lines21521621721821922015 unmodified linesproject_root = os.path.abspath(os.path.join(script_dir, '..'))pattern = os.path.join(project_root, "runs", "realignr_*")log_dirs = sorted(glob.glob(pattern), key=os.path.getmtime)latest_dir = log_dirs[-1]print(f"Found latest run: {os.path.basename(latest_dir)}")return latest_direlse:print("No realignr_ directories found in runs/")return Noneexcept Exception as e:print(f"Error finding latest run dir: {e}")47 unmodified linesreturn currentdef monitor_and_ask(log_dir):print("Monitoring TensorBoard logs with GPT feedback + control output...")ea.Reload()metrics = {}7 unmodified linesepoch_guess = events[-1].stepif not metrics:print("No scalars available yet. Waiting...")report = "".join([f"{k}: {v:.4f}\n" for k, v in metrics.items()])feedback_summary = analyze_feedback_log(log_dir)86 unmodified lines{"role": "user", "content": prompt.strip()}])reply = response.choices[0].message.content.strip()print("\nGPT Response:")try:control = json.loads(reply)control_path = os.path.join(os.path.dirname(__file__), '..', control_file)print(f"Control written to {control_path}")json.dump(control, f)# Also log alpha/mu and CPR_trigger as TensorBoard feedbacktb_feedback_path = os.path.join(log_dir, "feedback_log.json")3 unmodified linesf.write("\n")except Exception as e:print(f"Failed to parse GPT response: {e}")if __name__ == '__main__':while True:latest_log_dir = get_latest_run_dir()3 unmodified linesexcept Exception as e:print(f"Error during monitoring: {e}")else:print("No matching run directories found. Waiting...")time.sleep(poll_interval)
watcher.py+15-15