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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user