Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ComfyUI/user/default/comfy.settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"Comfy.TutorialCompleted": true
"Comfy.TutorialCompleted": true,
"Comfy.Queue.ImageFit": "cover",
"Comfy.Release.Version": "0.3.48",
"Comfy.Release.Timestamp": 1754374644423
}
34 changes: 33 additions & 1 deletion dream_layer_backend/img2img_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
import json
import logging
import os
import requests
from PIL import Image
import io
import time
from shared_utils import send_to_comfyui
from img2img_workflow import transform_to_img2img_workflow
from shared_utils import COMFY_API_URL
from dream_layer_backend_utils.fetch_advanced_models import get_controlnet_models
from run_registry import create_run_config_from_generation_data
from dataclasses import asdict

# Configure logging
logging.basicConfig(
Expand Down Expand Up @@ -178,11 +181,40 @@ def handle_img2img():
logger.info(f" Subfolder: {img.get('subfolder', 'None')}")
logger.info(f" URL: {img.get('url')}")

# Extract generated image filenames
generated_images = []
if comfy_response.get("generated_images"):
for img_data in comfy_response["generated_images"]:
if isinstance(img_data, dict) and "filename" in img_data:
generated_images.append(img_data["filename"])

# Register the completed run
try:
run_config = create_run_config_from_generation_data(
data, generated_images, "img2img"
)

# Send to run registry
registry_response = requests.post(
"http://localhost:5005/api/runs",
json=asdict(run_config),
timeout=5
)

if registry_response.status_code == 200:
logger.info(f"✅ Run registered successfully: {run_config.run_id}")
else:
logger.warning(f"⚠️ Failed to register run: {registry_response.text}")

except Exception as e:
logger.warning(f"⚠️ Error registering run: {str(e)}")

response = jsonify({
"status": "success",
"message": "Workflow sent to ComfyUI successfully",
"comfy_response": comfy_response,
"workflow": workflow
"workflow": workflow,
"run_id": run_config.run_id if 'run_config' in locals() else None
})

Comment on lines +209 to 219
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): Possible None run_id in response if registration fails.

Consider omitting the run_id field or returning a clearer error message when registration fails, to avoid confusing clients with a null value.

Suggested change
except Exception as e:
logger.warning(f"⚠️ Error registering run: {str(e)}")
response = jsonify({
"status": "success",
"message": "Workflow sent to ComfyUI successfully",
"comfy_response": comfy_response,
"workflow": workflow
"workflow": workflow,
"run_id": run_config.run_id if 'run_config' in locals() else None
})
except Exception as e:
logger.warning(f"⚠️ Error registering run: {str(e)}")
response = jsonify({
"status": "error",
"message": f"Failed to register run: {str(e)}",
"comfy_response": comfy_response,
"workflow": workflow
})
return response
response_data = {
"status": "success",
"message": "Workflow sent to ComfyUI successfully",
"comfy_response": comfy_response,
"workflow": workflow
}
if 'run_config' in locals() and hasattr(run_config, 'run_id'):
response_data["run_id"] = run_config.run_id
response = jsonify(response_data)

# Clean up the temporary image file
Expand Down
Loading