Update backend status handling and improve user notifications
- Enhanced documentation to clarify the transition from 'Idle' to 'ready (running)' for backend states, improving user understanding of system readiness. - Updated logging messages in the notification system to reflect the new backend status terminology, ensuring accurate feedback during operations. - Refined access link collection logic to better handle tunneled and non-tunneled scenarios, enhancing user experience. - Improved tests to validate the new backend status handling and ensure accurate reporting of access links and notifications.
This commit is contained in:
@@ -23,12 +23,7 @@ def test_collect_links_swarm_and_ollama(monkeypatch):
|
||||
|
||||
def test_collect_links_no_tunnel():
|
||||
links = collect_access_links(_Cfg(), tunneled=False)
|
||||
labels = [x.label for x in links]
|
||||
assert "SwarmUI UI" in labels
|
||||
assert "Ollama API" in labels
|
||||
assert any("17801" in x.url for x in links)
|
||||
assert any(x.note == "после tunnel" for x in links)
|
||||
assert any(x.label == "Сейчас" for x in links)
|
||||
assert links[0].url.startswith("gpu-rent tunnel")
|
||||
|
||||
|
||||
def test_mcp_snippet_json():
|
||||
|
||||
@@ -76,6 +76,77 @@ def test_classify_busy_from_status(monkeypatch):
|
||||
assert "idle" in detail
|
||||
|
||||
|
||||
def test_classify_running_without_queue_not_busy(monkeypatch):
|
||||
"""SwarmUI 'running' = ready; empty queue → idle-killer may stop GPU."""
|
||||
mod = _load_remote()
|
||||
|
||||
class FakeResp:
|
||||
def __init__(self, payload):
|
||||
self._payload = payload
|
||||
|
||||
def read(self):
|
||||
import json
|
||||
|
||||
return json.dumps(self._payload).encode()
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, *args):
|
||||
return False
|
||||
|
||||
def fake_urlopen(req, timeout=0, context=None):
|
||||
url = getattr(req, "full_url", None) or req.get_full_url()
|
||||
if "GetNewSession" in url:
|
||||
return FakeResp({"session_id": "abc"})
|
||||
return FakeResp(
|
||||
{
|
||||
"status": {"waiting_gens": 0, "live_gens": 0, "loading_models": 0},
|
||||
"backend_status": {"status": "running", "any_loading": False},
|
||||
}
|
||||
)
|
||||
|
||||
monkeypatch.setattr(mod.urllib.request, "urlopen", fake_urlopen)
|
||||
busy, detail = mod.swarm_busy("http://127.0.0.1:7801")
|
||||
assert busy is False
|
||||
assert "running" in detail
|
||||
|
||||
|
||||
def test_classify_loading_is_busy(monkeypatch):
|
||||
mod = _load_remote()
|
||||
|
||||
class FakeResp:
|
||||
def __init__(self, payload):
|
||||
self._payload = payload
|
||||
|
||||
def read(self):
|
||||
import json
|
||||
|
||||
return json.dumps(self._payload).encode()
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, *args):
|
||||
return False
|
||||
|
||||
def fake_urlopen(req, timeout=0, context=None):
|
||||
url = getattr(req, "full_url", None) or req.get_full_url()
|
||||
if "GetNewSession" in url:
|
||||
return FakeResp({"session_id": "abc"})
|
||||
return FakeResp(
|
||||
{
|
||||
"status": {"waiting_gens": 0, "live_gens": 0, "loading_models": 0},
|
||||
"backend_status": {"status": "loading", "any_loading": True},
|
||||
}
|
||||
)
|
||||
|
||||
monkeypatch.setattr(mod.urllib.request, "urlopen", fake_urlopen)
|
||||
busy, detail = mod.swarm_busy("http://127.0.0.1:7801")
|
||||
assert busy is True
|
||||
assert "loading" in detail
|
||||
|
||||
|
||||
def test_classify_busy_queue(monkeypatch):
|
||||
mod = _load_remote()
|
||||
|
||||
|
||||
@@ -5,21 +5,20 @@ 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
|
||||
assert "BUSY backend=empty" in _REMOTE_POLL
|
||||
|
||||
|
||||
def test_remote_poll_idle_is_ready():
|
||||
assert 'bstat == "idle"' in _REMOTE_POLL
|
||||
assert "READY backend=" in _REMOTE_POLL
|
||||
|
||||
|
||||
def test_remote_poll_loading_running_humanized():
|
||||
assert "Comfy стартует" in _REMOTE_POLL
|
||||
assert "Comfy прогрев" in _REMOTE_POLL
|
||||
assert 'bstat == "loading"' in _REMOTE_POLL
|
||||
def test_remote_poll_running_is_ready():
|
||||
"""SwarmUI: running = healthy ready; idle = suspended (cannot generate)."""
|
||||
assert 'bstat == "running"' in _REMOTE_POLL
|
||||
assert "READY backend=running" in _REMOTE_POLL
|
||||
assert "READY backend=idle" not in _REMOTE_POLL
|
||||
assert "BUSY backend=idle" in _REMOTE_POLL
|
||||
|
||||
|
||||
def test_remote_poll_loading_is_busy():
|
||||
assert 'bstat in ("loading", "some_loading")' in _REMOTE_POLL
|
||||
assert "Comfy стартует" in _REMOTE_POLL
|
||||
|
||||
|
||||
def test_install_swarm_comfy_script_payload():
|
||||
@@ -34,7 +33,7 @@ def test_install_swarm_comfy_script_payload():
|
||||
assert "modern_dark" in text
|
||||
assert "detect_stage" in text
|
||||
assert "dlbackend=" in text
|
||||
assert 'end="\\r"' in text or "end=\"\\r\"" in text
|
||||
assert 'end="\\r"' in text or 'end="\\r"' in text
|
||||
|
||||
|
||||
def test_verify_gpu_env_fail_fast_empty_dlbackend(monkeypatch):
|
||||
|
||||
Reference in New Issue
Block a user