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:
@@ -454,6 +454,11 @@ class MetricSink:
|
||||
which drops what it cannot keep up with, and a training curve with holes in
|
||||
it is not a result.
|
||||
|
||||
A batch that has been written announces itself (`on_flush`), which is how a
|
||||
screen watching a run knows there is something new to read. The event
|
||||
carries names rather than numbers: it is a nudge, and the rows are the
|
||||
record. One per batch, so it is nowhere near the per-point path.
|
||||
|
||||
The step is the count of emissions on that message. A node that publishes
|
||||
every tenth training step therefore has steps 0, 1, 2 rather than 0, 10,
|
||||
20 — a faithful x-axis of its own emissions, not of the loop inside it.
|
||||
@@ -464,10 +469,12 @@ class MetricSink:
|
||||
run_id: str,
|
||||
batch: int = METRIC_BATCH,
|
||||
interval: float = METRIC_FLUSH_S,
|
||||
on_flush: Callable[[list[str]], None] | None = None,
|
||||
) -> None:
|
||||
self.run_id = run_id
|
||||
self._batch = batch
|
||||
self._interval = interval
|
||||
self._on_flush = on_flush
|
||||
self._rows: dict[tuple[str, int], RunMetric] = {}
|
||||
self._steps: dict[str, int] = {}
|
||||
self._last_flush = time.monotonic()
|
||||
@@ -508,7 +515,7 @@ class MetricSink:
|
||||
self._rows.clear()
|
||||
self._last_flush = time.monotonic()
|
||||
if rows:
|
||||
self._write(rows)
|
||||
self._written(rows)
|
||||
|
||||
def flush(self) -> None:
|
||||
with self._lock:
|
||||
@@ -516,7 +523,17 @@ class MetricSink:
|
||||
self._rows.clear()
|
||||
self._last_flush = time.monotonic()
|
||||
if rows:
|
||||
self._write(rows)
|
||||
self._written(rows)
|
||||
|
||||
def _written(self, rows: list[RunMetric]) -> None:
|
||||
"""Write a batch, then say that it is there."""
|
||||
self._write(rows)
|
||||
if self._on_flush is None:
|
||||
return
|
||||
try:
|
||||
self._on_flush(sorted({row.name for row in rows}))
|
||||
except Exception:
|
||||
logger.exception("Announcing a batch of run %s failed", self.run_id)
|
||||
|
||||
def _write(self, rows: list[RunMetric]) -> None:
|
||||
try:
|
||||
@@ -1207,7 +1224,18 @@ class RunService:
|
||||
errors += 1
|
||||
self._record_node(run_id, outcome)
|
||||
|
||||
sink = MetricSink(run_id)
|
||||
sink = MetricSink(
|
||||
run_id,
|
||||
on_flush=lambda names: self._publish_event(
|
||||
{
|
||||
"type": "run_metric",
|
||||
"flow": run.flow,
|
||||
"run": run_id,
|
||||
"names": names,
|
||||
"ts": time.time(),
|
||||
}
|
||||
),
|
||||
)
|
||||
try:
|
||||
flow = self.controller.store.read_flow(run.flow, draft=run.draft)
|
||||
# Read again, now that it is this run's turn: a sweep queues every
|
||||
|
||||
Reference in New Issue
Block a user