Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Purpose

This repository provides a lightweight, pure‑Python implementation of the LiteGraph‑based workflow loader used by ComfyUI. It focuses solely on the data model needed to read a ComfyUI workflow generated by the JavaScript LiteGraph library and convert it to the ComfyAPI prompt format. All graphical‑interface code from the original project is intentionally omitted, keeping the library small and dependency‑free.


Usage

Installation

python -m venv venv_litegraph
source venv_litegraph/bin/activate   # Windows: venv_litegraph\Scripts\activate
pip install -e .                     # editable install for development (src layout)
pip install -r requirements.txt       # development and test dependencies

From Python

from litegraph_py import load_workflow_json, graph_to_prompt
from litegraph_py.loader import load_object_info

# Load a workflow JSON file (widget values will be unnamed)
graph = load_workflow_json("path/to/workflow.json")

# Or load with object_info.json for named widget values
graph = load_workflow_json("path/to/workflow.json", object_info=load_object_info("path/to/object_info.json"))

# Convert to the ComfyAPI prompt format
workflow_json, api_prompt = graph_to_prompt(graph)
print(api_prompt)  # dict ready for the ComfyUI API

CLI

python -m litegraph_py path/to/workflow.json [-o out.json] [--sort] [--object-info object_info.json]
  • -o/--output writes the JSON to a file instead of stdout.
  • --sort topologically sorts nodes before emitting the prompt.
  • --object-info path to an object_info.json file to reconstruct named widget values.


Contributing

When adding new tests, ensure they target the pure‑logic aspects of the library and avoid any UI‑related code. Feel free to submit pull requests that expand coverage of node/link handling or improve the prompt conversion algorithm.


About

A lightweight, python implementation of the **LiteGraph**‑based workflow loader used by **ComfyUI**. It focuses solely on the data model needed to read a ComfyUI workflow generated by the JavaScript LiteGraph library and convert it to the ComfyAPI prompt format.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages