Skip to main content

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?โ€‹

๐ŸŽฏ 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!