Welcome to Discomfort
Discomfort is a powerful ComfyUI extension that revolutionizes how you work with AI workflows by enabling programmatic execution with loops, conditionals, and persistent state management.
The Problemโ
ComfyUI's native execution model follows a Directed Acyclic Graph (DAG) pattern, executing nodes once in topological order. While powerful for single-pass workflows, this model doesn't natively support:
- ๐ Iterative refinement workflows
- โก Conditional execution paths
- ๐พ State preservation across iterations
- ๐งฉ Dynamic workflow composition
- ๐ Programmatic access and management
You spend 95% of your time building "Comfy spaghetti" instead of just creating. What if you could just write a script that tells ComfyUI exactly what to do?
The Solutionโ
Discomfort addresses these limitations by introducing an execution layer on top of ComfyUI's DAG model, using:
- Pre-execution graph manipulation for dynamic workflow modification
- Self-managed ComfyUI server for isolated runs
- Simple data store that handles context throughout execution
- Intelligent pass-by-value/reference system for different data types
โจ Key Featuresโ
๐ Loops & Conditionalsโ
for i in range(10):
if i % 2 == 0:
await discomfort.run(["empty_latent.json"])
else:
await discomfort.run(["img2img.json"])
๐พ Persistent State Managementโ
with discomfort.Context() as context:
context.save("model", my_model) # Saved across runs
await discomfort.run(["workflow.json"], context=context)
result = context.load("output_image")
๐งฉ Workflow Stitchingโ
workflows = ["load_model.json", "process.json", "save.json"]
stitched = discomfort.Tools.stitch_workflows(workflows)
await discomfort.run([stitched["stitched_workflow"]])
๐ Simple Integrationโ
Just add DiscomfortPort
nodes to your existing ComfyUI workflows - no complex modifications needed!
๐ Quick Startโ
1. Install Discomfortโ
cd ComfyUI/custom_nodes
git clone https://github.com/Distillery-Dev/Discomfort.git discomfort
cd discomfort
pip install -r requirements.txt
2. Add DiscomfortPorts to Your Workflowโ
Open any ComfyUI workflow and add DiscomfortPort
nodes:
- INPUT ports: Connect output โ workflow (inject data from Python)
- OUTPUT ports: Connect workflow โ input (extract data to Python)
- Give each port a unique
unique_id
3. Write Your Scriptโ
import asyncio
from custom_nodes.discomfort.discomfort import Discomfort
async def main():
discomfort = await Discomfort.create()
with discomfort.Context() as context:
# Set initial parameters
context.save("prompt", "A beautiful landscape")
context.save("seed", 12345)
# Run workflow
await discomfort.run(["my_workflow.json"], context=context)
# Get results
result_image = context.load("output_image")
discomfort.Tools.save_comfy_image_to_disk(result_image, "result.png")
await discomfort.shutdown()
asyncio.run(main())
๐ What's Next?โ
- Installation Guide - Detailed setup instructions
- Basic Tutorial - 5-minute video tutorial
- Core Concepts - Understand DiscomfortPorts and Context
- API Reference - Complete method documentation
- Create your first workflow - Master the basics before advanced techniques
- Explore examples - Real-world usage patterns
๐ฏ Perfect Forโ
- ๐ Iterative refinement: Progressively improve outputs through multiple passes
- ๐๏ธ Parameter sweeps: Test multiple configurations automatically
- ๐ Batch processing: Process large datasets with custom logic
- ๐งช A/B testing: Compare different approaches systematically
- ๐๏ธ Complex pipelines: Build sophisticated multi-stage workflows
โก Current Statusโ
Discomfort is in alpha but fully operational. Core functionality including:
- โ Discomfort Class - Complete programmatic API
- โ Context Management - State persistence and data handling
- โ Workflow Stitching - Merge multiple workflows seamlessly
- โ ComfyUI Integration - Stable server management
Ready to transform your ComfyUI workflows? Let's get started!