Files
gpu-rent/tests/test_server_plan.py
T
Leonid Pershin 2ab32a8ab5 Refactor LLM configuration to remove llamacpp support
- Removed references to llamacpp from configuration files, scripts, and documentation, streamlining the LLM setup process to focus solely on Ollama.
- Updated environment variables and paths to eliminate llamacpp-related entries, ensuring clarity in the configuration.
- Adjusted CLI commands and help messages to reflect the removal of llamacpp, enhancing user experience and reducing confusion.
- Revised documentation to provide clear guidance on using Ollama exclusively, including updates to setup instructions and runtime options.
2026-08-21 08:51:36 +03:00

62 lines
2.0 KiB
Python

from gpu_rent.inventory import FlavorInfo
from gpu_rent.ux import prompt_server_plan
from gpu_rent.varsfile import parse_vars_file, upsert_vars
def _cfg_stub(monkeypatch, data_gb: int = 100):
monkeypatch.setenv("OS_AUTH_URL", "https://example.invalid/identity/v3")
monkeypatch.setenv("OS_USER_DOMAIN_NAME", "999")
monkeypatch.setenv("OS_USERNAME", "svc")
monkeypatch.setenv("OS_PASSWORD", "secret")
monkeypatch.setenv("OS_PROJECT_ID", "proj")
monkeypatch.setenv("OS_REGION_NAME", "ru-7")
monkeypatch.setenv("GPU_RENT_AZ", "ru-7a")
monkeypatch.setenv("DATA_VOLUME_SIZE_GB", str(data_gb))
from gpu_rent.config import load_config
return load_config(require_auth=True)
def test_prompt_server_plan_with_ranked(monkeypatch, tmp_path):
cfg = _cfg_stub(monkeypatch)
monkeypatch.setattr("gpu_rent.paths.app_root", lambda: tmp_path)
f1 = FlavorInfo(
id="a", name="small", vcpus=4, ram_mb=16384, disabled=False, extra={}, label="4090-24"
)
f2 = FlavorInfo(
id="b", name="big", vcpus=12, ram_mb=65536, disabled=False, extra={}, label="4090-48"
)
monkeypatch.setattr(
"gpu_rent.ux.list_ranked_flavors",
lambda flavors, cfg: [f1, f2],
)
answers = iter(["2", "200", "2"])
def ask(msg: str, default: str = "") -> str:
return next(answers)
remembered: list[bool] = []
plan = prompt_server_plan(
cfg,
["x"],
picked=f1,
spot=True,
ask=ask,
confirm=lambda m: remembered.append(True) or False,
)
assert plan.flavor.id == "b"
assert plan.data_gb == 200
assert plan.spot is False
assert remembered
def test_upsert_vars(tmp_path):
path = tmp_path / "gpu-rent.vars"
path.write_text("# c\nLLM_RUNTIME=none\n", encoding="utf-8")
upsert_vars(path, {"LLM_RUNTIME": "ollama", "DATA_VOLUME_SIZE_GB": "200"})
data = parse_vars_file(path)
assert data["LLM_RUNTIME"] == "ollama"
assert data["DATA_VOLUME_SIZE_GB"] == "200"