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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Stop TestProbeGating asserting a tier the mapping check is meant to upgrade (#9029)
Daniel Hanb46cc90f2ec6
diff --git a/studio/backend/tests/test_transformers_version.py b/studio/backend/tests/test_transformers_version.pyindex 595456bdc20..99f3c38dcc6 100644--- a/studio/backend/tests/test_transformers_version.py+++ b/studio/backend/tests/test_transformers_version.py@@ -49,6 +49,7 @@ from utils.transformers_version import (_higher_tier,_config_json_cache,_tokenizer_class_cache,+ _config_mapping_cache,_config_needs_510_cache,_config_needs_530_cache,_config_needs_550_cache,@@ -1473,6 +1474,10 @@ class TestProbeGating:_config_needs_510_cache.clear()_config_needs_550_cache.clear()_tokenizer_class_cache.clear()+ # Sixth cache, and the one this class used to miss. get_transformers_tier consults+ # CONFIG_MAPPING_NAMES per tier and upgrades a model_type the ambient default does+ # not ship, so a mapping parsed by an earlier test decides the answer here.+ _config_mapping_cache.clear()def _patch_venvs(self, monkeypatch):for fn in (@@ -1522,8 +1527,13 @@ class TestProbeGating:monkeypatch.setattr("utils.transformers_version._check_tokenizer_config_needs_v5", lambda m, t = None: False)+ # A model_type the ambient default DOES ship. "brandnew" is in none of the+ # mappings, so the static config-mapping tier upgraded it to 530 before the+ # version-field probe under test ever ran, and the assert below only passed+ # when an earlier test had left _config_mapping_cache in a state that skipped+ # that path. The probe, not the mapping upgrade, is the subject here._config_json_cache[("org/new", None)] = {- "model_type": "brandnew",+ "model_type": "llama","transformers_version": "5.0.0",}seen = []@@ -1541,8 +1551,9 @@ class TestProbeGating:monkeypatch.setattr("utils.transformers_version._check_tokenizer_config_needs_v5", lambda m, t = None: False)+ # Shipped by the ambient default, for the same reason as the test above._config_json_cache[("org/new", None)] = {- "model_type": "brandnew",+ "model_type": "llama","transformers_version": "5.6.0",}results = iter([_proc(1, "KeyError: 'x'"), _proc(1, "KeyError: 'x'"), _proc(0)])@@ -1554,6 +1565,46 @@ class TestProbeGating:assert get_transformers_tier("org/new") == "550"assert seen == ["", tv._VENV_T5_530_DIR, tv._VENV_T5_550_DIR]+ def test_a_model_type_the_default_lacks_never_reaches_the_version_field_probe(+ self, monkeypatch+ ):+ """The mapping check answers first, and short-circuits the probe below it.++ This ordering is what quietly invalidated the two tests above. They pinned+ model_type "brandnew", which no mapping ships, so once #7043 landed the mapping+ check answered before the version-field probe they were written for ever ran, and+ they began asserting the wrong branch's answer. Nothing pinned the ordering, so+ the only symptom was those two failing in a way that read like a probe bug.++ Pinning it here means a future reshuffle that puts the probe first fails as+ itself, and the two tests above keep testing the probe rather than this.+ """+ import utils.transformers_version as tv++ self._patch_venvs(monkeypatch)+ monkeypatch.setattr(+ "utils.transformers_version._check_tokenizer_config_needs_v5", lambda m, t = None: False+ )+ monkeypatch.setattr(+ tv,+ "_config_model_types",+ lambda tier: frozenset({"llama"} if tier == "default" else {"llama", "brandnew"}),+ )+ # Declares 5.x too, so the version-field probe below WOULD fire if it were reached.+ _config_json_cache[("org/brandnew", None)] = {+ "model_type": "brandnew",+ "transformers_version": "5.0.0",+ }+ probed = []+ monkeypatch.setattr(+ "utils.transformers_version.subprocess.run",+ lambda cmd, **k: probed.append(cmd[3]) or _proc(0),+ )++ tier = get_transformers_tier("org/brandnew")+ assert tier != "default", f"a model_type the default lacks must be raised, got {tier!r}"+ assert probed == [], "the mapping check must answer before any sidecar probe runs"+def test_ordinary_4x_config_does_not_probe(self, monkeypatch):self._patch_venvs(monkeypatch)monkeypatch.setattr(