Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Tests: keep five tests off what the host has installed or downloaded (#13395)

Daniel Hanbf10801178a7
diff --git a/studio/backend/tests/test_media_model_index_accounts.py b/studio/backend/tests/test_media_model_index_accounts.py
index 9b63d60fa98..47cfd3a246c 100644
--- a/studio/backend/tests/test_media_model_index_accounts.py
+++ b/studio/backend/tests/test_media_model_index_accounts.py
@@ -12,6 +12,7 @@ import core.inference.media_model_index as index
import routes.models as models_route
from auth import policy
from storage import studio_db
+from utils import hf_cache_settings
from utils.account_context import OWNER, AccountContext, run_as
ALICE = AccountContext("a" * 32, "alice")
@@ -21,6 +22,11 @@ BOB = AccountContext("b" * 32, "bob")
@pytest.fixture
def home(monkeypatch, tmp_path):
monkeypatch.setenv("UNSLOTH_STUDIO_HOME", str(tmp_path))
+ # The scan also walks every known HF cache home: a host HF_HOME and the platform default
+ # ($XDG_CACHE_HOME or ~/.cache), which the suite-wide empty hub cache does not cover. On a
+ # machine with image models downloaded, they would be listed beside the private ones.
+ monkeypatch.delitem(hf_cache_settings._EXPLICIT_CACHE_ENV, "HF_HOME", raising = False)
+ monkeypatch.setenv("XDG_CACHE_HOME", str(tmp_path / "xdg"))
monkeypatch.setattr(policy, "installation_is_multi_user", lambda: True)
monkeypatch.setattr(models_route, "_local_model_task", lambda info: mas.IMAGE_TASK)
mas.invalidate_index()
diff --git a/studio/backend/tests/test_openai_catalog.py b/studio/backend/tests/test_openai_catalog.py
index f2b54753080..986e6230a42 100644
--- a/studio/backend/tests/test_openai_catalog.py
+++ b/studio/backend/tests/test_openai_catalog.py
@@ -15,6 +15,17 @@ if str(_BACKEND) not in sys.path:
import routes.inference as inf # noqa: E402
from core.inference import local_model_resolver as resolver # noqa: E402
import routes.models as models_mod
+import pytest
+
+
[email protected](autouse = True)
+def _no_host_default_hf_cache(monkeypatch, tmp_path):
+ """/v1/models appends media rows from a scan that walks every known HF cache home, a host
+ HF_HOME and the platform default included; keep it off whatever the host has downloaded."""
+ from utils import hf_cache_settings
+
+ monkeypatch.delitem(hf_cache_settings._EXPLICIT_CACHE_ENV, "HF_HOME", raising = False)
+ monkeypatch.setenv("XDG_CACHE_HOME", str(tmp_path / "xdg"))
class _Info:
diff --git a/studio/backend/tests/test_sandbox_linux.py b/studio/backend/tests/test_sandbox_linux.py
index 6b56d264637..6d2cb6f0d19 100644
--- a/studio/backend/tests/test_sandbox_linux.py
+++ b/studio/backend/tests/test_sandbox_linux.py
@@ -1579,6 +1579,14 @@ def _fake_editable(
encoding = "utf-8",
)
monkeypatch.syspath_prepend(str(site_dir))
+ # Only the fake: an editable install in the environment running the suite (pip install -e)
+ # would otherwise be granted too, and the expected roots would depend on the host.
+ from importlib import metadata
+
+ real_distributions = metadata.distributions
+ monkeypatch.setattr(
+ metadata, "distributions", lambda **kw: real_distributions(path = [str(site_dir)])
+ )
os_sandbox.editable_source_roots.cache_clear()
return site_dir
diff --git a/studio/backend/tests/test_training_gated_upstream.py b/studio/backend/tests/test_training_gated_upstream.py
index 90d9bbe094d..b778d9c6621 100644
--- a/studio/backend/tests/test_training_gated_upstream.py
+++ b/studio/backend/tests/test_training_gated_upstream.py
@@ -250,6 +250,9 @@ def test_pre_detect_reads_the_repo_the_loader_fetches(
monkeypatch.setattr(trainer_mod, "detect_audio_type_checked", probe)
monkeypatch.setattr(trainer_mod, "is_vision_model", vision)
monkeypatch.setattr(transformers, "AutoTokenizer", _Tokenizer, raising = False)
+ # The 4-bit row reads the 4-bit table only where bitsandbytes is usable; with unsloth
+ # importable on a CPU host it is not. The fallback has its own test below.
+ monkeypatch.setattr(trainer_mod, "_bitsandbytes_allows_4bit", lambda: True)
trainer = trainer_mod.UnslothTrainer()
trainer.pre_detect_and_load_tokenizer(
diff --git a/tests/test_async_grpo_fast_inference.py b/tests/test_async_grpo_fast_inference.py
index c78abb3a75e..352d8ba5d28 100644
--- a/tests/test_async_grpo_fast_inference.py
+++ b/tests/test_async_grpo_fast_inference.py
@@ -412,6 +412,9 @@ def test_trl_vllm_client_reads_this_server():
from trl.experimental.async_grpo.vllm_client import VLLMClient
except Exception:
pytest.skip("TRL AsyncGRPO not installed")
+ if not hasattr(VLLMClient, "load_lora_adapter"):
+ # TRL 1.13's client syncs full weights only; fast_inference requires TRL >= 1.14 for this.
+ pytest.skip("TRL < 1.14: VLLMClient has no LoRA adapter calls")
PartialState() # TRL logs through accelerate's logger
llm = _FakeLLM()
server = server_module.UnslothAsyncVLLMServer(_model(llm), sampling_params = _Sampling)