Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -150,6 +150,27 @@ def eval_latest(run_dir_text):
|
|
150 |
f"--output_dir='{eval_out_dir}'"
|
151 |
)
|
152 |
rc, tail = _run(cmd, elog)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
metrics_txt = "(metrics.json not found)"
|
154 |
p = pathlib.Path(eval_out_dir) / "metrics.json"
|
155 |
if p.exists():
|
|
|
150 |
f"--output_dir='{eval_out_dir}'"
|
151 |
)
|
152 |
rc, tail = _run(cmd, elog)
|
153 |
+
# --- begin optional patch: extract metrics from log tail ---
|
154 |
+
import re, ast
|
155 |
+
metrics_txt = "(metrics.json not found)"
|
156 |
+
p = pathlib.Path(eval_out_dir) / "metrics.json"
|
157 |
+
# try to parse the last Python-dict-looking block from the log tail
|
158 |
+
m = re.findall(r"\{[^}]+pc_success[^}]+\}", tail, flags=re.S)
|
159 |
+
if m:
|
160 |
+
try:
|
161 |
+
d = ast.literal_eval(m[-1])
|
162 |
+
out = {
|
163 |
+
"success_rate": d.get("pc_success"),
|
164 |
+
"avg_max_overlap": d.get("avg_max_reward"),
|
165 |
+
"avg_sum_reward": d.get("avg_sum_reward"),
|
166 |
+
"eval_s": d.get("eval_s"),
|
167 |
+
}
|
168 |
+
p.write_text(json.dumps(out, indent=2))
|
169 |
+
metrics_txt = f"Success rate: {out['success_rate']}\nAvg max overlap: {out['avg_max_overlap']}"
|
170 |
+
except Exception:
|
171 |
+
pass
|
172 |
+
# --- end optional patch ---
|
173 |
+
|
174 |
metrics_txt = "(metrics.json not found)"
|
175 |
p = pathlib.Path(eval_out_dir) / "metrics.json"
|
176 |
if p.exists():
|