You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d4d340d
Browse filesBrowse the repository at this point in the historyBrowse files
authored
Provide API endpoint for Workflow graph (actually an endpoint for each subgraph) (#13524)
* Add design plan for Workflow HTTP API endpoints
Plan-only commit: expose each workflow subject as a named Gradio
endpoint reusing /info, /call, and /api. Registration via explicit
non-rendered components (B2). No implementation yet.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Workflow API: server-side executor + per-subject endpoints (B2)
Phases 1-3 of the plan:
- gradio/workflow_api.py: schema-v2 graph model, topo-sort, upstream-subgraph
and free-input extraction (ports of the canvas's workflow-graph.ts), plus a
Python WorkflowExecutor that runs a subject's upstream DAG by reusing the
existing call_space/call_model/call_fn/fetch_dataset server functions.
- Register one named API endpoint per subject via hidden real components (B2),
reusing Gradio's /info + /call. Endpoint execution re-reads the current
workflow.json so operator/wiring edits are live; the endpoint set + schema is
a launch-time snapshot for now.
- Tests cover graph parsing, topo/cycle, subgraph + free inputs, end-to-end
execution (callers mocked), /info schema, and request/token injection.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Workflow API: live endpoint updates on save (Option 2)
Replace the static registration with a WorkflowEndpointManager that re-derives
the endpoint set on every save_workflow: it tears down the prior endpoints
(unrender() their components + drop their event triggers from blocks.fns) and
rebuilds from the saved graph, then refreshes the cached config and invalidates
the App's /info cache. Adding, removing, renaming, or retyping an output now
updates /info + /call live without a restart.
To mutate the running Blocks safely we set the render context directly
(Context.root_block/block) instead of `with self:`, whose __exit__ would re-run
attach_load_events (duplicating the canvas's callable-value load event) and
recreate the running App.
Tests: add/remove/rename outputs reflect in get_api_info(), no fn leak after
removal, and save_workflow triggers the re-sync.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Workflow API: 2-subject demo, end-to-end /call test, dataset hardening
- demo/workflow_api: a self-contained workflow with two outputs (Loud,
Reversed) fed by bound fn operators — exposes /loud and /reversed.
- Tests: gradio_client end-to-end against real /info + /call (skipped unless
the frontend is built, as it fetches the root page), plus a TestClient check
that /gradio_api/info lists the endpoints (runs without a frontend build).
- Harden dataset-operator output mapping ({src: url} cells -> file values).
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Workflow API: "View API" panel + describe endpoint
- Add get_workflow_api server function + describe_workflow_api(), returning
one descriptor per output (api_name, typed params, return) — re-read live so
it tracks edits. Registration now shares _slug_iter() so described names
match registered ones exactly.
- Frontend: WorkflowApiPanel.svelte, a canvas-styled overlay (dark theme,
JetBrains Mono) opened from a "View API" toolbar button. Lists each output's
endpoint with parameter/return types and copyable Python / JavaScript / curl
snippets, language-toggle, against the app's own URL.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* changes
* changes
* Fix prettier formatting in workflow-graph countSubgraphs test
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Fix ty typecheck errors in workflow API
- Annotate Workflow._api_endpoints as WorkflowEndpointManager | None and
narrow directly so .sync() typechecks
- Assert _api_endpoints / view_api dict result in tests before subscripting
- Guard os.path.dirname against gr.__file__ being None
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Fix call_fn signature to match caller convention
The API executor invokes every caller as caller(data, request, token),
but call_fn only accepted (data, token), so calling an fn-backed workflow
endpoint via the Gradio client raised a TypeError. Align call_fn with
call_space/call_model/fetch_dataset's (data, request, token) signature.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Fix workflow API panel and schema validation
* Use server OAuth fallback for workflow text generation
* changes
* changes
* changes
* Update changeset: endpoint per subgraph, not per output
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Fix test_save_allowed_with_write_access: use valid schema_version 2 payload
save_workflow now validates schema_version; the gating test's legacy
{"nodes": []} stub no longer passes validation.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
* Address Copilot review: map file ports + per-subgraph wording
- port_to_component: map 'file' ports to gr.File(type='filepath') instead of
falling through to Textbox, so /info schema matches _PY_TYPE/MEDIA_PORT_TYPES
(+ regression test)
- WorkflowApiPanel subtitle + get_workflow_api docstring: 'one endpoint per
output' -> 'per subgraph', matching the per-subgraph endpoint grouping
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
feat:Run`gr.Workflow` subgraphs via the Gradio API — each subgraph is exposed as a named endpoint (returning all of its outputs) reusing `/info`, `/call`, and `/api`, with a "View API" panel in the canvas
0 commit comments