Make the example's __main__ actually run

It claimed to run the pipeline with no engine involved, and could not: the
node bodies it called save and load artifacts, which raise outside a node by
design. Each node is now a thin wrapper over a plain function — make_rows,
train_curve, score — and __main__ calls those, which is the split the sandbox
already demonstrates and the one worth copying.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-26 22:57:36 +02:00
co-authored by Claude Opus 5
parent 4f3eaf950c
commit 8f71b638b6
5 changed files with 45 additions and 19 deletions
+12 -4
View File
@@ -8,6 +8,14 @@ import fluksio
from fluksio import Port, node
def make_rows(source: str = "builtin", limit: int = 512) -> dict:
"""The training set itself, with no Fluksio in it."""
return {
"source": source,
"rows": [{"x": index / limit, "y": (index % 7) / 7} for index in range(limit)],
}
@node(provides=[Port("dataset", "artifact"), Port("rows", "int")])
def prepare(source: str = "builtin", limit: int = 512):
"""Make the training set and store it, returning a reference to it.
@@ -15,11 +23,11 @@ def prepare(source: str = "builtin", limit: int = 512):
`source` and `limit` have defaults and are not ports, so they become the
node's settings: the canvas can tune them without touching this file.
"""
rows = [{"x": index / limit, "y": (index % 7) / 7} for index in range(limit)]
payload = json.dumps({"source": source, "rows": rows}).encode()
payload = make_rows(source, limit)
blob = json.dumps(payload).encode()
return {
"dataset": fluksio.save_artifact(payload, "dataset.json", "application/json"),
"rows": len(rows),
"dataset": fluksio.save_artifact(blob, "dataset.json", "application/json"),
"rows": len(payload["rows"]),
}