[PR #45] [CLOSED] feat: add embed_workflow to embed the graph in output metadata #53

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

📋 Pull Request Information

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

Base: main ← Head: wei/be-7128-embed-workflow-metadata


📝 Commits (1)

  • 8983b26 feat: add embed_workflow option to embed the API-format graph in output metadata

📊 Changes

5 files changed (+140 additions, -14 deletions)

View changed files

📝 README.md (+25 -1)
📝 src/comfy_sdk/_core.py (+17 -8)
📝 src/comfy_sdk/client.py (+13 -5)
📝 tests/test_async.py (+28 -0)
📝 tests/test_jobs.py (+57 -0)

📄 Description

Recovering the workflow from an image it produced isn't possible today, which makes debugging harder. Adds an opt-in flag.

flowchart LR
  W["workflow"] --> M["materialize<br/>(assets → core/ASSET)"]
  M --> G["graph"]
  G -- "workflow" --> R["POST /jobs"]
  G -- "extra_data.extra_pnginfo.workflow<br/>(only if embed_workflow)" --> R
  R --> P["PNG: workflow chunk"]

submit() and run() — sync and async — take a keyword-only embed_workflow: bool = False. When set, the SDK sends the materialized graph as extra_data.extra_pnginfo.workflow, the key local ComfyUI's SaveImage writes into output PNG metadata.

Behavior

  • Off by default. With no api_key and the flag off, the wire format is byte-identical to today: no extra_data at all, never {}. Existing tests pinning this are untouched.
  • Merges with the partner-node key when both are given.
  • Embeds the materialized graph — the same object sent as workflow — not the caller's input. A test asserts the core/ASSET substitution actually happened, so it can't pass by embedding the wrong object.

Reviewer notes

  • Needs the matching server-side contract change, landing separately — don't merge this first, or the flag is a no-op.
  • spec/openapi.yaml is untouched by design (synced one-way); it picks the field up on the next sync.
  • The TypeScript SDK ships the same feature as embedWorkflow, producing identical bytes.

ruff, mypy, pytest (133 passed, 4 pre-existing skips), spec-drift and hygiene checks all clean.

🤖 Generated with Claude Code


🔄 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/45 **Author:** [@wei-hai](https://github.com/wei-hai) **Created:** 8/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `wei/be-7128-embed-workflow-metadata` --- ### 📝 Commits (1) - [`8983b26`](https://github.com/Comfy-Org/comfy-python-sdk/commit/8983b26f927c5a54957d35e6305e0b3bbd9960b4) feat: add embed_workflow option to embed the API-format graph in output metadata ### 📊 Changes **5 files changed** (+140 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+25 -1) 📝 `src/comfy_sdk/_core.py` (+17 -8) 📝 `src/comfy_sdk/client.py` (+13 -5) 📝 `tests/test_async.py` (+28 -0) 📝 `tests/test_jobs.py` (+57 -0) </details> ### 📄 Description Recovering the workflow from an image it produced isn't possible today, which makes debugging harder. Adds an opt-in flag. ```mermaid flowchart LR W["workflow"] --> M["materialize<br/>(assets → core/ASSET)"] M --> G["graph"] G -- "workflow" --> R["POST /jobs"] G -- "extra_data.extra_pnginfo.workflow<br/>(only if embed_workflow)" --> R R --> P["PNG: workflow chunk"] ``` `submit()` and `run()` — sync and async — take a keyword-only `embed_workflow: bool = False`. When set, the SDK sends the materialized graph as `extra_data.extra_pnginfo.workflow`, the key local ComfyUI's `SaveImage` writes into output PNG metadata. ## Behavior - Off by default. With no `api_key` and the flag off, the wire format is byte-identical to today: no `extra_data` at all, never `{}`. Existing tests pinning this are untouched. - Merges with the partner-node key when both are given. - Embeds the **materialized** graph — the same object sent as `workflow` — not the caller's input. A test asserts the `core/ASSET` substitution actually happened, so it can't pass by embedding the wrong object. ## Reviewer notes - Needs the matching server-side contract change, landing separately — **don't merge this first**, or the flag is a no-op. - `spec/openapi.yaml` is untouched by design (synced one-way); it picks the field up on the next sync. - The TypeScript SDK ships the same feature as `embedWorkflow`, producing identical bytes. `ruff`, `mypy`, `pytest` (133 passed, 4 pre-existing skips), spec-drift and hygiene checks all clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <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:02 +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#53
No description provided.