Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/nullius/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,13 +633,13 @@ def summary(self) -> dict:

def stages(self) -> dict:
"""The stages said so far, folded for the page (``progress.fold``).
Once the run has failed or been stopped, a stage still running was
cut short by it, and nothing is waiting any more."""
Once the run has ended, no stage is running or waiting any more.
Counts remain exactly what the progress events reported."""
with self._lock:
events = list(self.events)
got = progress.fold(events)
if self.state in ("failed", "stopped"):
got["stages"] = [dict(r, state="failed") if r["state"] == "running" else r for r in got["stages"] if r["state"] != "waiting"]
if self.state in ("done", "failed", "stopped"):
got["stages"] = [dict(r, state="done" if self.state == "done" else "failed") if r["state"] == "running" else r for r in got["stages"] if r["state"] != "waiting"]
got["current"] = None
return got

Expand Down
6 changes: 5 additions & 1 deletion app/nullius/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ def fold(events: Iterable[dict]) -> dict:
stages[key]["key"] = key
stages.setdefault(key, {"key": key, "stage": st, "label": label(ev), "state": "waiting"})
row = stages[key]
if state == "start":
# A later part or retry starts this stage afresh.
for field in ("seconds", "bytes", "total", "detail"):
row.pop(field, None)
row["label"] = label(ev)
if ev.get("detail") is not None:
row["detail"] = ev["detail"]
Expand All @@ -295,7 +299,7 @@ def fold(events: Iterable[dict]) -> dict:
last = seen[-1] if seen else -1
rows = [r for i, r in enumerate(rows) if r["state"] != "waiting" or i > last]
if ended: # a run that ended has nothing running, nor anything still to come
rows = [dict(r, state="failed") if r["state"] == "running" and ended == "refused" else r
rows = [dict(r, state="failed" if ended == "refused" else "done") if r["state"] == "running" else r
for r in rows if r["state"] != "waiting"]
current = next((r for r in rows if r["state"] == "running"), None)
return {"stages": rows, "units": units, "current": current["key"] if current else None, "ended": ended, "detail": detail}
13 changes: 13 additions & 0 deletions app/static/runs/board.css
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,19 @@
box-shadow: var(--shadow); font: 12px/1.45 var(--sans); color: var(--text); pointer-events: none; }

@media (prefers-reduced-motion: reduce) { .rp *, .rp *::before, .rp *::after { transition: none !important; } }

/* Run identity belongs on the full run overview, above its views. */
.run-identity{align-items:center;gap:10px}
.run-identity-card{display:flex;align-items:center;gap:12px;border:1px solid var(--border);border-radius:var(--radius);background:var(--surface);padding:9px 14px;min-width:0;max-width:100%;color:var(--text);line-height:1.5}
.run-identity-card>div{min-width:0;overflow-wrap:anywhere}
.run-identity-card .k{display:block;color:var(--text-dim);font-size:.75rem}
.run-identity-card .v{display:block;font-weight:500}
.run-identity-sep{width:1px;flex:none;align-self:stretch;background:var(--border)}
.run-identity-mark{width:32px;height:32px;border-radius:8px;background:var(--accent-soft);color:var(--accent);display:grid;place-items:center;font:500 15px/1 var(--mono);flex:none;padding:6px}
.run-identity-mark:has(.agent-logo){padding:4px;background:color-mix(in srgb,var(--text) 8%,transparent);color:var(--text)}
.run-identity-model{display:block;font-size:.8rem;color:var(--text-dim);overflow-wrap:anywhere}

.run-runner-logo{width:32px;height:32px;flex:none;color:var(--text)}
/* the Filtered score under the adjusted rate: a switch per kind of flag, and the rate without those tasks */
.rp .filtered { display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; margin: 1rem 18px 0; }
.rp .filtered .filter-heading { flex-basis: 100%; color: var(--text-faint); font-size: .8rem; }
Expand Down
4 changes: 3 additions & 1 deletion app/static/runs/live-board.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* The job page's two views, and the Live board.
/* The job page's views, and the Live board.
Scoped to .lb; the phase and outcome hues are the app's own. */

/* ---- the two views ---- */
Expand Down Expand Up @@ -183,3 +183,5 @@
.lb-open-row:hover { text-decoration: underline; }
/* the board counts the trials itself: the run strip's own task bar would say it twice */
body:has(#live-board) #execution-units { display: none; }

.view-tabs [role="tab"]:disabled { color: var(--text-faint); cursor: default; }
37 changes: 31 additions & 6 deletions app/static/runs/live-board.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,20 @@
let snap = null, timer = null, misses = 0;
// opened while the run was going: the Results rendered with the page are older than its end
const startedLive = board.dataset.state !== 'finished';
let waiting = board.dataset.state === 'unknown';
function paint() {
if (!snap) return;
if (!snap || stateOf(snap) === 'unknown') return;
if (waiting) {
waiting = false;
doc.getElementById('preparing')?.remove();
const liveTab = doc.getElementById('tab-live');
if (liveTab) liveTab.disabled = false;
const resultsTab = doc.getElementById('tab-results');
if (resultsTab) resultsTab.disabled = false;
const dot = doc.getElementById('live-dot');
if (dot) dot.classList.toggle('on', stateOf(snap) !== 'finished');
doc.dispatchEvent(new Event('live-ready'));
}
const out = render(snap, opts);
board.dataset.state = out.state;
$('[data-lb-state]').textContent = out.stateLabel;
Expand Down Expand Up @@ -338,8 +350,18 @@
async function tick() {
try {
const r = await nulliusFetch(endpoint, {headers: {'Accept': 'application/json'}, cache: 'no-store'});
if (!r.ok) throw new Error('HTTP ' + r.status);
misses = 0; snap = await r.json();
if (!r.ok) {
if (waiting && doc.getElementById('execution')?.dataset.live === 'no') { clearInterval(timer); timer = null; }
throw new Error('HTTP ' + r.status);
}
const next = await r.json();
if (waiting && (next.state === 'unknown' || !next.counts)) {
if (next.state === 'finished' || doc.getElementById('execution')?.dataset.live === 'no') {
clearInterval(timer); timer = null;
}
return;
}
misses = 0; snap = next;
} catch (e) { misses += 1; }
paint();
}
Expand All @@ -360,7 +382,7 @@
paint();
if (!snap || stateOf(snap) !== 'finished') { timer = setInterval(tick, 1000); tick(); }
}
// The two views of the job page: switched in place, kept in the address as ?view=.
// The views of the job page: switched in place, kept in the address as ?view=.
function mountTabs(doc) {
const tabs = Array.from(doc.querySelectorAll('[data-view-tab]'));
if (!tabs.length) return;
Expand All @@ -376,11 +398,14 @@
if (view === 'results' && badge && badge.dataset.stale) { location.assign(u); return; }
history.replaceState(null, '', u);
}
tabs.forEach((t, i) => {
doc.addEventListener('live-ready', () => {
if (!new URL(location.href).searchParams.has('view')) show('live');
});
tabs.forEach(t => {
t.addEventListener('click', () => show(t.dataset.viewTab));
t.addEventListener('keydown', e => {
const d = e.key === 'ArrowRight' ? 1 : e.key === 'ArrowLeft' ? -1 : 0;
if (d) { e.preventDefault(); const n = tabs[(i + d + tabs.length) % tabs.length]; n.focus(); show(n.dataset.viewTab); }
if (d) { e.preventDefault(); const enabled = tabs.filter(t => !t.disabled); const i = enabled.indexOf(t); const n = enabled[(i + d + enabled.length) % enabled.length]; n.focus(); show(n.dataset.viewTab); }
});
});
}
Expand Down
28 changes: 17 additions & 11 deletions app/static/traces/conversation.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions app/templates/runs/_execution.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
{%- if st.state == 'cached' %}<span class="xs-time">cached</span>{% elif st.get('seconds') is not none and st.state in ('done', 'failed') %}<span class="xs-time">{{ st.seconds|secs }}</span>{% endif %}
{%- if st.state in ('running', 'failed') and st.detail and st.detail != sp.detail %}<span class="xs-detail">{{ st.detail }}</span>{% endif %}</li>{% endfor %}
</ol>
<div class="xs-units" id="execution-units"{% if not sp.units %} hidden{% endif %}>{% if sp.units %}{% set u = sp.units %}<progress max="{{ u.n or 1 }}" value="{{ u.done }}"></progress><span class="small"><b>{{ u.done }} / {{ u.n if u.n is not none else '?' }}</b> {{ u.noun }}{% for k in ('passed', 'failed', 'scored', 'errors') if u[k] %} · {{ u[k] }} {{ 'error' + ('' if u[k] == 1 else 's') if k == 'errors' else k }}{% endfor %}{% if u.running %} · {{ u.running }} running{% endif %}</span>{% endif %}</div>
<div class="xs-units" id="execution-units"{% if not sp.units %} hidden{% endif %}>{% if sp.units %}{% set u = sp.units %}<progress{% if u.n is not none %} max="{{ u.n or 1 }}" value="{{ u.done }}"{% endif %}></progress><span class="small"><b>{{ u.done }} / {{ u.n if u.n is not none else '?' }}</b> {{ u.noun }}{% for k in ('passed', 'failed', 'scored', 'errors') if u[k] %} · {{ u[k] }} {{ 'error' + ('' if u[k] == 1 else 's') if k == 'errors' else k }}{% endfor %}{% if u.running %} · {{ u.running }} running{% endif %}</span>{% endif %}</div>
<div class="small bad" id="execution-refused"{% if sp.ended != 'refused' %} hidden{% endif %}>{% if sp.ended == 'refused' %}Refused before its first unit: {{ sp.detail }}{% endif %}</div>
</div>
{# a part downloading: its file, how much of it, as a bar #}
<div class="execution-progress" id="execution-progress" hidden><progress id="execution-bar" max="1" value="0"></progress><span class="small mono" id="execution-progress-text"></span></div>
<details class="execution-log" {% if waiting %}open{% endif %}><summary class="small">Launch log</summary><pre id="execution-lines"></pre></details>
<details class="execution-log" open><summary class="small">Launch log</summary><pre id="execution-lines"></pre></details>
</section>
<script>
(() => {
Expand All @@ -49,8 +49,8 @@
const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e; };
const stages = sp => {
const wrap = document.getElementById('execution-stages'), list = document.getElementById('execution-stage-list'), units = document.getElementById('execution-units');
if (!sp || (!sp.stages.length && !sp.units)) return;
wrap.hidden = false;
if (!sp) return;
wrap.hidden = !sp.stages.length && !sp.units;
sp.stages.forEach((st, n) => {
const li = list.children[n] || list.appendChild(el('li'));
li.className = 'xs ' + st.state;
Expand All @@ -73,7 +73,7 @@
const u = sp.units;
units.hidden = !u;
if (u) {
const bar = el('progress'); bar.max = u.n || 1; bar.value = u.done;
const bar = el('progress'); if (u.n != null) { bar.max = u.n || 1; bar.value = u.done; }
const txt = el('span', 'small'); txt.append(el('b', '', u.done + ' / ' + (u.n != null ? u.n : '?')), ' ' + u.noun);
for (const k of ['passed', 'failed', 'scored', 'errors']) if (u[k]) txt.append(' · ' + u[k] + ' ' + (k === 'errors' ? (u[k] === 1 ? 'error' : 'errors') : k));
if (u.running) txt.append(' · ' + u.running + ' running');
Expand Down Expand Up @@ -106,8 +106,7 @@
if (j.state === 'stopping') document.getElementById('execution-stop')?.remove();
const ask = document.getElementById('execution-ask'); ask.hidden = j.state !== 'paused'; document.getElementById('execution-question').textContent = j.question || '';
if (!alive && live) { live = false; document.getElementById('execution-stop')?.remove(); if (j.error && !own) { const e = document.createElement('span'); e.className = 'small bad'; e.textContent = j.error; state.after(e); } }
// Check once more at completion, but do not wait forever for a job that never started.
if (box.dataset.waiting === 'yes') { const h = await nulliusFetch(location.pathname, {method: 'HEAD', cache: 'no-store'}); if (h.ok) location.reload(); }
box.dataset.live = alive ? 'yes' : 'no';
if (alive) setTimeout(tick, 1000);
} catch { if (retry) setTimeout(tick, 5000); }
};
Expand Down
27 changes: 27 additions & 0 deletions app/templates/runs/_live_board.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% macro live_panel(job_id, live_board=none, trial_base="", noun="") %}
<section class="lb" id="live-board" aria-label="Live board" data-state="{{ live_board.initial.state if live_board and live_board.initial else 'unknown' }}"
data-endpoint="{{ url_for('job_live', job_id=job_id) }}"
data-trial-base="{{ trial_base }}"
data-noun="{{ noun }}">
<div class="lb-headline">
<span class="lb-state"><i aria-hidden="true"></i><span data-lb-state>{{ live_board.initial.state|capitalize if live_board and live_board.initial else '' }}</span></span>
<span class="lb-clock" data-lb-head></span>
<span class="lb-meta" data-lb-meta></span>
</div>
<div class="lb-stats" data-lb-stats></div>
<div class="lb-mix">
<div class="lb-mixbar" data-lb-mixbar role="img" aria-label="Outcome mix of finished trials, as the feed reports them"></div>
<ul class="lb-legend" data-lb-legend aria-label="Filter trials by outcome"></ul>
<div class="lb-lanes" data-lb-lanes hidden></div>
</div>
<div class="lb-body">
<div class="lb-main">
<div class="lb-tiles-wrap"><span data-lb-tiles-label>All trials</span><div class="lb-tiles" data-lb-tiles></div></div>
<div data-lb-flight></div>
</div>
<aside class="lb-drawer" data-lb-drawer aria-label="Trial detail" hidden></aside>
</div>
<p class="lb-foot" data-lb-foot hidden><span data-lb-status></span></p>
</section>
<script id="live-board-initial" type="application/json">{{ (live_board.initial if live_board else none) | tojson }}</script>
{% endmacro %}
Loading