Implement headless ComfyUI installation and improve backend status handling

- Added a new function to ensure headless installation of ComfyUI when backends are empty, enhancing the setup process for SwarmUI.
- Updated documentation to clarify the installation flow and backend readiness checks, ensuring users understand the requirements for a successful setup.
- Enhanced backend status checks to differentiate between 'empty' and 'idle' states, improving error handling and user feedback during provisioning.
- Adjusted logging messages to provide clearer insights into the installation and backend status processes.
This commit is contained in:
Leonid Pershin
2026-08-21 09:18:59 +03:00
parent 97abc7985e
commit f7ba915e74
9 changed files with 454 additions and 8 deletions
+4
View File
@@ -47,6 +47,10 @@ def _mock_bind(monkeypatch):
lambda cfg, host, log, update=True, light=False: None,
)
monkeypatch.setattr("gpu_rent.session.provision_vm", lambda cfg, host, log, **kw: None)
monkeypatch.setattr(
"gpu_rent.session.ensure_swarm_comfy_installed",
lambda cfg, host, log: None,
)
monkeypatch.setattr("gpu_rent.session.wait_backend_idle", lambda cfg, host, log, **kw: None)
monkeypatch.setattr(
"gpu_rent.session.verify_stack_on_vm",
+66
View File
@@ -0,0 +1,66 @@
"""Tests for wait_backend_idle READY semantics and install helpers."""
from gpu_rent.ready import _REMOTE_POLL
def test_remote_poll_empty_is_busy_not_ready():
assert 'bstat == "empty"' in _REMOTE_POLL
assert 'BUSY backend=empty' in _REMOTE_POLL
# Must not treat empty as READY anymore
assert '("idle", "disabled", "all_disabled", "empty")' not in _REMOTE_POLL
def test_remote_poll_idle_is_ready():
assert 'bstat == "idle"' in _REMOTE_POLL
assert "READY backend=" in _REMOTE_POLL
def test_install_swarm_comfy_script_payload():
from importlib.resources import files
text = files("gpu_rent.remote").joinpath("install_swarm_comfy.py").read_text(
encoding="utf-8"
)
assert "InstallConfirmWS" in text
assert '"backend": "comfyui"' in text
assert '"models": "none"' in text
assert "modern_dark" in text
def test_verify_gpu_env_fail_fast_empty_dlbackend(monkeypatch):
import json
from gpu_rent.errors import CloudError
from gpu_rent.ready import verify_gpu_env
import gpu_rent.ssh_ops as ssh_ops
class Cfg:
enable_swarmui = True
payload = {
"ok": False,
"checks": [
{"name": "nvidia-smi", "required": True, "ok": True, "detail": "ok"},
{"name": "cuda", "required": True, "ok": True, "detail": "ok"},
{
"name": "torch",
"required": True,
"ok": False,
"detail": "ComfyUI venv python не найден (dlbackend пуст — SwarmUI Install не прогоняли)",
},
],
}
calls = {"n": 0}
def fake(*a, **k):
calls["n"] += 1
return json.dumps(payload)
monkeypatch.setattr(ssh_ops, "run_python", fake)
logs: list[str] = []
try:
verify_gpu_env(Cfg(), "1.2.3.4", logs.append, timeout=600.0, poll_every=0.1)
assert False, "expected CloudError"
except CloudError as exc:
assert "fail-fast" in str(exc).lower() or "torch" in str(exc).lower()
assert calls["n"] == 1