chore: auto-commit (61 archivos)
- docs/capabilities/INDEX.md - docs/capabilities/comfyui.md - python/functions/browser/comfyui_export_workflow_ui.md - python/functions/browser/comfyui_export_workflow_ui.py - python/functions/browser/comfyui_load_workflow_ui.md - python/functions/browser/comfyui_load_workflow_ui.py - python/functions/browser/comfyui_queue_prompt_ui.md - python/functions/browser/comfyui_queue_prompt_ui.py - python/functions/browser/comfyui_refresh_nodes_ui.md - python/functions/browser/comfyui_refresh_nodes_ui.py - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
---
|
||||
name: comfyui_wait_result
|
||||
kind: function
|
||||
lang: py
|
||||
domain: ml
|
||||
version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "def comfyui_wait_result(prompt_id: str, server: str = \"127.0.0.1:8188\", timeout: float = 180.0, poll_interval: float = 1.0) -> dict"
|
||||
description: "Sondea GET /history/{prompt_id} hasta que un prompt ComfyUI completa (status.completed o status_str success/error) o se agota el timeout. Devuelve los outputs por nodo (node_id -> {images: [...]}). Polling como mecanismo principal (no WebSocket). Impura: HTTP GET en bucle + sleep, solo stdlib."
|
||||
tags: [comfyui, ml, image-generation, stable-diffusion, http, polling]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: "error_go_core"
|
||||
imports: []
|
||||
params:
|
||||
- name: prompt_id
|
||||
desc: "id devuelto por comfyui_submit_workflow (clave 'prompt_id' de su respuesta)."
|
||||
- name: server
|
||||
desc: "host:port del servidor ComfyUI sin esquema (default '127.0.0.1:8188')."
|
||||
- name: timeout
|
||||
desc: "Maximo de segundos a esperar antes de lanzar TimeoutError."
|
||||
- name: poll_interval
|
||||
desc: "Segundos entre sondeos de /history."
|
||||
output: "dict de outputs {node_id: {'images': [{'filename', 'subfolder', 'type'}, ...]}} tal como ComfyUI los expone en history[prompt_id]['outputs']. Para un txt2img, el nodo SaveImage ('9') trae el PNG. Puede contener otros tipos (gifs, texto) segun los nodos del workflow."
|
||||
tested: false
|
||||
tests: []
|
||||
test_file_path: ""
|
||||
file_path: "python/functions/ml/comfyui_wait_result.py"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```python
|
||||
import sys, os
|
||||
sys.path.insert(0, os.path.join(os.environ["HOME"], "fn_registry", "python", "functions"))
|
||||
from ml.comfyui_build_txt2img_workflow import comfyui_build_txt2img_workflow
|
||||
from ml.comfyui_submit_workflow import comfyui_submit_workflow
|
||||
from ml.comfyui_wait_result import comfyui_wait_result
|
||||
|
||||
wf = comfyui_build_txt2img_workflow(
|
||||
ckpt_name="v1-5-pruned-emaonly-fp16.safetensors",
|
||||
positive="a red apple on a wooden table, sharp focus",
|
||||
)
|
||||
pid = comfyui_submit_workflow(wf)["prompt_id"]
|
||||
outputs = comfyui_wait_result(pid, timeout=240)
|
||||
for node_id, out in outputs.items():
|
||||
for img in out.get("images", []):
|
||||
print(img["filename"]) # ej. comfy_00001_.png en ~/ComfyUI/output/
|
||||
```
|
||||
|
||||
O lanzable directo (build + submit + wait) con: `./fn run comfyui_wait_result`.
|
||||
|
||||
## Cuando usarla
|
||||
|
||||
Tercer y ultimo paso del round-trip: tras `comfyui_submit_workflow`, para
|
||||
bloquear hasta que la generacion termine y recuperar las rutas de los PNG
|
||||
generados. Usala cuando quieras el resultado fija (no streaming de progreso paso
|
||||
a paso) — es portable porque solo depende de HTTP, no de websocket-client.
|
||||
|
||||
## Gotchas
|
||||
|
||||
- Bloquea el hilo (sondea + duerme). Para varias generaciones en paralelo,
|
||||
encola todas con submit y luego espera cada prompt_id, o usa hilos.
|
||||
- El timeout por defecto (180s) puede quedarse corto en GPUs lentas o workflows
|
||||
pesados (muchos steps, alta resolucion, upscalers). Sube `timeout` segun el
|
||||
caso. Lanza TimeoutError si se agota.
|
||||
- Lanza RuntimeError si la ejecucion termina con status_str "error" (el detalle
|
||||
del fallo va en el mensaje) o si no se puede conectar al servidor.
|
||||
- Devuelve metadatos de los PNG (filename, subfolder, type), NO los bytes de la
|
||||
imagen. Los archivos quedan en la carpeta output/ del servidor; para leerlos
|
||||
desde otra maquina usa GET /view?filename=...&subfolder=...&type=output.
|
||||
Reference in New Issue
Block a user