Enhance installation state management and diagnostics for ComfyUI
- Updated the `gpu-rent` logic to ensure the `IsInstalled` flag is accurately set based on the presence of ComfyUI, preventing conflicts during installation. - Improved the handling of the `/mnt/swarm_data` directory to skip creation if it does not exist, enhancing robustness in provisioning. - Added tests to validate the new installation state checks and ensure proper diagnostics during the installation process, including scenarios for clearing and setting the `IsInstalled` flag.
This commit is contained in:
@@ -102,9 +102,57 @@ def test_autocomplete_merge_sets_is_installed():
|
||||
|
||||
assert "IsInstalled: true" in _AUTOCOMPLETE_MERGE_PY
|
||||
assert "IsInstalled: true" in _ENSURE_INSTALLED_PY
|
||||
assert "comfy_on_disk" in _AUTOCOMPLETE_MERGE_PY
|
||||
assert "comfy_on_disk" in _ENSURE_INSTALLED_PY
|
||||
assert r"\1false" in _AUTOCOMPLETE_MERGE_PY
|
||||
assert r"\1false" in _ENSURE_INSTALLED_PY
|
||||
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")
|
||||
|
||||
|
||||
def test_ensure_installed_clears_flag_without_comfy(tmp_path):
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from gpu_rent.provision import _ENSURE_INSTALLED_PY
|
||||
|
||||
settings = tmp_path / "Settings.fds"
|
||||
settings.write_text("IsInstalled: true\nTheme: modern_dark\n", encoding="utf-8")
|
||||
script = tmp_path / "ensure.py"
|
||||
script.write_text(_ENSURE_INSTALLED_PY, encoding="utf-8")
|
||||
env = os.environ.copy()
|
||||
env["GPU_RENT_SETTINGS_FDS"] = str(settings)
|
||||
env["GPU_RENT_COMFY_PRESENT"] = "0"
|
||||
out = subprocess.check_output([sys.executable, str(script)], env=env, text=True)
|
||||
assert "IsInstalled false" in out or "cleared" in out
|
||||
text = settings.read_text(encoding="utf-8")
|
||||
assert re.search(r"(?im)^\s*IsInstalled:\s*false\s*$", text)
|
||||
assert "Theme: modern_dark" in text
|
||||
|
||||
|
||||
def test_ensure_installed_sets_true_when_comfy_present(tmp_path):
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from gpu_rent.provision import _ENSURE_INSTALLED_PY
|
||||
|
||||
settings = tmp_path / "Settings.fds"
|
||||
settings.write_text("IsInstalled: false\n", encoding="utf-8")
|
||||
script = tmp_path / "ensure.py"
|
||||
script.write_text(_ENSURE_INSTALLED_PY, encoding="utf-8")
|
||||
env = os.environ.copy()
|
||||
env["GPU_RENT_SETTINGS_FDS"] = str(settings)
|
||||
env["GPU_RENT_COMFY_PRESENT"] = "1"
|
||||
subprocess.check_call([sys.executable, str(script)], env=env)
|
||||
text = settings.read_text(encoding="utf-8")
|
||||
assert re.search(r"(?im)^\s*IsInstalled:\s*true\s*$", text)
|
||||
|
||||
|
||||
def test_install_comfy_patches_is_installed_on_skip():
|
||||
from importlib.resources import files
|
||||
|
||||
@@ -113,3 +161,20 @@ def test_install_comfy_patches_is_installed_on_skip():
|
||||
)
|
||||
assert "ensure_settings_installed_flag" in text
|
||||
assert "leave /Install" in text
|
||||
assert "prepare_first_install" in text
|
||||
assert "already installed" in text
|
||||
assert "IsInstalled=false" in text
|
||||
assert "Open SwarmUI" not in text
|
||||
|
||||
|
||||
def test_clear_settings_installed_flag(tmp_path, monkeypatch):
|
||||
from gpu_rent.remote import install_swarm_comfy as inst
|
||||
|
||||
settings = tmp_path / "Settings.fds"
|
||||
settings.write_text("IsInstalled: true\nTheme: x\n", encoding="utf-8")
|
||||
monkeypatch.setattr(inst, "SETTINGS", settings)
|
||||
assert inst.clear_settings_installed_flag() is True
|
||||
text = settings.read_text(encoding="utf-8")
|
||||
assert "IsInstalled: false" in text
|
||||
assert "Theme: x" in text
|
||||
assert inst.clear_settings_installed_flag() is False
|
||||
|
||||
Reference in New Issue
Block a user