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:
@@ -23,6 +23,8 @@ from collections.abc import Callable, Sequence
|
||||
from pathlib import Path
|
||||
from typing import Any, TypeVar
|
||||
|
||||
from fluksio.sdk.imports import digest_of, reached
|
||||
|
||||
__all__ = [
|
||||
"FLOWS",
|
||||
"Flow",
|
||||
@@ -549,6 +551,18 @@ def _check(spec: NodeSpec, mode: str) -> dict[str, Any]:
|
||||
}
|
||||
|
||||
|
||||
def _code_of(spec: NodeSpec) -> dict[str, Any]:
|
||||
"""What this node's function calls into, which its shim does not say.
|
||||
|
||||
Read here rather than when the flow is declared, so a second `sync()` in
|
||||
one process — a notebook — sees the edit that happened between them. This
|
||||
side is the only one that can work it out at all: it has imported the
|
||||
code, and the engine never does.
|
||||
"""
|
||||
files = reached(spec.fn)
|
||||
return {"code_files": files, "code_digest": digest_of(files)}
|
||||
|
||||
|
||||
def _serialisable(value: Any) -> bool:
|
||||
try:
|
||||
json.dumps(value)
|
||||
@@ -676,7 +690,10 @@ class Flow:
|
||||
"name": self.name,
|
||||
"title": self.title,
|
||||
"mode": self.mode,
|
||||
"nodes": self._nodes,
|
||||
"nodes": [
|
||||
node | _code_of(spec)
|
||||
for spec, node in zip(self.nodes, self._nodes, strict=True)
|
||||
],
|
||||
"inputs": [
|
||||
{"spec": port.spec(), "initial": port.initial} for port in self.inputs
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user