Enhance backend idle management and diagnostics in SwarmUI

- Updated the `wait_backend_idle` function to handle disabled backends, introducing a new failure condition and diagnostics collection for better error handling.
- Refactored the `install_swarm_comfy` script to include a new `configure_comfy_backend` function, streamlining backend configuration and enabling better management of backend states.
- Added tests to validate the new functionality for handling disabled backends and ensuring robust diagnostics, improving overall backend management.
This commit is contained in:
Leonid Pershin
2026-08-21 11:00:01 +03:00
parent f8bbde8ac0
commit a18074c985
3 changed files with 205 additions and 29 deletions
+38
View File
@@ -41,6 +41,10 @@ def test_install_swarm_comfy_script_payload():
assert 'bstat == "errored"' in text
assert "sanitize_backends_fds" in text or "recover_empty_backends" in text
assert "AddNewBackend" in text
assert "EditBackend" in text
assert "dlbackend/ComfyUI/main.py" in text
assert "configure_comfy_backend" in text
assert 'bstat in ("empty", "disabled", "all_disabled", "unknown")' in text
def test_wait_backend_idle_fail_fast_on_errored(monkeypatch):
@@ -72,6 +76,40 @@ def test_wait_backend_idle_fail_fast_on_errored(monkeypatch):
assert diag_calls["n"] == 1
def test_wait_backend_idle_fail_fast_on_disabled(monkeypatch):
from gpu_rent.errors import CloudError
from gpu_rent import ready
class Cfg:
pass
def fake_ssh(*a, **k):
return "BUSY backend=disabled"
diag_calls = {"n": 0}
def fake_diag(*a, **k):
diag_calls["n"] += 1
return "DIAG ok"
monkeypatch.setattr(ready, "run_ssh", fake_ssh)
monkeypatch.setattr(ready, "collect_swarm_diagnostics", fake_diag)
try:
ready.wait_backend_idle(
Cfg(),
"1.2.3.4",
[].append,
timeout=600.0,
poll_every=0.01,
disabled_fail_sec=0.05,
)
assert False, "expected CloudError"
except CloudError as exc:
assert "disabled" in str(exc).lower()
assert "startscript" in str(exc).lower()
assert diag_calls["n"] == 1
def test_swarm_diag_script_covers_api_and_journal():
from importlib.resources import files