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>... Claude-Session: https://claude.ai/code/session_01SSi5AvZ7pFmySK8zy3NPMh
This commit is contained in:
@@ -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")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user