SDK: artifacts work outside a node, run --follow prints status and queue waits, fluksio cancel

save_artifact/load_artifact outside a node use the worker's own store code in
$FLUKSIO_ARTIFACT_DIR or <tmp>/fluksio-artifacts, so a node can be called by
hand. --follow prints status changes and each node's resource wait; the
placer's waiting snapshot now carries the run. fluksio cancel <run>...
This commit is contained in:
2026-10-28 08:07:35 +01:00
parent 4c2df681d3
commit 34243e6902
14 changed files with 274 additions and 27 deletions
+37
View File
@@ -1,5 +1,7 @@
"""What the decorators declare, and what the engine would be given."""
from pathlib import Path
import pytest
from fluksio.flow.schemas import FlowDef
@@ -396,3 +398,38 @@ def test_a_flow_records_the_module_that_declared_it():
# A repository the file is not in has no path to give it.
elsewhere = flow.document({"kind": "python", "repo": "/elsewhere"})["origin"]
assert (elsewhere["declared_in"], elsewhere["module"]) == ("", "")
def test_artifacts_round_trip_outside_a_node(tmp_path, monkeypatch):
"""A node that returns an artifact can be smoke-tested by calling it."""
import fluksio
monkeypatch.setenv("FLUKSIO_ARTIFACT_DIR", str(tmp_path))
ref = fluksio.save_artifact(b"weights", "w.bin", "application/x-test")
assert ref["name"] == "w.bin"
assert ref["size"] == 7
assert ref["media_type"] == "application/x-test"
assert ref["digest"].startswith("sha256:")
assert Path(fluksio.load_artifact(ref)).read_bytes() == b"weights"
assert str(tmp_path) in fluksio.load_artifact(ref)
source = tmp_path / "plot.png"
source.write_bytes(b"png")
assert fluksio.save_artifact(source)["name"] == "plot.png"
def test_the_local_artifact_store_defaults_to_the_temporary_directory(monkeypatch):
import tempfile
import fluksio
# Set and removed again, so the variable the default writes is undone too.
monkeypatch.setenv("FLUKSIO_ARTIFACT_DIR", "")
monkeypatch.delenv("FLUKSIO_ARTIFACT_DIR")
ref = fluksio.save_artifact(b"x" * 3)
assert fluksio.load_artifact(ref).startswith(
str(Path(tempfile.gettempdir()) / "fluksio-artifacts")
)