[PR #47] [CLOSED] feat: add get_workflow() to fetch the graph that produced a job #54

Closed
opened 2026-10-31 22:01:03 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/comfy-python-sdk/pull/47
Author: @wei-hai
Created: 8/13/2026
Status: ❌ Closed

Base: main ← Head: wei/fetch-job-workflow


📝 Commits (1)

  • ee2155d feat: add get_workflow() to fetch the graph that produced a job

📊 Changes

5 files changed (+172 additions, -2 deletions)

View changed files

📝 src/comfy_low/transport.py (+26 -0)
📝 src/comfy_sdk/__init__.py (+2 -1)
📝 src/comfy_sdk/jobs.py (+44 -1)
📝 tests/conftest.py (+20 -0)
➕ tests/test_job_workflow.py (+80 -0)

📄 Description

A caller holding a job — including one rehydrated by id — has no way to see the workflow behind it. The SDK holds the graph only when it submitted the job in the same process; otherwise it's gone.

flowchart LR
  subgraph B["Before"]
    J1["job (rehydrated by id)"] -. "?" .-> W1["workflow"]
  end
  subgraph A["After"]
    J2["job"] -- "GET /jobs/{id}/workflow" --> W2["workflow + format"]
  end

What it returns

Both the graph and the format discriminator, never just the graph:

  • api — the executed graph. Editor-only constructs (Note nodes, Get/Set) are already resolved away.
  • save — the authoring workflow at the version the job ran, un-mangled. Only for jobs that pin a workflow version; jobs submitted through this SDK today always get api.

Callers must branch on format — which shape comes back depends on how the job was submitted, not on anything the caller controls.

Server side is merged

GET /api/v2/jobs/{id}/workflow landed in Comfy-Org/cloud#6642, so this now works against a live server.

One follow-up, deliberately not done here

The transport call is written by hand, because the vendored spec didn't describe the operation when this was written. The spec-sync PR carrying it is open in this repo — once that merges, this call should move onto the generated client and the hand-written request dropped. A comment in the code marks the spot.

Keeping the two separate so this PR stays reviewable on its own; spec/openapi.yaml and spec/VERSION are untouched here and the drift check passes.

Naming

Matches the existing get_download_url / getDownloadUrl precedent for a network-fetching accessor, and the two SDKs stay in lockstep.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added workflow retrieval for synchronous and asynchronous jobs.
    • Workflows are available in API and save formats, including graph data.
    • Added public workflow models and package-level access.
    • Supports retrieving workflows from rehydrated jobs and handling missing workflows.
  • Bug Fixes

    • Missing workflows now consistently raise the SDK’s not-found error.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/comfy-python-sdk/pull/47 **Author:** [@wei-hai](https://github.com/wei-hai) **Created:** 8/13/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `wei/fetch-job-workflow` --- ### 📝 Commits (1) - [`ee2155d`](https://github.com/Comfy-Org/comfy-python-sdk/commit/ee2155d984d9cc946e54382bf5ae252ad22e9d2d) feat: add get_workflow() to fetch the graph that produced a job ### 📊 Changes **5 files changed** (+172 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/comfy_low/transport.py` (+26 -0) 📝 `src/comfy_sdk/__init__.py` (+2 -1) 📝 `src/comfy_sdk/jobs.py` (+44 -1) 📝 `tests/conftest.py` (+20 -0) ➕ `tests/test_job_workflow.py` (+80 -0) </details> ### 📄 Description A caller holding a job — including one rehydrated by id — has no way to see the workflow behind it. The SDK holds the graph only when it submitted the job in the same process; otherwise it's gone. ```mermaid flowchart LR subgraph B["Before"] J1["job (rehydrated by id)"] -. "?" .-> W1["workflow"] end subgraph A["After"] J2["job"] -- "GET /jobs/{id}/workflow" --> W2["workflow + format"] end ``` ## What it returns Both the graph **and** the `format` discriminator, never just the graph: - **`api`** — the executed graph. Editor-only constructs (Note nodes, Get/Set) are already resolved away. - **`save`** — the authoring workflow at the version the job ran, un-mangled. Only for jobs that pin a workflow version; jobs submitted through this SDK today always get `api`. Callers must branch on `format` — which shape comes back depends on how the job was submitted, not on anything the caller controls. ## Server side is merged `GET /api/v2/jobs/{id}/workflow` landed in Comfy-Org/cloud#6642, so this now works against a live server. ## One follow-up, deliberately not done here The transport call is written by hand, because the vendored spec didn't describe the operation when this was written. The spec-sync PR carrying it is open in this repo — once that merges, this call should move onto the generated client and the hand-written request dropped. A comment in the code marks the spot. Keeping the two separate so this PR stays reviewable on its own; `spec/openapi.yaml` and `spec/VERSION` are untouched here and the drift check passes. ## Naming Matches the existing `get_download_url` / `getDownloadUrl` precedent for a network-fetching accessor, and the two SDKs stay in lockstep. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added workflow retrieval for synchronous and asynchronous jobs. * Workflows are available in API and save formats, including graph data. * Added public workflow models and package-level access. * Supports retrieving workflows from rehydrated jobs and handling missing workflows. * **Bug Fixes** * Missing workflows now consistently raise the SDK’s not-found error. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 22:01:03 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/comfy-python-sdk#54
No description provided.