Archived
refactor: streamline run_workflow function by removing custom client_id handling and unnecessary imports
This commit is contained in:
1 parent
a886e2d327
commit
ed0ac8090b
1 file changed
+2
-19
+2
-19
@@ -3,8 +3,8 @@ Basic SDXL Text to Image workflow.
|
||||
Schema is defined in basic_sdxl.yaml (auto-generated from WorkflowParams).
|
||||
"""
|
||||
import os
|
||||
import comfy_script.runtime as runtime
|
||||
from comfy_script.runtime import *
|
||||
from comfy_script.runtime import _client_id
|
||||
|
||||
# ComfyUI server URL - configurable via environment variable
|
||||
COMFYUI_SERVER_URL = os.environ.get('COMFYUI_SERVER_URL', 'http://127.0.0.1:8188/')
|
||||
@@ -282,12 +282,10 @@ def run_workflow(**kwargs):
|
||||
Special kwargs (not passed to WorkflowParams):
|
||||
save_mode: "disk" | "temporary" | "stream" - how to save output images
|
||||
params_raw: dict - original parameters from frontend (for PNG metadata/recall)
|
||||
client_id: str - custom client_id for WebSocket events (optional)
|
||||
"""
|
||||
# Extract special parameters before creating WorkflowParams
|
||||
save_mode = kwargs.pop('save_mode', 'disk')
|
||||
params_raw = kwargs.pop('params_raw', None)
|
||||
custom_client_id = kwargs.pop('client_id', None)
|
||||
|
||||
required = ['prompt', 'checkpoints', 'seed', 'steps', 'negativePrompt', 'dimensions', 'cfg']
|
||||
missing = [f for f in required if f not in kwargs]
|
||||
@@ -298,19 +296,4 @@ def run_workflow(**kwargs):
|
||||
|
||||
# Create and run workflow with save settings
|
||||
workflow = SDXLWorkflow(params, params_raw=params_raw, save_mode=save_mode)
|
||||
|
||||
# If custom client_id provided, temporarily override comfy_script's client_id
|
||||
original_client_id = getattr(runtime, '_client_id', None)
|
||||
if custom_client_id and original_client_id:
|
||||
runtime._client_id = custom_client_id
|
||||
|
||||
try:
|
||||
result = workflow.run()
|
||||
# Use custom client_id in response if provided
|
||||
if custom_client_id:
|
||||
result['client_id'] = custom_client_id
|
||||
return result
|
||||
finally:
|
||||
# Restore original client_id
|
||||
if custom_client_id and original_client_id:
|
||||
runtime._client_id = original_client_id
|
||||
return workflow.run()
|
||||
Reference in new issue
Block a user