Refactor LLM runtime handling and enhance CLI documentation

- Updated `resolve_llm_runtime` to prioritize live configuration over legacy notes, ensuring accurate runtime resolution.
- Enhanced `tunnel_forwards` to prefer current configuration for LLM runtime, improving tunnel setup logic.
- Improved idle-killer logic to handle stale markers and provide clearer warnings in the status output.
- Updated CLI documentation in `cli.md` to reflect changes in command behavior and runtime handling.
- Enhanced tests to validate new runtime resolution logic and ensure proper handling of configuration states.
This commit is contained in:
Leonid Pershin
2026-08-21 05:40:22 +03:00
parent 82e36129cd
commit dc1fde9e3e
17 changed files with 464 additions and 152 deletions
+29 -4
View File
@@ -38,12 +38,37 @@ def test_tunnel_forwards_swarm_only(monkeypatch):
assert tunnel_forwards(Cfg()) == [(17801, 7801)]
def test_tunnel_forwards_ollama(monkeypatch):
def test_tunnel_forwards_prefers_cfg_over_stale_notes(monkeypatch):
class Cfg:
swarmui_local_port = 17801
llm_runtime = "ollama"
llm_runtime = "none"
ollama_local_port = 17811
llamacpp_local_port = 17812
monkeypatch.setattr("gpu_rent.tunnel.load_state", lambda: type("S", (), {"notes": {}})())
assert tunnel_forwards(Cfg()) == [(17801, 7801), (17811, 11434)]
monkeypatch.setattr(
"gpu_rent.tunnel.load_state",
lambda: type("S", (), {"notes": {"llm_runtime": "ollama"}})(),
)
assert tunnel_forwards(Cfg()) == [(17801, 7801)]
def test_resolve_llm_notes_only_when_cfg_none(monkeypatch):
from gpu_rent.access_card import resolve_llm_runtime
class Cfg:
llm_runtime = "none"
monkeypatch.setattr(
"gpu_rent.access_card.load_state",
lambda: type("S", (), {"notes": {"llm_runtime": "ollama"}})(),
)
assert resolve_llm_runtime(Cfg()) == "ollama"
class Cfg2:
llm_runtime = "llamacpp"
monkeypatch.setattr(
"gpu_rent.access_card.load_state",
lambda: type("S", (), {"notes": {"llm_runtime": "ollama"}})(),
)
assert resolve_llm_runtime(Cfg2()) == "llamacpp"