Update documentation and CLI behavior for GPU management

- Clarified the behavior of `Ctrl+C` and `Ctrl+D` in the README and other documentation, specifying that `Ctrl+C` only stops the tunnel while keeping the GPU active, and `Ctrl+D` stops the GPU while preserving disk data.
- Enhanced the CLI documentation to reflect these changes, ensuring users understand the implications of these commands during GPU operations.
- Improved the handling of data bindings and remounting logic in the codebase to prevent issues with empty model tabs in the UI.
- Added tests to validate the new command behaviors and ensure proper documentation alignment.
This commit is contained in:
Leonid Pershin
2026-08-21 13:25:55 +03:00
parent 1d18ece17b
commit f437cd0373
26 changed files with 712 additions and 142 deletions
+96
View File
@@ -109,6 +109,12 @@ def test_autocomplete_merge_sets_is_installed():
assert "GPU_RENT_COMFY_PRESENT" in _AUTOCOMPLETE_MERGE_PY
assert "GPU_RENT_COMFY_PRESENT" in _ENSURE_INSTALLED_PY
assert hasattr(provision, "ensure_settings_is_installed")
assert "set_autocomplete_source" in _AUTOCOMPLETE_MERGE_PY
assert "CHANGED inserted AutoComplete.Source" in _AUTOCOMPLETE_MERGE_PY
assert '"settings_applied": False' in Path(provision.__file__).read_text(
encoding="utf-8"
)
assert "if not applied:" not in Path(provision.__file__).read_text(encoding="utf-8")
def test_ensure_installed_clears_flag_without_comfy(tmp_path):
@@ -178,3 +184,93 @@ def test_clear_settings_installed_flag(tmp_path, monkeypatch):
assert "IsInstalled: false" in text
assert "Theme: x" in text
assert inst.clear_settings_installed_flag() is False
def _run_autocomplete_merge(tmp_path, settings_text: str, fname: str = "danbooru.csv"):
import os
import subprocess
import sys
from gpu_rent.provision import _AUTOCOMPLETE_MERGE_PY
settings = tmp_path / "Settings.fds"
settings.write_text(settings_text, encoding="utf-8")
script = tmp_path / "merge.py"
script.write_text(_AUTOCOMPLETE_MERGE_PY, encoding="utf-8")
env = os.environ.copy()
env["GPU_RENT_SETTINGS_FDS"] = str(settings)
env["GPU_RENT_AUTOCOMPLETE_FILE"] = fname
env["GPU_RENT_COMFY_PRESENT"] = "1"
out = subprocess.check_output([sys.executable, str(script)], env=env, text=True)
return out, settings.read_text(encoding="utf-8")
def test_autocomplete_merge_inserts_source_when_only_escapeparens(tmp_path):
out, text = _run_autocomplete_merge(
tmp_path,
"IsInstalled: true\nDefaultUser:\n AutoComplete:\n EscapeParens: true\n",
)
assert "CHANGED inserted AutoComplete.Source=danbooru.csv" in out
assert "Source: danbooru.csv" in text
assert "EscapeParens: true" in text
def test_autocomplete_merge_fills_empty_fds_source(tmp_path):
out, text = _run_autocomplete_merge(
tmp_path,
"DefaultUser:\n AutoComplete:\n Source: \\x\n EscapeParens: true\n",
)
assert "CHANGED patched AutoComplete.Source=danbooru.csv" in out
assert "Source: danbooru.csv" in text
def test_autocomplete_merge_keeps_user_source(tmp_path):
out, text = _run_autocomplete_merge(
tmp_path,
"DefaultUser:\n AutoComplete:\n Source: e621.csv\n",
)
assert "SKIP_USER" in out
assert "Source: e621.csv" in text
assert "danbooru.csv" not in text
def test_seed_autocomplete_merges_when_csv_already_present(monkeypatch):
import json
from gpu_rent import provision
class Cfg:
autocomplete_enabled = True
autocomplete_filename = "danbooru.csv"
autocomplete_github_repo = "org/repo"
autocomplete_github_path = "tags/danbooru.csv"
autocomplete_github_ref = "main"
monkeypatch.setattr(
provision,
"_github_blob",
lambda _cfg: {"sha": "abc", "download_url": "https://example.invalid/x"},
)
def fake_exists(_cfg, _host, path):
return path.endswith("danbooru.csv") or path.endswith(".json")
def fake_ssh(_cfg, _host, cmd, **_kw):
if "cat" in cmd:
return json.dumps({"github_blob_sha": "abc", "settings_applied": True})
return ""
merges: list[str] = []
def fake_merge(*_a, **_k):
merges.append("called")
return "changed"
monkeypatch.setattr(provision, "remote_exists", fake_exists)
monkeypatch.setattr(provision, "run_ssh", fake_ssh)
monkeypatch.setattr(provision, "_merge_autocomplete_into_settings", fake_merge)
monkeypatch.setattr(provision, "put_text", lambda *_a, **_k: None)
logs: list[str] = []
assert provision.seed_autocomplete(Cfg(), "1.2.3.4", logs.append) is True
assert merges == ["called"]