Start, stop and pause flows, and show what their nodes print
Flows can now be taken off the engine and put back. Stopped state lives in a runtime.json beside the flow, not in the flow document: the canvas autosaves that document, so a stopped flow would otherwise start itself again on the next edit. A stopped flow gets no subscriptions, schedules or webhooks, its nodes are skipped by the scheduler, and running it answers 409. Pausing holds a flow's nodes while its values keep arriving, so the canvas still shows what is coming in. Node code is user code and print is how it says things, so stdout is teed through a contextvar sink active only during a node execution — one event per execution, capped, so a chatty node cannot outrun the stream. A node that fails sends its traceback the same way, trimmed to the author's own frames. The dock gains a logs panel and a pause control; the dashboard replaces its placeholder with what is running, stopped or failing; the edge inspector can send the last message again. Single-stepping is deferred and noted: the scheduler keeps no progress between calls, so a step button would re-run the same node rather than advance. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
606ab3c423
commit
7344eac262
@@ -193,6 +193,71 @@ def test_discarding_a_draft_restores_what_is_running(
|
||||
client.delete(f"{PREFIX}/reverted", headers=superuser_token_headers)
|
||||
|
||||
|
||||
def test_stopping_a_flow_takes_it_off_the_engine(
|
||||
client: TestClient, superuser_token_headers: dict[str, str]
|
||||
) -> None:
|
||||
saved = client.put(
|
||||
f"{PREFIX}/halted", headers=superuser_token_headers, json=a_flow("halted")
|
||||
).json()
|
||||
client.post(
|
||||
f"{PREFIX}/halted/publish",
|
||||
headers=superuser_token_headers,
|
||||
json={"version": saved["definition"]["version"]},
|
||||
)
|
||||
|
||||
stopped = client.post(f"{PREFIX}/halted/stop", headers=superuser_token_headers)
|
||||
assert stopped.status_code == 200
|
||||
assert stopped.json()["enabled"] is False
|
||||
# Nothing of it is loaded, so there is nothing to run.
|
||||
assert (
|
||||
client.post(
|
||||
f"{PREFIX}/halted/run", headers=superuser_token_headers, json={"inputs": {}}
|
||||
).status_code
|
||||
== 409
|
||||
)
|
||||
|
||||
started = client.post(f"{PREFIX}/halted/start", headers=superuser_token_headers)
|
||||
assert started.json()["enabled"] is True
|
||||
assert (
|
||||
client.post(
|
||||
f"{PREFIX}/halted/run", headers=superuser_token_headers, json={"inputs": {}}
|
||||
).status_code
|
||||
== 200
|
||||
)
|
||||
|
||||
client.delete(f"{PREFIX}/halted", headers=superuser_token_headers)
|
||||
|
||||
|
||||
def test_pausing_is_reported_back(
|
||||
client: TestClient, superuser_token_headers: dict[str, str]
|
||||
) -> None:
|
||||
saved = client.put(
|
||||
f"{PREFIX}/held", headers=superuser_token_headers, json=a_flow("held")
|
||||
).json()
|
||||
client.post(
|
||||
f"{PREFIX}/held/publish",
|
||||
headers=superuser_token_headers,
|
||||
json={"version": saved["definition"]["version"]},
|
||||
)
|
||||
|
||||
assert (
|
||||
client.post(f"{PREFIX}/held/pause", headers=superuser_token_headers).status_code
|
||||
== 200
|
||||
)
|
||||
assert (
|
||||
client.get(f"{PREFIX}/held", headers=superuser_token_headers).json()["paused"]
|
||||
is True
|
||||
)
|
||||
|
||||
client.post(f"{PREFIX}/held/resume", headers=superuser_token_headers)
|
||||
assert (
|
||||
client.get(f"{PREFIX}/held", headers=superuser_token_headers).json()["paused"]
|
||||
is False
|
||||
)
|
||||
|
||||
client.delete(f"{PREFIX}/held", headers=superuser_token_headers)
|
||||
|
||||
|
||||
def test_unconnected_input_is_surfaced(
|
||||
client: TestClient, superuser_token_headers: dict[str, str]
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user