Repository navigation
feat: add a workflow status view and honor limit on GET /workflows - #238
Merged
Merged
Conversation
Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
kaiitunnz
force-pushed
the
kaiitunnz/confident-dirac-gb2uzj
branch
from
October 17, 2026 08:31
8eaae1b to
e931aa7
Compare
Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Relates to #225; follow-up to #227. Workflow pollers and listers have the same two problems #227 fixed for tasks:
GET /api/v1/workflows/{id}returnstask_idsplus the dispatched, completed, failed and cancelled task-ID lists, so the payload grows with the size of the graph.flowmesh workflow watchandworkflows.wait()poll it on every tick and read onlystatus.GET /api/v1/workflowsignoredlimit. It was treated as an unknown filter key, so every workflow came back, ordered by random uuid4 id.With this PR, a poller can ask for a workflow's status view, which holds per-state task counts instead of the ID lists.
limitkeeps the newest matching workflows, the SDK and CLI pollers use the status view, and both CLI list commands can bound their output.Changes
?view=statusonGET /workflows/{id}andGET /workflowsreturns aWorkflowStatusView(src/server/schemas/workflow.py):workflow_id,status,submitted_atandupdated_at, which match theirWorkflowfields, plustask_count,dispatched_count,completed_count,failed_countandcancelled_count. The default view staysfull.limit.GET /workflowslists workflows oldest submission first, with ties broken by id; asubmitted_atthat can't be parsed sorts oldest.limit(1–10000) keeps the newest matching workflows, applied after filtering and permissions. Neitherviewnorlimitis treated as a field filter.workflows.status(id)andworkflows.list_statuses(...)return status views, sync and async.workflows.list(limit=...).workflows.wait_status()polls until the workflow isDONE,FAILEDorCANCELLEDand returns its status view.workflows.wait()polls the same way, then fetches the full workflow once; its return type is unchanged.flowmesh workflow watchpolls the status view and still prints the full workflow at the end.flowmesh workflow listandflowmesh task listtake--limit N(1–10000), which keeps the newest N matches.docs/API.md,docs/SDK.mdanddocs/CLI.mdcoverview,limit,--limitand the new SDK calls. TheGET /workflowsrow now lists its real filters (workflow_id,status,task_ids);ownerwas listed but isn't aWorkflowfield, so it was silently ignored.Design
The view mirrors #227's opt-in design, so released SDKs keep working. The counts are the only fields with no
Workflowcounterpart. They keep the payload a fixed size while still showing progress; a poller that needs the failed task IDs can calltasks.list_statuses(workflow_id=..., status="FAILED").Because the counts aren't a subset of
Workflow, the SDK'sWorkflowStatusViewderives any missing count from the matching ID list. An older server ignoresviewand returns the full workflow, and that still validates, so the new SDK calls work against any server.Workflows have no
submitted_ts, so the order key parsessubmitted_at, shaped liketask_order.Left for later:
/workflows.limitandviewbound the response, not the reads:GET /workflowsstill reads every accessible workflow before it filters and sorts, asGET /tasksdoes.Test Plan
Test Result
uv run pre-commit run --all-files: passed (gitleaks, isort, black, ruff, codespell, mypy, and requirements sync).uv run pytest tests/ --ignore=tests/worker/test_mp_executor_cleanup_gpu.py: 3091 passed, 54 skipped.Workflowcounterpart;viewbeing a 422 on both routes, andlimit=0andlimit=10001being 422s;submitted_atsorting oldest,limitkeeping the newest, andlimitapplying after astatusfilter and after permissions;status(),list_statuses()andwait()requestingview=status, sync and async, withwait()then fetching the full workflow once;list(limit=)sendinglimitwithoutview;flowmesh workflow watchpolling the status view and printing the full workflow once;flowmesh workflow list --limitandflowmesh task list --limitforwarding the limit, defaulting to none, and rejecting out-of-range values before calling the server.echo_local.yamlandecho_three_node_graph.yamlworkflows ran to DONE and a graph with a failing python node ended FAILED; for each, the status view held exactly its fields, matched the full workflow on the shared ones, and had each count equal to its list's length.GET /workflowslisted them in submission order,limitkept the newest afterstatus,workflow_idandtask_idsfilters, and badviewandlimitvalues got 422s. The sync and async SDK calls returned the right types and values, and the server's access log showedwait()polling?view=statusand fetching the full workflow once.flowmesh workflow list --limitandflowmesh task list --limitprinted the newest matches and rejected out-of-range values.flowmesh workflow watchon a runningssh_debug_shell.yamlworkflow followed it to CANCELLED afterflowmesh workflow cancel, polling the status view and fetching the full workflow exactly once.Pre-submission Checklist
pre-commit run --all-filesand fixed any issues.uv run pytest tests/passes locally.uv sync --all-packages --group ci --frozen).[BREAKING]and described migration steps above.