346f859b86
Cubre 15 funciones del grupo comfyui (+ las 4 de comfyui-judge) que no tenian test, con tests offline (sin red, sin GPU, sin servidor ComfyUI): - 5 builders puros gamedev-2d: build_asset_variant, build_directional_sprite, build_inpaint_asset, build_outpaint_asset, build_sprite_from_sketch (estructura del workflow en API format + cableado + determinismo + error paths). - 3 impuras offline via PIL/stdlib: build_grid, flatten_alpha_on_color, read_png_metadata (PNGs reales en tmp, error paths). - 4 de comfyui-judge: score_aesthetic y score_clip_alignment por sus guards previos al subproceso torch; judge_image (panel) y critique_image_llm con la dependencia pesada monkeypatcheada. - 3 que componen otras funciones: resolve_workflow_deps, import_workflow_json, extract_recipe_from_png (dependencia de red monkeypatcheada o fallback offline). Cada .md actualizado con tested: true + test_file_path + tests. Cobertura del grupo comfyui (tag plano): 79 -> 90 con test (47 -> 36 sin). comfyui-judge: 0/4 -> 4/4. pytest: 101 passed; carpeta ml/tests: 376 passed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3.0 KiB
3.0 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | |||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| comfyui_read_png_metadata | function | py | ml | 1.0.0 | impure | def comfyui_read_png_metadata(png_path: str) -> dict | Lee los parametros de generacion de un PNG generado por ComfyUI: extrae el chunk 'prompt' (API format) y resume modelo, seed, steps, cfg, sampler, scheduler, denoise y los prompts positivo/negativo siguiendo las conexiones del KSampler. Comparte el lector de chunks PNG con comfyui_import_workflow_png. Impura: lectura de disco, solo stdlib. |
|
false | error_go_core |
|
dict {ok, prompt, parameters, error}. prompt = workflow API format embebido (dict); parameters = {model, seed, steps, cfg, sampler_name, scheduler, denoise, positive, negative} extraido del KSampler y nodos conectados; error = motivo si ok=False. | true |
|
python/functions/ml/tests/test_comfyui_read_png_metadata.py | python/functions/ml/comfyui_read_png_metadata.py |
Ejemplo
import sys, os
sys.path.insert(0, os.path.join(os.environ["HOME"], "fn_registry", "python", "functions"))
from ml.comfyui_read_png_metadata import comfyui_read_png_metadata
res = comfyui_read_png_metadata(os.path.expanduser("~/ComfyUI/output/comfy_00001_.png"))
# res["ok"] == True
# res["parameters"]["seed"] # ej. 20260623
# res["parameters"]["model"] # ej. "IMG_dreamshaper_8.safetensors"
# res["parameters"]["positive"] # el prompt positivo usado
O lanzable directo con: ./fn run comfyui_read_png_metadata <ruta.png>.
Cuando usarla
Cuando quieras saber con que parametros se genero una imagen (que seed, modelo o
prompt) sin abrir el grafo entero: para reproducir una imagen que te gusto, para
catalogar outputs, o para comparar generaciones. Si necesitas el workflow completo
para relanzarlo usa comfyui_import_workflow_png (devuelve el dict entero).
Gotchas
- Impura: lee el archivo del disco. Un path inexistente o un PNG sin chunk
'prompt' devuelve
{ok: False, error: ...}(no lanza). parametersse extrae del primer nodo cuyo class_type acaba en "KSampler" y de los CLIPTextEncode conectados a sus inputs positive/negative. Workflows muy custom (varios samplers, sin CheckpointLoaderSimple) pueden darparametersparcial; elpromptcompleto siempre se devuelve para inspeccion manual.- Lee chunks tEXt/zTXt/iTXt; los PNG de la API REST solo traen 'prompt' (no 'workflow'), suficiente para los parametros.
- Marcada impura (no pura) porque hace I/O de disco, segun la regla de pureza del registry; la logica de parseo en si es determinista.