Add your description here
Project description
Comfy Nodekit
Utilities for working with ComfyUI node graphs from Python. The project provides typed wrappers around ComfyUI nodes, lightweight graph primitives, and helpers for exporting a workflow back to the JSON format that the ComfyUI API expects.
- Typed
NodeandEdgemodels (Pydantic) for tracking dependencies and serialising graphs. - A generated
nodes.pymodule that mirrors the ComfyUI node catalogue with Python callables. - Tooling (
nodes_to_py.py) to regenerate those bindings directly from a running ComfyUI server. - Example workflow builder scaffolding that shows how to stitch nodes into higher-level pipelines.
Requirements
- Python 3.12+
requestsandpydantic(installed automatically when the package is installed)- Access to a running ComfyUI server when regenerating node bindings
Installation
uv venv
source .venv/bin/activate
uv pip install -e .
uv is used in this repository because the pyproject.toml declares the uv_build backend. If you prefer pip, install the dependencies (requests, pydantic) manually and run Python with your environment of choice.
Usage
Create nodes the same way you would wire a ComfyUI graph. Each factory function from nodes.py returns a typed Edge that keeps track of its originating node. When you are ready to export the workflow, grab the source_node of your terminal edge and call build_json_workflow().
from comfy_nodekit.models import Edge
from comfy_nodekit.nodes import (
CheckpointLoaderSimple,
CLIPTextEncode,
EmptyLatentImage,
KSampler,
VAEDecode,
)
# Load base models
model, clip, vae = CheckpointLoaderSimple("juggernautXL_v9Rdphoto2Lightning.safetensors")
# Encode prompts
positive = CLIPTextEncode(text="a cinematic portrait of an astronaut", clip=clip)
negative = CLIPTextEncode(text="", clip=clip)
# Create latents and sample
latent = EmptyLatentImage(width=1024, height=1024, batch_size=1)
sampled = KSampler(
model=model,
seed=42,
steps=20,
cfg=7.5,
sampler_name="euler",
scheduler="normal",
positive=positive,
negative=negative,
latent_image=latent,
denoise=1.0,
)
decoded = VAEDecode(samples=sampled, vae=vae)
# Export to ComfyUI JSON format
workflow = decoded.source_node.build_json_workflow()
# Optionally: print or send to a ComfyUI server
import json
print(json.dumps(workflow, indent=2))
Regenerating node bindings
nodes.py is generated from the ComfyUI /object_info endpoint. To sync with the nodes available on your server, run:
uv run python -m comfy_nodekit.nodes_to_py http://127.0.0.1:8188/
If you omit the URL, the script defaults to http://127.0.0.1:8188/. The script downloads the node schema, sanitises type names, and rewrites nodes.py with updated classes and helper functions.
The just recipe just run wraps that command if you prefer using just.
Acknowledgments
Thanks to ComfyScript for inspiration and prior art.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file comfy_nodekit-0.1.0.tar.gz.
File metadata
- Download URL: comfy_nodekit-0.1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08cdcb360ca4ea0bcf3e64a68e9f4e815bbb671721db79dd6f349a97b3812083
|
|
| MD5 |
9b0292049dc580a01223ee78798e3cc0
|
|
| BLAKE2b-256 |
874d4b44854c42bba51ccb1309cfa0ebf846040990615dedeffd7f3ef5255df6
|
File details
Details for the file comfy_nodekit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: comfy_nodekit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fdb7c1258e93278fba79f3d5e37169296cf708c7c9a02afeceaf944c3411637c
|
|
| MD5 |
5141e8cac23096d98c262f690fc701bc
|
|
| BLAKE2b-256 |
d5d77b1d69d80cc05873233a5546abe86fcffe69e50e56c48064f69b23314b92
|