History is kept by flow id: runs, cascades, rollups and events file the id in their flow column and nodes as <flow id>.<node>, the API answers flow plus flow_name and shows and takes nodes as <key>.<node>; events carry flow_id from the moment they are published; run queue items, the stage cache and cached curves keep ids and keys apart; endpoints, the brain graph, device bindings and search name the id to open
This commit is contained in:
@@ -303,7 +303,7 @@ def test_delete_flow(
|
||||
put_flow(client, superuser_token_headers, a_flow(), "demo")
|
||||
# Finished: a flow with a live run refuses to be deleted, which is its own
|
||||
# test below.
|
||||
db.add(Run(id="run-1", flow="demo", status="ok", created_at=datetime.now(UTC)))
|
||||
db.add(Run(id="run-1", flow_id="demo", status="ok", created_at=datetime.now(UTC)))
|
||||
db.add(RunNode(run_id="run-1", node="sensor"))
|
||||
db.add(RunMetric(run_id="run-1", name="loss", step=-1))
|
||||
db.add(RunArtifact(run_id="run-1", name="model.pt"))
|
||||
@@ -335,7 +335,12 @@ def test_delete_flow_is_refused_while_a_run_is_live(
|
||||
) -> None:
|
||||
put_flow(client, superuser_token_headers, a_flow(), "demo")
|
||||
db.add(
|
||||
Run(id="run-live", flow="demo", status="running", created_at=datetime.now(UTC))
|
||||
Run(
|
||||
id="run-live",
|
||||
flow_id="demo",
|
||||
status="running",
|
||||
created_at=datetime.now(UTC),
|
||||
)
|
||||
)
|
||||
db.commit()
|
||||
|
||||
@@ -506,30 +511,35 @@ def test_saving_a_header_moves_the_node_ports_in_the_draft(
|
||||
def test_a_shared_node_in_use_is_retired_only_with_detach(
|
||||
client: TestClient, superuser_token_headers: dict[str, str]
|
||||
) -> None:
|
||||
put_flow(client, superuser_token_headers, a_flow("shared"), "shared")
|
||||
# Under an id that is not its key: the library names nodes by key.
|
||||
put_flow(client, superuser_token_headers, a_flow("shared"), "x_shared")
|
||||
client.put(
|
||||
f"{PREFIX}/shared/nodes/sensor/source",
|
||||
f"{PREFIX}/x_shared/nodes/sensor/source",
|
||||
headers=superuser_token_headers,
|
||||
json={"code": WORKING_NODE},
|
||||
)
|
||||
client.post(
|
||||
f"{PREFIX}/shared/nodes/sensor/share",
|
||||
f"{PREFIX}/x_shared/nodes/sensor/share",
|
||||
headers=superuser_token_headers,
|
||||
json={"lib_name": "reading"},
|
||||
)
|
||||
(shared,) = client.get(f"{PREFIX}/library", headers=superuser_token_headers).json()
|
||||
assert shared["used_by"] == ["shared.sensor"]
|
||||
|
||||
url = f"{PREFIX}/library/reading"
|
||||
assert client.delete(url, headers=superuser_token_headers).status_code == 409
|
||||
refused = client.delete(url, headers=superuser_token_headers)
|
||||
assert refused.status_code == 409
|
||||
assert "shared.sensor" in refused.json()["detail"]
|
||||
response = client.delete(f"{url}?detach=true", headers=superuser_token_headers)
|
||||
assert response.status_code == 200
|
||||
|
||||
assert client.get(f"{PREFIX}/library", headers=superuser_token_headers).json() == []
|
||||
source = client.get(
|
||||
f"{PREFIX}/shared/nodes/sensor/source", headers=superuser_token_headers
|
||||
f"{PREFIX}/x_shared/nodes/sensor/source", headers=superuser_token_headers
|
||||
)
|
||||
assert source.json()["code"] == WORKING_NODE
|
||||
|
||||
client.delete(f"{PREFIX}/shared", headers=superuser_token_headers)
|
||||
client.delete(f"{PREFIX}/x_shared", headers=superuser_token_headers)
|
||||
|
||||
|
||||
def test_a_shared_node_only_the_published_flow_uses_is_kept(
|
||||
|
||||
Reference in New Issue
Block a user