Performance: run in progress vs ETA and last runs, in the Server tab and as a floating card

Floating cards share one base (float.js) with magnet docking; docked cards
stack in the corner. Durations come from ComfyUI's history timestamps, the
start of the current run from the execution_start event.
This commit is contained in:
Edouard Durand
2026-09-27 03:22:51 +00:00
parent b9aadf496b
commit 4fdbc035f4
11 changed files with 403 additions and 156 deletions
+32
View File
@@ -603,3 +603,35 @@ def test_freeing_memory_is_admin_only(run):
assert (await rig.http.post(rig.url("/api/free"), json=body, headers=queuer)).status == 403, "affects everyone's runs"
assert (await rig.http.post(rig.url("/api/free"), json=body, headers=admin)).status == 200
run(scenario())
def test_performance_eta_and_recent_runs(run):
async def scenario():
async with rig_server() as rig:
from rigshare_core.stats import queue_items, run_history
q = rig.ps.prompt_queue
def finished(pid, start, ms, event="execution_success"):
q.history[pid] = {"status": {"status_str": "success", "completed": True, "messages": [
["execution_start", {"prompt_id": pid, "timestamp": start}],
[event, {"prompt_id": pid, "timestamp": start + ms}]]}}
user = {"username": "alice", "display_name": "Alice"}
for i, (wf, ms, event) in enumerate([("face", 20000, "execution_success"), ("face", 30000, "execution_success"),
("face", 5000, "execution_interrupted"), ("video", 90000, "execution_success")]):
pid = f"h{i}"
rig.hub.record_prompt(pid, user, wf)
finished(pid, 1_000_000 + i * 100_000, ms, event)
rig.hub.record_prompt("live", user, "face")
q.running.append((9, "live", {"1": {}}, {}, []))
import time
rig.hub.run_started["live"] = time.time() - 12
rig.hub.run_started["old"] = time.time() - 999 # finished long ago
perf = rig.hub.performance(run_history(rig.ps), rig.hub.with_owners(queue_items(rig.ps)))
live = perf["running"][0]
assert live["workflow"] == "face" and live["eta_ms"] == 25000 and live["runs"] == 2, "ETA: this workflow's successful runs"
assert 11000 <= live["elapsed_ms"] <= 14000
assert [(r["workflow"], r["ms"], r["result"]) for r in perf["recent"][:2]] == [("video", 90000, "done"), ("face", 5000, "stopped")]
assert "old" not in rig.hub.run_started, "finished runs are forgotten"
run(scenario())