A node's worker label is worker, so a device is only a paired one

- NodeDef `device`/`device_policy` become `worker`/`worker_policy`, the
  issue `ignored_device` becomes `ignored_worker`, and the SDK's `@node`
  takes `worker=` and `worker_policy=`
- FlowStore._migrate renames the keys in published and draft documents
  once, bumping their version; a queued run's `needs` reads the old key
- placement passes the label as `label`, client regenerated
- docs: worker placement wording, MCP issuer without DOMAIN, device rows in
  the CLI data directory and the API table, device links in compose comments

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Melvin Strobl
2026-10-16 16:56:05 +02:00
co-authored by Claude Opus 5.5
parent f8011d2a8a
commit a9d453c9d9
40 changed files with 215 additions and 178 deletions
+4 -4
View File
@@ -125,8 +125,8 @@ def test_a_published_node_with_no_body_is_reported(store: FlowStore):
assert [i for i in controller.issues if i.code == "missing_source"] == []
def test_a_device_on_a_node_without_code_is_reported(store: FlowStore):
"""Only code travels to a worker, so the device would be ignored silently."""
def test_a_worker_on_a_node_without_code_is_reported(store: FlowStore):
"""Only code travels to a worker, so the worker would be ignored silently."""
store.write_flow(
FlowDef(
name="heating",
@@ -134,7 +134,7 @@ def test_a_device_on_a_node_without_code_is_reported(store: FlowStore):
NodeDef(
id="relay",
type="change",
device="gpu",
worker="gpu",
provides=[MessageSpec(name="temp")],
)
],
@@ -143,7 +143,7 @@ def test_a_device_on_a_node_without_code_is_reported(store: FlowStore):
controller = FlowController(store)
asyncio.run(controller.reload())
(issue,) = [i for i in controller.issues if i.code == "ignored_device"]
(issue,) = [i for i in controller.issues if i.code == "ignored_worker"]
assert issue.node == "heating.relay"
assert issue.advisory
+2 -2
View File
@@ -108,7 +108,7 @@ def test_a_required_label_waits_for_its_machine_rather_than_running_here(loop):
placer = placer_over(hub)
worker, _ = attach(hub, loop, labels=("gpu",))
with placer.claim(Resources(cpus=2), device="gpu", policy="require") as (
with placer.claim(Resources(cpus=2), label="gpu", policy="require") as (
target,
_,
):
@@ -120,7 +120,7 @@ def test_a_preferred_label_falls_back_here_and_is_still_accounted(loop):
hub = RemoteWorkerHub()
placer = placer_over(hub)
with placer.claim(Resources(cpus=3), device="gpu", policy="prefer") as (
with placer.claim(Resources(cpus=3), label="gpu", policy="prefer") as (
target,
allocation,
):
+1 -1
View File
@@ -231,7 +231,7 @@ def test_a_run_held_before_it_starts_still_gets_a_machine_asked_for(monkeypatch)
hpc = cluster()
placer = Placer(local=ResourceAccountant(cpus=4, gpus=0))
placer.provisioners = [hpc]
needs = {"cpus": 2, "gpus": 1, "ram_mb": 0, "device": ""}
needs = {"cpus": 2, "gpus": 1, "ram_mb": 0, "worker": ""}
assert placer.satisfiable(needs) == "1 gpu(s) and 2 cpu(s)"
placer.provision_for(needs)
+8 -8
View File
@@ -378,23 +378,23 @@ def test_the_digest_identifies_the_inputs_not_their_order():
assert digest_of({"a": 1}, 3) != digest_of({"a": 1}, 4)
def test_labels_come_from_the_nodes_that_ask_for_a_device():
def test_labels_come_from_the_nodes_that_ask_for_a_worker():
flow = double_flow()
assert required_labels(flow) == []
flow.nodes[0].device = "gpu"
flow.nodes[0].worker = "gpu"
assert required_labels(flow) == ["gpu"]
def test_a_preferred_device_does_not_hold_a_run_back():
def test_a_preferred_worker_does_not_hold_a_run_back():
flow = double_flow()
flow.nodes[0].device = "gpu"
flow.nodes[0].device_policy = "prefer"
flow.nodes[0].worker = "gpu"
flow.nodes[0].worker_policy = "prefer"
# It runs on the engine when no such worker is attached, so waiting for
# one would be waiting for something the run does not need.
assert required_labels(flow) == []
def test_a_device_on_a_node_no_worker_could_run_is_not_waited_for():
def test_a_worker_on_a_node_no_worker_could_run_is_not_waited_for():
"""A connector is an entry point loaded here, so a worker cannot take it.
Holding the run for one is a run that never starts — and it looked exactly
@@ -402,7 +402,7 @@ def test_a_device_on_a_node_no_worker_could_run_is_not_waited_for():
"""
flow = double_flow()
flow.nodes[0].type = "mqtt"
flow.nodes[0].device = "gpu"
flow.nodes[0].worker = "gpu"
assert required_labels(flow) == []
@@ -416,7 +416,7 @@ def test_what_a_run_needs_is_the_largest_single_machine_it_asks_for():
"cpus": 8,
"gpus": 1,
"ram_mb": 0,
"device": "",
"worker": "",
}
+20
View File
@@ -1,3 +1,4 @@
import json
import os
import subprocess
from datetime import UTC, datetime
@@ -173,3 +174,22 @@ def test_opening_the_store_renames_the_mqtt_publish_queue_size(store: FlowStore)
assert published.nodes[0].params == {"send_queue_size": 8}
assert published.version == 2
assert commit_count(store) == commits + 1
def test_opening_the_store_renames_a_nodes_device_to_worker(store: FlowStore):
"""`device` names a paired device now, so a node's worker label moves over."""
store.write_flow(FlowDef(name="lab", nodes=[NodeDef(id="fit")]))
path = store.root / "lab" / "flow.json"
data = json.loads(path.read_text())
node = data["nodes"][0]
del node["worker"], node["worker_policy"]
node.update(device="gpu", device_policy="prefer")
path.write_text(json.dumps(data))
published = FlowStore(store.root).read_flow("lab")
assert (published.nodes[0].worker, published.nodes[0].worker_policy) == (
"gpu",
"prefer",
)
assert published.version == 2
+5 -5
View File
@@ -17,8 +17,8 @@ def prepare(limit=8):
@node(
requires=["dataset", Port("lr", "float")],
provides=[Port("loss", "float", stream=True), Port("weights", "artifact")],
device="gpu",
device_policy="prefer",
worker="gpu",
worker_policy="prefer",
)
def fit(dataset, lr, epochs=3):
for step in range(epochs):
@@ -68,12 +68,12 @@ def test_defaults_become_settings_and_ports_do_not():
assert {p.port for p in nodes["fit"].requires} == {"dataset", "lr"}
def test_device_travels_to_the_node():
def test_worker_travels_to_the_node():
definition = FlowDef.model_validate(a_flow().document())
node_def = next(n for n in definition.nodes if n.id == "fit")
assert node_def.device == "gpu"
assert node_def.device_policy == "prefer"
assert node_def.worker == "gpu"
assert node_def.worker_policy == "prefer"
def test_a_required_port_takes_the_type_it_is_provided_as():