(self, parsed)
| 1069 | |
| 1070 | try: |
| 1071 | data = _load_runs_index(run_index_file) |
| 1072 | except Exception as e: |
| 1073 | self._send_html(500, f"load runs index failed: {e}") |
| 1074 | return |
| 1075 | info = (data.get("runs") or {}).get(rid) if isinstance(data, dict) else None |
| 1076 | if not isinstance(info, dict): |
| 1077 | self._send_html(404, "run not found") |
| 1078 | return |
| 1079 | |
| 1080 | progress_file = Path(str(info.get("progress_file", ""))) |
| 1081 | prog = _read_jsonl_tail(progress_file, max_lines=400) |
| 1082 | prog_html = "\n".join( |
| 1083 | f"<pre>{_html_escape(json.dumps(e, ensure_ascii=False))}</pre>" for e in prog |
| 1084 | ) |
| 1085 | |
| 1086 | log_link = f"/log?id={_html_escape(rid)}" |
| 1087 | |
| 1088 | follow_cfg = _get_follow_cfg_for_repo_branch(str(info.get('repo','')), str(info.get('branch',''))) |
| 1089 | step_links = '' |
| 1090 | if isinstance(follow_cfg, dict): |
| 1091 | run_cfg = follow_cfg.get('run') |
| 1092 | if isinstance(run_cfg, dict): |
| 1093 | cmds = run_cfg.get('commands') |
| 1094 | if isinstance(cmds, list) and cmds: |
| 1095 | parts = [] |
| 1096 | for idx2 in range(1, len(cmds) + 1): |
| 1097 | parts.append(f"<a href='/step_log?id={_html_escape(rid)}&step={idx2}' target='_blank'>step_{idx2}</a>") |
| 1098 | step_links = ' '.join(parts) |
| 1099 | rid_html = _html_escape(rid) |
| 1100 | status_html = _html_escape(str(info.get('status',''))) |
| 1101 | repo_html = _html_escape(str(info.get('repo',''))) |
| 1102 | branch_html = _html_escape(str(info.get('branch',''))) |
| 1103 | commit_html = _html_escape(str(info.get('commit',''))) |
| 1104 | name_prefix_html = _html_escape(str(info.get('name_prefix',''))) |
| 1105 | |
| 1106 | html = """<!doctype html> |
| 1107 | <html><head><meta charset='utf-8'/> |
| 1108 | <meta name='viewport' content='width=device-width, initial-scale=1'/> |
| 1109 | <meta http-equiv='refresh' content='2'/> |
| 1110 | <title>Run @@RID@@</title> |
| 1111 | <style> |
| 1112 | body{font-family:ui-sans-serif,system-ui,Segoe UI,Roboto,Helvetica,Arial;max-width:1200px;margin:16px auto;padding:0 12px;} |
| 1113 | pre{background:#0b1020;color:#e5e7eb;padding:10px;border-radius:8px;overflow:auto;} |
| 1114 | </style> |
| 1115 | </head><body> |
| 1116 | <a href='/'>back</a> |
| 1117 | <h2>Run @@RID@@</h2> |
| 1118 | <div>status: <code>@@STATUS@@</code></div> |
| 1119 | <div>repo: <code>@@REPO@@</code></div> |
| 1120 | <div>branch: <code>@@BRANCH@@</code></div> |
| 1121 | <div>commit: <code>@@COMMIT@@</code></div> |
| 1122 | <div>name_prefix: <code>@@NAME_PREFIX@@</code></div> |
| 1123 | <div>log: <a href='@@LOG_LINK@@'>@@LOG_LINK@@</a></div> |
| 1124 | <div>step_logs: @@STEP_LINKS@@</div> |
| 1125 | <h3>Logs</h3> |
| 1126 | <iframe src='@@LOG_LINK@@' style='width:100%;height:82vh;border:1px solid #e5e7eb;border-radius:8px;'></iframe> |
| 1127 | <details style='margin-top:12px'> |
| 1128 | <summary>progress.jsonl (tail)</summary> |
no test coverage detected