Key a node on the code it reaches, not on the repository around it
Docs / docs (push) Successful in 21s
Playwright Tests / test-playwright (1, 2) (push) Successful in 2m13s
Playwright Tests / test-playwright (2, 2) (push) Successful in 1m52s
pre-commit / pre-commit (push) Failing after 2m6s
Test Backend / test-backend (push) Successful in 2m30s
Compose Smoke Test / test-compose (push) Successful in 32s
Playwright Tests / merge-reports (push) Successful in 1m53s
Docs / docs (push) Successful in 21s
Playwright Tests / test-playwright (1, 2) (push) Successful in 2m13s
Playwright Tests / test-playwright (2, 2) (push) Successful in 1m52s
pre-commit / pre-commit (push) Failing after 2m6s
Test Backend / test-backend (push) Successful in 2m30s
Compose Smoke Test / test-compose (push) Successful in 32s
Playwright Tests / merge-reports (push) Successful in 1m53s
`sync` follows each node function's imports through the project's own modules — stopping at the standard library, at anything installed, and at Fluksio itself, whose checkout would otherwise be most of every digest — and records the file list with what it hashed to. The engine hashes those files again when the run is claimed, so the fingerprint is live rather than a snapshot, and falls back to what sync recorded when it cannot see them: a remote worker's runs used to share one empty digest, and therefore one key. Three things follow. Editing a helper a node calls into re-runs that node, as before. Editing something the node never reaches no longer re-runs anything — a notebook two directories away was invalidating every arm. And `Run.code_digest` is now the hash of its nodes' digests, so it is neither looser nor tighter than "the code behind these numbers", which is what makes it worth joining an exported table on. `sync` says so too: it compares the per-node digest against the stored one, so a helper edit prints `train: updated (flow, fit)` instead of `unchanged`. The digest is read when the document is built rather than when the flow is declared, so a second `sync()` in one process sees an edit between them. Also: `fluksio runs` shows only the inputs that differ from what the flow declares, fitted to the terminal, so a flow taking a few kB of json no longer wraps every line. Every existing cache entry misses once — the fingerprint changed shape. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A9Hdrmf2cwNABCnE5x9UJa
This commit is contained in:
@@ -14,9 +14,10 @@ import importlib
|
||||
import itertools
|
||||
import json
|
||||
import pkgutil
|
||||
import shutil
|
||||
import sys
|
||||
import time
|
||||
from collections.abc import Callable, Iterator
|
||||
from collections.abc import Callable, Iterable, Iterator
|
||||
from contextlib import contextmanager, nullcontext
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
@@ -744,11 +745,36 @@ def cmd_status(args: argparse.Namespace) -> int:
|
||||
return _unreachable(exc)
|
||||
|
||||
|
||||
#: How much of a run's inputs the list shows. A flow taking a few kB of JSON
|
||||
#: would otherwise make the table unreadable; `client.runs()` is where the
|
||||
#: whole value is read.
|
||||
#: How much of a run's inputs the list shows when nothing says how wide the
|
||||
#: terminal is. `client.runs()` and `fluksio export runs` are where the whole
|
||||
#: value is read.
|
||||
PARAMS_WIDTH = 80
|
||||
|
||||
#: What the columns before the inputs take: the id, status, flow, duration and
|
||||
#: stamp, with their spacing.
|
||||
LISTING_WIDTH = 84
|
||||
|
||||
|
||||
def _declared(client: Client, flows: Iterable[str]) -> dict[str, dict[str, Any]]:
|
||||
"""What each flow declares its inputs to be, by flow.
|
||||
|
||||
So the listing can leave out an input that is simply the declared value:
|
||||
what a reader is looking for across a page of runs is where they differ,
|
||||
and a flow taking a few kB of JSON crowds that off the line.
|
||||
"""
|
||||
known: dict[str, dict[str, Any]] = {}
|
||||
for name in flows:
|
||||
try:
|
||||
stored = client.get_flow(name) or {}
|
||||
except (SyncError, ApiError, httpx.HTTPError):
|
||||
# A flow deleted since its runs were recorded still lists them.
|
||||
stored = {}
|
||||
known[name] = {
|
||||
str((entry.get("spec") or {}).get("name", "")): entry.get("initial")
|
||||
for entry in (stored.get("definition") or {}).get("inputs") or []
|
||||
}
|
||||
return known
|
||||
|
||||
|
||||
def _stamp(row: dict[str, Any]) -> str:
|
||||
"""What code a run ran: the commit, whether it was dirty, and the digest.
|
||||
@@ -767,14 +793,29 @@ def cmd_runs(args: argparse.Namespace) -> int:
|
||||
try:
|
||||
with _client_for(args, retries=0) as client:
|
||||
rows = client.runs(flow=args.flow, limit=args.limit)
|
||||
declared = _declared(client, {str(row["flow"]) for row in rows})
|
||||
except (SyncError, ApiError) as exc:
|
||||
return _fail(str(exc))
|
||||
except httpx.HTTPError as exc:
|
||||
return _unreachable(exc)
|
||||
# Whatever is left of the line after the fixed columns; the fallback is
|
||||
# what a pipe gets, since there is no width to ask for there.
|
||||
room = max(
|
||||
20,
|
||||
shutil.get_terminal_size((LISTING_WIDTH + PARAMS_WIDTH, 24)).columns
|
||||
- LISTING_WIDTH,
|
||||
)
|
||||
for row in rows:
|
||||
params = json.dumps(row["params"])
|
||||
if len(params) > PARAMS_WIDTH:
|
||||
params = params[: PARAMS_WIDTH - 3] + "..."
|
||||
given = row["params"] or {}
|
||||
defaults = declared.get(str(row["flow"])) or {}
|
||||
shown = {
|
||||
name: value
|
||||
for name, value in given.items()
|
||||
if name not in defaults or defaults[name] != value
|
||||
}
|
||||
params = json.dumps(shown)
|
||||
if len(params) > room:
|
||||
params = params[: room - 3] + "..."
|
||||
_say(
|
||||
f"{row['id']} {_status(row['status'], 9)} {row['flow']:<16} "
|
||||
f"{row['duration_ms'] / 1000:7.1f}s {_stamp(row):<22} {params}"
|
||||
|
||||
Reference in New Issue
Block a user