4.1 KiB
Repository Guidelines
Project Structure & Module Organization
This repository is a ComfyUI custom node package. Python source files live at the repository root:
__init__.pyregisters the extension, web directory, nodes, and server routes.nodes.pydefines the V3SubworkflowInputandSubworkflowOutputpassthrough nodes.workflow_node.pydefines the V3Subworkflownode wrapper.workflow_utils.pycontains workflow loading, I/O discovery, and graph expansion logic.server_routes.pyexposes HTTP routes used by the UI extension.js/subworkflow.jscontains browser-side ComfyUI behavior for dynamic slots.
There is currently no dedicated tests/ directory or bundled asset folder. Keep new runtime code close to the module it supports unless a reusable helper clearly belongs in workflow_utils.py.
Build, Test, and Development Commands
python -m py_compile __init__.py nodes.py workflow_node.py workflow_utils.py server_routes.pychecks Python syntax without launching ComfyUI.- Start ComfyUI normally with this directory installed under
ComfyUI/custom_nodes/; ComfyUI loads the package throughcomfy_entrypoint(). - Restart ComfyUI after Python changes. Browser-side changes in
js/subworkflow.jsmay also require a hard refresh.
The pyproject.toml declares package metadata and Python >=3.10, but does not define build, lint, or test scripts.
Coding Style & Naming Conventions
Use Python 3.10+ syntax and 4-space indentation. Follow the existing style: small modules, explicit imports, descriptive helper names, and ComfyUI-facing constants in uppercase. Node IDs use the SWF_ prefix, for example SWF_SubworkflowInput; display names should be human-readable, for example Subworkflow. Node categories should use Subworkflow capitalization. Prefer concise comments only where ComfyUI integration behavior is non-obvious.
JavaScript should stay scoped to ComfyUI extension behavior in js/subworkflow.js. Match existing naming and avoid broad global state unless required by the ComfyUI frontend API.
Runtime Behavior Notes
Subworkflow,Subworkflow Input, andSubworkflow Outputare V3 nodes. Do not reintroduce V1 node APIs unless there is a specific compatibility task.Subworkflowdynamically updates its UI slots from the selected inner workflow throughserver_routes.pyandjs/subworkflow.js.- The workflow selector uses an empty placeholder value when no workflow is selected.
- The
at executionoption controls whether the inner workflow is reloaded for every execution or kept loaded so ComfyUI-style widget state updates can persist. Subworkflow InputandSubworkflow Outputmust remain usable as passthrough nodes when the workflow is executed standalone.- When an inner workflow is expanded,
Subworkflow Inputvalues come from the outerSubworkflowinputs andSubworkflow Outputvalues become the outer outputs. - Preserve support for UI-format workflows, API-format workflows, UI subgraphs, UUID node types resolved through
properties["Node name for S&R"], list and object link shapes, and list or dictionary widget values. - Keep type information on dynamic slots accurate where it is available. Runtime validation should raise clear errors for known concrete type mismatches instead of letting confusing downstream errors surface.
Testing Guidelines
No automated test suite is present. For now, validate changes with syntax checks and a manual ComfyUI run using workflows that include Subworkflow Input, Subworkflow Output, and Subworkflow. When adding tests, place them under tests/, name files test_*.py, and focus on pure workflow parsing and graph expansion helpers before UI-dependent behavior.
Commit & Pull Request Guidelines
Use short imperative commit subjects such as Fix workflow output slot expansion or Add route validation.
Pull requests should include a clear description, affected nodes or routes, manual validation steps, and screenshots or short recordings for UI changes. Link related issues or README known-issue items when applicable, especially current concerns around progress reporting, optional outputs, path macros, progress borders, and input/output ordering.