Skip to content

Commit

Permalink
feat(ui/solara): metadata viewer fallback to API format (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaoses-Ib committed Jun 19, 2024
1 parent d302aa7 commit f490399
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/comfy_script/ui/solara/metadata.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import traceback
from warnings import warn
import solara
from PIL import Image

Expand Down Expand Up @@ -28,9 +30,19 @@ def on_file(file_info: solara.file_drop.FileInfo):
elif 'workflow' in image_info or 'prompt' in image_info:
if 'workflow' in image_info:
workflow = image_info['workflow']
try:
script = WorkflowToScriptTranspiler(workflow).to_script()
except Exception:
traceback.print_exc()

msg = 'Failed to transpile workflow in web UI format, fallbacking to API format...'
warn(msg)
workflow = image_info['prompt']
script = WorkflowToScriptTranspiler(workflow).to_script()
elif 'prompt' in image_info:
workflow = image_info['prompt']
set_script(WorkflowToScriptTranspiler(workflow).to_script())
script = WorkflowToScriptTranspiler(workflow).to_script()
set_script(script)
elif 'parameters' in image_info:
set_script(image_info['parameters'])

Expand Down

0 comments on commit f490399

Please sign in to comment.