cli-export
Export ComfyUI API workflows to Python and troubleshoot the generated script runtime.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- cli-export
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Export ComfyUI API workflows to Python and troubleshoot the generated script runtime.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/cli-reference.md1.3 KB
- 参考文档references/generated-script-runtime.md2.2 KB
- 参考文档references/troubleshooting.md1.7 KB
- 脚本scripts/export_smoke.py2.0 KB
03 SKILL.md 正文
CLI Export and Generated Script Runtime
Use this sub-skill when the task is about converting workflow_api.json into Python or understanding the standalone script that the exporter produces.
Typical user requests
- Convert an exported ComfyUI workflow to a Python script.
- Run the exporter from the command line.
- Explain or debug the generated Python file.
- Check why a generated script cannot find ComfyUI,
torch, or a model file. - Understand how node ordering, seed sync, cleanup, or custom-node loading works.
- Create or run a small export smoke test.
What this sub-skill owns
comfyui_to_python/package behavior.- The CLI parser and
python -m comfyui_to_pythonentry point. - Generated script layout, bootstrap, cleanup, and queue execution.
- Workflow loading, load-order planning, and renderer output.
- Generated-script troubleshooting for
COMFYUI_PATH,torch,black, custom nodes, and model/runtime issues.
What this sub-skill excludes
- Installing the repo as a ComfyUI custom node.
- The browser
File -> Save As Scriptbutton and/saveasscriptroute. - Frontend menu behavior or ComfyUI discovery mechanics beyond what the exporter needs at runtime.
Read these first
references/cli-reference.mdfor commands, flags, and defaults.references/generated-script-runtime.mdfor the structure and runtime behavior of exported Python.references/troubleshooting.mdfor exporter and generated-script failure modes.scripts/export_smoke.pyfor a fast end-to-end smoke check with a tiny workflow.
Workflow
- Confirm that the user has an API-format workflow or wants the exporter to produce one.
- Use the CLI when the user wants a file-based export, or use
ComfyUItoPython(...)programmatically when they are scripting the export. - If ComfyUI is not already discoverable, set
COMFYUI_PATHbefore running the exported Python. - Make sure
blackis available in the runtime that renders the script. - If the user needs the generated script to unload models after each run, explain
COMFYUI_TOPYTHON_UNLOAD_MODELS=1ormain(unload_models=True). - Use the smoke script for quick validation before you move to heavier runtime checks.
Routing hints
Choose this sub-skill when you see any of these signals:
workflow_api.jsonworkflow_api.pypython -m comfyui_to_pythoncomfyui_to_python.py--input_file,--output_file, or--queue_sizeCOMFYUI_PATHNo module named 'torch'custom nodeimport errors during generated-script executioncleanup_comfyui_runtimebootstrap_comfyui_runtimeFile -> Export (API)
What the generated script does
The exported Python is a standalone workflow runner, not a generic API service. It:
- embeds the workflow and optional frontend metadata
- bootstraps ComfyUI before importing
torch - loads ComfyUI model paths and custom nodes when needed
- executes the workflow in a bounded queue loop
- performs best-effort cleanup in a
finallyblock
Success criteria
A future agent should be able to:
- export a workflow to a Python file,
- understand the key sections in the generated source,
- explain why the script needs a ComfyUI runtime,
- and diagnose the common runtime failures without reopening the original repository.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).