"""Scoring what was trained.""" from __future__ import annotations import json import fluksio from fluksio import Port, node def score(lr: float, epochs: int) -> float: """How good the model came out, with no Fluksio in it.""" return round(1 - lr / (1 + epochs), 4) @node(requires=["weights"], provides=Port("score", "float")) def evaluate(weights): """Score the model, returning the number rather than a dict. `provides=Port(...)` — one port rather than a list of them — is the opt-in to a bare return: the generated node wraps it in the message it belongs to. """ trained = json.loads(open(fluksio.load_artifact(weights)).read()) return score(trained["lr"], trained["epochs"])