runtime display

This commit is contained in:
Michael Pilosov 2026-04-21 20:22:38 -06:00
parent b99406671e
commit c6bd693058
3 changed files with 25 additions and 0 deletions

View File

@ -453,6 +453,18 @@ app.mount("/static", StaticFiles(directory=str(BASE_DIR / "static")), name="stat
templates = Jinja2Templates(directory=str(BASE_DIR / "templates"))
def _fmt_runtime(seconds: Optional[float]) -> Optional[str]:
if seconds is None or seconds <= 0:
return None
if seconds < 60:
return f"{seconds:.1f}s"
m, s = divmod(int(seconds), 60)
if m < 60:
return f"{m}m{s:02d}s"
h, m = divmod(m, 60)
return f"{h}h{m:02d}m"
def _run_view(run: Dict[str, Any]) -> Dict[str, Any]:
"""Normalise a flow-run dict for the template."""
rid = run.get("id", "")
@ -460,6 +472,9 @@ def _run_view(run: Dict[str, Any]) -> Dict[str, Any]:
state_name = run.get("state_name") or state_type.title()
start = run.get("start_time") or run.get("expected_start_time") or run.get("created")
params = run.get("parameters") or {}
# estimated_run_time recomputes server-side (ticks up while RUNNING);
# total_run_time is the authoritative value once the run finishes.
rtime_s = run.get("estimated_run_time") or run.get("total_run_time")
# Try to look up synthesised outputs either from memory or from params
ref_file = None
emb_file = None
@ -493,6 +508,7 @@ def _run_view(run: Dict[str, Any]) -> Dict[str, Any]:
"state_type": state_type,
"state_name": state_name,
"start": start,
"runtime": _fmt_runtime(float(rtime_s) if rtime_s is not None else None),
"params": params,
"ref_file": ref_file,
"emb_file": emb_file,

View File

@ -426,6 +426,14 @@ button.submit:disabled { background: var(--faint); border-color: var(--faint); c
.badge.crashed,
.badge.cancelled { color: var(--alarm); background: #f4e8e4; }
.run .stamp .rt {
display: block;
color: var(--faint);
font-size: 0.68rem;
margin-bottom: 8px;
font-variant-numeric: tabular-nums;
}
.run .recipe {
font-family: var(--serif);
font-size: 0.92rem;

View File

@ -9,6 +9,7 @@
{% for r in runs %}
<li class="run {% if just_submitted is defined and r.id == just_submitted %}just-submitted{% endif %}">
<div class="stamp">
{% if r.runtime %}<span class="rt">{{ r.runtime }}</span>{% endif %}
{% if r.start %}{{ r.start[:10] }}<br/>{{ r.start[11:19] }}{% else %}&nbsp;{% endif %}
<span class="id">#{{ r.short_id }}</span>
</div>