Close eight open SDK tasks: the pidfile, the log, cards, names and a live curve
Each was a loose end recorded under `### SDK` in the notepad. `serve` takes its own pidfile down on SIGTERM. uvicorn restores the handler it found and re-raises the signal it stopped on, so the default handler ended the process without unwinding and the `finally` never ran — which is what a stop sends, and what left `serve.pid` behind. `serve.log` is cut back past 5 MB by the engine rather than by the screen that started it, so an adopted engine is bounded too. Gated on its own stdout being an appended regular file, which is what makes the cut safe: the kernel then puts the next write at the new end. Cards are counted from `/dev/nvidia[0-9]*`, so `FLOW_GPUS`/`--gpus` of 0 means "work it out" the way `FLOW_CPUS` always has. The engine counts, not the accountant — a remote worker builds one of those from its own inventory, and detecting there would hand it the engine host's cards. The worker counts last: what a batch job says it was granted still wins. `GET /runs/metrics/names` is the distinct over a selection that `--list` and the terminal's metric picker were approximating by reading the newest run that had measured anything, which missed a name only an older run ever wrote. `MetricSink` announces each batch it has written (`run_metric`, carrying the names). Not a per-point event: one covers up to 500 points or two seconds of them, and the rows stay the record. The terminal comparison fills in as the first readings land instead of staying blank until reopened, and the browser refetches the run and any comparison rather than the list behind them. `retry --group` pages the list route by `before` instead of stopping at 500. The terminal dashboard takes the terminal's colours (`ansi-dark`), and the web UI can re-pair from Settings without disconnecting first. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PRQ9bmTvCbqCwXo9mxZzzV
This commit is contained in:
@@ -19,7 +19,7 @@ from textual.containers import Horizontal
|
||||
from textual.screen import Screen
|
||||
from textual.widgets import DataTable, Footer, Header, Select, Static
|
||||
|
||||
from fluksio.sdk.cli import _dur, metric_names
|
||||
from fluksio.sdk.cli import _dur
|
||||
from fluksio.sdk.client import Client
|
||||
from fluksio.tui.chart import MAX_SERIES, Curves, legend
|
||||
|
||||
@@ -33,8 +33,9 @@ PARAM, METRIC = "param.", "metric."
|
||||
RUNNING = frozenset({"queued", "running"})
|
||||
|
||||
#: How often a curve is re-read while a run in the selection is still going.
|
||||
#: Metric points are not published on the event bus — the run's sink writes
|
||||
#: them — so the socket makes the *table* live and this makes the *curve* live.
|
||||
#: The engine announces each batch its sink writes (`run_metric`), which is
|
||||
#: what usually wakes this screen; the poll is the heartbeat behind it, and
|
||||
#: what makes the screen live against an engine older than that event.
|
||||
LIVE_S = 1.0
|
||||
|
||||
|
||||
@@ -136,7 +137,7 @@ class CompareScreen(Screen[None]):
|
||||
def read_table(self) -> None:
|
||||
try:
|
||||
rows = self.client.export_runs(ids=self.ids)
|
||||
names = metric_names(self.client, self.ids)
|
||||
names = list(self.client.metric_names(ids=self.ids))
|
||||
except Exception as exc: # noqa: BLE001 — the screen reports it
|
||||
self.app.call_from_thread(self.show_error, exc)
|
||||
return
|
||||
@@ -213,8 +214,7 @@ class CompareScreen(Screen[None]):
|
||||
*(_cell(row.get(key)) for key in params),
|
||||
*(_cell(row.get(key)) for key in scores),
|
||||
)
|
||||
# A curve only grows while its run does, and metric points are not on
|
||||
# the event bus — so this is the one thing the screen polls for.
|
||||
# A curve only grows while its run does.
|
||||
self.keep_live(any(str(row.get("status")) in RUNNING for row in rows))
|
||||
self.read_curves()
|
||||
|
||||
@@ -228,9 +228,21 @@ class CompareScreen(Screen[None]):
|
||||
legend(label for label, _ in lines[:MAX_SERIES])
|
||||
)
|
||||
|
||||
def refresh_live(self) -> None:
|
||||
"""New readings have landed. Draw them.
|
||||
|
||||
A run opened before it measured anything has no metric picked, and
|
||||
nothing but the table read fills that in — so the whole read is what a
|
||||
first batch needs, and only the curve after that.
|
||||
"""
|
||||
if not self.names:
|
||||
self.read_table()
|
||||
else:
|
||||
self.read_curves()
|
||||
|
||||
def keep_live(self, running: bool) -> None:
|
||||
if running and self.live is None:
|
||||
self.live = self.set_interval(LIVE_S, self.read_curves)
|
||||
self.live = self.set_interval(LIVE_S, self.refresh_live)
|
||||
elif not running and self.live is not None:
|
||||
self.live.stop()
|
||||
self.live = None
|
||||
|
||||
Reference in New Issue
Block a user