"""Scoring what was trained.""" from __future__ import annotations import json import fluksio from fluksio import Port, node @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 round(1 - trained["lr"] / (1 + trained["epochs"]), 4)