Skip to content

Smart Queue v1: GPU-aware queue autopilot + Cooldown & Pause node - #1

Merged
rubz merged 17 commits into
masterfrom
smart-queue-v1
Aug 28, 2026
Merged

rubz merged 17 commits into
masterfrom
smart-queue-v1

Conversation

@rubz

@rubz rubz commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • GPU-aware autopilot rule engine (temp/VRAM/job-count) that pauses the queue via non-intrusive middleware on /prompt, never interrupting a running job
  • SQLite-backed queue persistence, readable job names, drag-drop reorder, history with thumbnails
  • Native-feeling queue panel (Crystools-aware, theme-aware, works with Nodes 2.0 on/off) plus a manual pause toggle
  • "Smart Cooldown & Pause" node (V3 schema, backward-compatible node-type ID) consolidating fixed-delay/temp-wait cooldown, model unload, wait-for-click, and sound/toast notifications
  • Full spec and implementation plan in docs/specs/ and docs/plans/

Test plan

  • 70 automated tests green (cd tests && python -m pytest -q)
  • Manual verification against a live ComfyUI instance: queue panel, settings sync, Crystools detection, theme rendering, manual pause, Nodes 2.0 toggle on/off
  • Cooldown node manual verification: sound, toast, custom-sound fallback, wait-for-click blocking/resume, unload-models-before-wait
  • Old superseded rubz-gpu-cooldown pack deleted (never published, no external users)

rubz added 17 commits August 28, 2026 22:55
Also add aiohttp to CI install (needed since Task 5's middleware tests,
plan only called this out for pytest-asyncio in Task 6).
SmartCooldownNode falls back to a plain object base when comfy_api isn't
installed, so it stays importable for __init__.py's smoke test outside a
real ComfyUI process (plan only wrapped the io import, not the class).
Two plan-code fixes required to make this actually work:
- test_smoke.py's manual __init__.py loader didn't register the module in
  sys.modules before exec, so __init__.py's relative imports (from .backend...)
  couldn't resolve their parent package. Fixed by registering it first and
  giving it submodule_search_locations so it's treated as a package.
- pytest.ini moved from the package root into tests/: with it at the package
  root, pytest's Package collector (any dir with __init__.py) unconditionally
  imports that __init__.py during test *setup* for setUpModule/tearDownModule
  support, which broke every single test the moment __init__.py started doing
  the Task 9 relative imports. Rooting pytest at tests/ (which has no
  __init__.py) keeps the package __init__.py out of the collection tree
  entirely; --import-mode=importlib avoids the equivalent issue for backend/
  and backend/nodes/, which do need __init__.py for real imports.
--import-mode=importlib (needed to keep the package's own __init__.py out
of pytest's Package-setup import) stops pytest from touching sys.path at
all, so bare `pytest tests/ -v` (what CI runs) couldn't find backend/
without it. python -m pytest masked this by adding cwd itself.
Wires the Python side too (execute() dispatches smart_queue.cooldown_notify
and, for wait_for_click, smart_queue.cooldown_wait_for_click via
PromptServer.send_sync, then blocks on backend/continue_registry.py's
threading.Event until POST /smart_queue/continue/<prompt_id> signals it).
run_cooldown()'s signature and tests are unchanged.

Sound files are short generated sine-wave tones (stdlib wave module,
440/880/1318Hz, all under 25KB).
Manual verification against a running ComfyUI instance surfaced four gaps
unit tests couldn't catch: the queue panel and history were never actually
populated (add_queue_item/mark_completed/record_job_started existed only in
tests), smart_queue.css was never linked into the page, no manual pause
control existed despite spec Section 6 requiring one, and RubzGpuCooldownNode
is shadowed by the old rubz-gpu-cooldown pack's registration.

- Add backend/queue_tracker.py: mirrors PromptServer's live prompt_queue into
  Smart Queue's own persistence and the autopilot job counter, including jobs
  that start and finish within a single poll tick.
- Add manual pause/resume: AutopilotState.manual_paused/effective_paused,
  POST /smart_queue/manual_pause, middleware gates on the combined state.
- Fix CSS not being loaded; land the pause control as a small icon button
  inserted into ComfyUI's own Run-button toolbar row (real flex child, not a
  position:fixed overlay guessing coordinates) after two placements that
  overlapped other UI were tried and rejected.
- Document all findings in spec Section 13 and update plan checkboxes to match
  actual verified state.
define_schema() referenced a Hidden enum member that doesn't exist in this
ComfyUI version, crashing /object_info for the node. Read the running
prompt's id from PromptServer.instance.last_prompt_id instead, set once
per prompt by ComfyUI's own execution loop.

Verified against a live instance: node sound/toast/fallback/wait-for-click/
unload-before-wait all work, and the queue panel + node UI hold up with
Nodes 2.0 toggled on and off. v1 is now fully verified end to end.
Fully superseded and never published, so no external users to migrate.
Confirmed the node still resolves correctly from this pack after removal.
@rubz
rubz merged commit a34a53f into master Aug 28, 2026
1 check passed
rubz added a commit that referenced this pull request Aug 30, 2026
Smart Queue v1: GPU-aware queue autopilot + Cooldown & Pause node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant