mirror of
https://github.com/Comfy-Org/comfy-python-sdk.git
synced 2026-11-04 23:37:47 +00:00
[PR #52] [MERGED] docs: document from_json/from_str and kind-typed outputs in the README #59
Labels
No labels
audit:ai-readiness
audit:community
audit:github
audit:health-scoring
audit:policy
audit:release
audit:supply-chain
effort:medium
effort:small
effort:small
effort:trivial
priority:nice-to-have
priority:nice-to-have
priority:recommended
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/comfy-python-sdk#59
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Comfy-Org/comfy-python-sdk/pull/52
Author: @mattmillerai
Created: 8/13/2026
Status: ✅ Merged
Merged: 8/24/2026
Merged by: @wei-hai
Base:
main← Head:matt/be-7455-readme-from-json-and-typed-outputs📝 Commits (1)
7278496docs: document from_json/from_str and kind-typed outputs in the README📊 Changes
1 file changed (+47 additions, -2 deletions)
View changed files
📝
README.md(+47 -2)📄 Description
ELI-5
The README only ever showed one way to build a workflow — load
workflow_api.jsonoff disk — and only ever showed saving an image to a file. The SDK can do more than that: you can hand it a graph you built in code, and outputs tell you whether they're an image, a video, audio or text so you can pull them as raw bytes or as a link instead of a file. None of that was written down, so anyone integrating had to read the SDK source to find it. This writes it down. Docs only — no code changed.What changed
Getting started → new "Constructing a workflow" subsection. A three-row table covering
from_file(path)/from_json(graph)/from_str(text), a note that all three are local (no network I/O), and a worked example that builds a graph as adict, callsset_inputon it, submits withclient.run, and pulls the result withto_bytes()— the headless/cron shape with no filesystem round-trip. It also states thatfrom_jsonwraps the dict rather than copying it (sowf.jsonis your graph and stays freely mutable), and thatAsyncComfyexposes the same three constructors.Downloading outputs → new "Outputs are kind-typed" subsection.
output.typeis documented as the normalized kind, alongsidecontent_type/name/size_bytes, with an example that branches across kinds and uses a different retrieval path for each:to_filefor image,to_bytesfor audio,get_download_url()for video, and acase _fallback.to_bytes()andget_download_url()themselves were already documented (#50/#51); what was missing was the kind discriminator and any non-image example — before this, the README's only mentions of audio or video were zero.Verification
ruff check .,ruff format --check .,mypy src,pytest— all green (140 passed, 4 skipped; the skips are the pre-existing integration tests).Beyond the suite, every claim the new prose makes was exercised rather than asserted. I wrote a throwaway pytest module that runs the new snippets verbatim against the repo's own stub server and deleted it before committing (this is a docs-only PR, so it is not in the diff). It confirmed:
from_jsonwraps without copying (wf.json is graph),set_inputmutates that same dict,from_strround-trips the JSON text,to_bytes()returns the served bytes, and a job carrying four outputs typedimage/audio/video/textdispatches correctly through thematchin the example, includingget_download_url().url.The same names were then checked against the published 0.1.8 release (not just this tree), since the acceptance bar is that the examples work on the current published 0.1.x:
WorkflowFactoryhas all three constructors,Outputhasto_file/to_stream/to_bytes/get_download_url/type/content_type/name/size_bytes, andOutputTypeis the same six-value enum.Judgment calls
Six kinds, not four. The brief I worked from named the kinds as
image | video | audio | text. The source of truth — theOutputTypeenum generated fromspec/openapi.yaml— has six:image,video,audio,text,file,latent. I documented the six that exist. Thecase _fallback in the example is deliberate for the same reason: the README isn't covered by the codegen drift check, so a reader who copies the snippet still handles a kind added later.The example graph is abridged and says so. A genuinely runnable API-format graph is roughly seven nodes of checkpoint/CLIP/latent plumbing, which would bury the point of the snippet. It is labelled
(abridged); node9references a node8that isn't shown.Not covered by this PR
Output.to_stream()is still undocumented, deliberately. It has no async twin —AsyncOutput.to_streamdoes not exist on 0.1.8 or on this tree — and the outputs section closes with "AsyncOutputmirrors all of the above withawait", which documenting it there would make false. Writing it up properly means either adding the async method or carving out an exception, and both are outside a docs-only change.comfy_sdkclasses against the README says 6 of 41 distinct names go unmentioned after this change (aclose,as_reference,close,created_new,refresh, and theto_streamabove), down from 10 before it (content_type,from_json,from_strandsize_bytesare the four this PR adds). The sweep is coarse — it matches bare words, so a name liketypecounts as mentioned wherever the English word appears — but it is symmetric across both revisions.src/comfy_sdk/workflows.py,src/comfy_sdk/outputs.pyand the generatedOutputType— but they are named here rather than assumed away.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.