Repository navigation
comfyui: a cmd worker for image and video tools, and engine size options - #156
Conversation
tools/comfyui/worker.py starts its own ComfyUI (options.comfy_dir/python/args/env, loopback, a private output directory) or uses options.url, fills an API-format workflow from the request through explicit bindings (node.input), queues it, reports progress from /ws, waits on /history and fetches 0.png.. or video.mp4 through /view. Unbound fields (negative prompt, steps, guidance), edits and image-to-video are refused, never ignored; sizes, frame grids (frame_multiple / frame_offset) and fps are checked; audio off removes a bound input. Cancel is SIGUSR1 (/queue delete + /interrupt), and the worker stays loaded. Standard library only; test_worker.py runs it against a fake ComfyUI (16 checks). engine.fill: a video tool's options may name default_width/default_height for requests without a size (a cmd model's own size); else 1344x768 as before.
options.modes.image_edit / image_to_video give requests with input images their own workflow and bindings, merged over the tool's. references, mask and first_frame are uploaded to ComfyUI (/upload/image, into the worker's private input directory, cleaned per job) and wired in through added LoadImage nodes (IMAGE, or MASK for a mask). Requests a tool cannot honour are still refused. Tests: 24 checks against a fake ComfyUI.
image_edit may set defaults and an unmasked overlay (workflow, bindings, defaults) used when a request has input images but no mask; request fields still override. Masked edits keep the tool's fast defaults. Tests cover the auto-select and the overrides.
worker.py had grown to 662 lines with edits and image to video, past the 600-line convention; the RFC 6455 client moves to comfy_events.py (76 lines) and worker.py is 596. No behaviour change: the 29 worker checks pass.
jayleaton
left a comment
There was a problem hiding this comment.
Thanks for the explicit bindings, the refusals for unsupported options and the fake-ComfyUI coverage. The 29 worker checks pass, and the Zig size options keep the existing defaults.
Blocking: tools/comfyui/worker.py:224. ComfyUI starts in its own session, outside the worker group that the daemon SIGKILLs on abort or worker timeout. It can therefore outlive an unloaded worker and keep holding GPU memory. Please make a hard worker kill take ComfyUI down too, and add a fake-server test for that path. The graceful-exit and SIGUSR1 tests don't cover it. This is the same issue as #154.
…ts code A job, video or 3D asset object's error now has type (the value an HTTP error for the same failure carries, e.g. insufficient_memory), code (the same value, as before) and message. A client matching the HTTP type in a job's message missed jobs refused for room (the message reads "insufficient memory: ...") and gave up instead of retrying. docs/AGENTS.md: match type or code, never the message. Test: the error object's JSON.
A video job holds its model while it runs; a chat request (or an API load) that needs the room is refused at once with 503 insufficient_memory, and loads once the job is done. The scheduler already does this (in_use); the test pins it, and fails if admit may take a slot in use.
ComfyUI no longer gets a session of its own (start_new_session): it stays in the worker's process group, so the daemon's SIGKILL of that group on abort or timeout takes it down too, and PR_SET_PDEATHSIG (SIGTERM) covers the worker dying alone. Before, a hard kill left ComfyUI holding the GPU. An unload now signals ComfyUI and every process below it instead of its group; SIGUSR1 (cancel) still goes to the worker alone. Test: SIGKILL of the worker's group mid-render, the fake ComfyUI is gone (fails on the old worker). The worker tests start the worker in its own group, as the daemon does.
|
Review fixes pushed (new commits, no force-push):
— SMF Works |
# Conflicts: # .github/workflows/ci.yml
jayleaton
left a comment
There was a problem hiding this comment.
Randy's round-2 review found nothing left to fix. ComfyUI dies with the worker in both kill cases, the job-error type field is additive, and the scheduler test passes. Thanks!
|
Approved: Randy's round-2 review found nothing left to fix. I merged #154 first (squashed as f902361), and now GitHub shows this PR as conflicting with |
ci.yml: main's openai_audio step, then this branch's ComfyUI worker step.
Part 4 of 5 (split from #152).
Independent of Parts 1–3. A generic cmd worker that serves image and video tools through a ComfyUI server: text to image, edits with input images and an optional mask, image to video, and progress over
/ws. Also the narrow Zig size-options change (engine defaults keep precedence; the fallback has a unit test)./wsclient moved totools/comfyui/comfy_events.py, soworker.py(596 lines) stays under the 600-line convention.tools/comfyui/test_worker.py(29 checks against a fake ComfyUI).Checks run locally:
zig build test,zig build test-unit(26/26), comfy 29/29, syntax,git diff --check.