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:
@@ -9,6 +9,14 @@ import fluksio
|
||||
from fluksio import Port, node
|
||||
|
||||
|
||||
def train_curve(lr: float, epochs: int) -> list[float]:
|
||||
"""The loss per epoch, with no Fluksio in it."""
|
||||
return [
|
||||
math.exp(-lr * epoch * 10) * (1 + 0.05 * (epoch % 3)) / (1 + lr)
|
||||
for epoch in range(epochs)
|
||||
]
|
||||
|
||||
|
||||
@node(
|
||||
requires=["dataset", Port("lr", "float")],
|
||||
provides=[
|
||||
@@ -38,8 +46,7 @@ def fit(dataset, lr, epochs=25):
|
||||
"""
|
||||
rows = json.loads(open(fluksio.load_artifact(dataset)).read())["rows"]
|
||||
loss = 1.0
|
||||
for epoch in range(epochs):
|
||||
loss = math.exp(-lr * epoch * 10) * (1 + 0.05 * (epoch % 3)) / (1 + lr)
|
||||
for loss in train_curve(lr, epochs):
|
||||
yield {"loss": loss}
|
||||
weights = json.dumps({"lr": lr, "epochs": epochs, "n": len(rows)}).encode()
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user