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.

Studio: install transformers releases needing hub >= 1.31, and transformers main after consent (#12871)

Daniel Han2cda887dbbb2
diff --git a/studio/backend/models/inference.py b/studio/backend/models/inference.py
index 79b4a2eea8b..dfea78225f0 100644
--- a/studio/backend/models/inference.py
+++ b/studio/backend/models/inference.py
@@ -755,9 +755,20 @@ class TransformersUpgradeInfo(BaseModel):
)
supported_in_main: bool = Field(
False,
- description = "True if transformers GitHub main ships this model_type (dev-only; "
- "not installable through Unsloth yet).",
+ description = "True if transformers GitHub main ships this model_type; with main_version "
+ "set, Unsloth can install main into the persistent sidecar after user consent.",
)
+ main_version: Optional[str] = Field(
+ None, description = "transformers main __version__ (a .devN string) at check time"
+ )
+
+ @property
+ def installable(self) -> bool:
+ """The consent dialog can install it: the PyPI release, else transformers main."""
+ return bool(
+ (self.supported_in_pypi and self.pypi_version)
+ or (self.supported_in_main and self.main_version)
+ )
class TransformersUpgradeCheckRequest(BaseModel):
@@ -918,7 +929,7 @@ class ValidateModelResponse(BaseModel):
False,
description = "True when the model's architecture is unknown to every installed "
"transformers but a newer transformers ships it; the UI should offer the "
- "install-latest-transformers consent dialog (or the dev-only notice).",
+ "install-transformers consent dialog (a PyPI release, else transformers main).",
)
transformers_upgrade: Optional[TransformersUpgradeInfo] = Field(
None,
@@ -1342,6 +1353,9 @@ class InstallLatestTransformersResponse(BaseModel):
description = "On a version-mismatch failure: the release that superseded "
"the requested one, so the client can retry with it",
)
+ latest_main_version: Optional[str] = Field(
+ None, description = "On a version-mismatch failure: transformers main's current version"
+ )
class GenerateRequest(BaseModel):
diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py
index fb7c4c6fdb8..3562d6afd68 100644
--- a/studio/backend/routes/inference.py
+++ b/studio/backend/routes/inference.py
@@ -19821,8 +19821,7 @@ async def validate_model(
from utils.transformers_version import latest_tier_active_for
_install_only_upgrade = (
transformers_upgrade is not None
- and transformers_upgrade.supported_in_pypi
- and transformers_upgrade.pypi_version
+ and transformers_upgrade.installable
and not requires_trust_remote_code
)
if _install_only_upgrade or await asyncio.to_thread(
@@ -20231,15 +20230,14 @@ async def check_transformers_upgrade_route(
# An offered install lands the model on the latest sidecar, which forces 16-bit (bnb
# 4-bit feeds quantized experts into unvalidated paths for brand-new architectures).
- # A dev-only upgrade is never installed, so it changes nothing. Same rule /validate
+ # An upgrade with nothing to install changes nothing. Same rule /validate
# applies: a model with a custom-code fallback still loads 4-bit on the current
# transformers and the dialog offers that way out, so a merely offered upgrade
# cannot be claimed as 16-bit. Only an install-only upgrade, or a sidecar already
# routing the model, forces it.
install_only_upgrade = bool(
transformers_upgrade is not None
- and transformers_upgrade.supported_in_pypi
- and transformers_upgrade.pypi_version
+ and transformers_upgrade.installable
and not requires_trust_remote_code
)
# Already on the sidecar: the install is not what would strand the checkpoint, and
@@ -20279,7 +20277,8 @@ async def install_latest_transformers_route(
Called after the user confirms the transformers-upgrade dialog raised by /validate
(requires_transformers_upgrade). The requested version must match the current latest
- PyPI release (re-verified server-side); the sidecar then participates in routing on
+ PyPI release, or transformers main when only main ships the architecture (both
+ re-verified server-side); the sidecar then participates in routing on
this and every future start. A pip install runs off-loop, so this can take a minute.
"""
from utils.transformers_latest import install_latest_transformers
@@ -20479,7 +20478,7 @@ async def install_latest_transformers_route(
if owns_reservation:
end_sidecar_swap()
if not result["success"]:
- if result.get("latest_version"):
+ if result.get("latest_version") or result.get("latest_main_version"):
# Structured failure so the dialog can update to the newer release
# and offer a retry that can actually succeed.
return InstallLatestTransformersResponse(**result, model_unloaded = unloaded_chat["v"])
diff --git a/studio/backend/tests/test_training_transformers_upgrade_gate.py b/studio/backend/tests/test_training_transformers_upgrade_gate.py
index 75e07709533..93336f6e4e6 100644
--- a/studio/backend/tests/test_training_transformers_upgrade_gate.py
+++ b/studio/backend/tests/test_training_transformers_upgrade_gate.py
@@ -105,8 +105,17 @@ def test_installable_upgrade_is_reported_with_its_version(monkeypatch):
assert response.latest_tier_active is False
+def test_main_installable_upgrade_claims_16bit(monkeypatch):
+ # Installing transformers main lands the model on the same 16-bit sidecar.
+ inf_mod = _stub(
+ monkeypatch,
+ upgrade = {**UPGRADE, "supported_in_pypi": False, "main_version": "5.16.0.dev0"},
+ )
+ assert _call(inf_mod).forces_16bit is True
+
+
def test_dev_only_upgrade_does_not_claim_16bit(monkeypatch):
- # Unsloth never installs a transformers dev build, so nothing about the run changes.
+ # Main's version unknown: nothing can be installed, so nothing about the run changes.
inf_mod = _stub(
monkeypatch,
upgrade = {**UPGRADE, "supported_in_pypi": False},
diff --git a/studio/backend/tests/test_transformers_latest.py b/studio/backend/tests/test_transformers_latest.py
index d28ec68a1f2..f414a80a640 100644
--- a/studio/backend/tests/test_transformers_latest.py
+++ b/studio/backend/tests/test_transformers_latest.py
@@ -145,6 +145,8 @@ def _fake_urlopen_factory(counter: dict):
return _FakeResponse(_MAIN_ONLY_SOURCE.encode())
if "/main/" in url and url.endswith("configuration_auto.py"):
return _FakeResponse(b"CONFIG_MAPPING_NAMES = {}\n")
+ if url == f"{tl._MAIN_RAW}/src/transformers/__init__.py":
+ return _FakeResponse(b'__version__ = "5.14.0.dev0"\n')
raise AssertionError(f"unexpected URL fetched: {url}")
return _fake_urlopen
@@ -261,6 +263,7 @@ class TestLatestTransformersSupports:
"pypi_version": "5.13.0",
"supported_in_pypi": True,
"supported_in_main": True,
+ "main_version": "5.14.0.dev0",
}
def test_dev_only_arch_reported_main_only(self, monkeypatch):
@@ -268,6 +271,7 @@ class TestLatestTransformersSupports:
result = latest_transformers_supports("dev_only_arch")
assert result["supported_in_pypi"] is False
assert result["supported_in_main"] is True
+ assert result["main_version"] == "5.14.0.dev0"
def test_unknown_everywhere(self, monkeypatch):
monkeypatch.setattr("urllib.request.urlopen", _fake_urlopen_factory({}))
@@ -319,6 +323,29 @@ class TestLatestTransformersSupports:
latest_transformers_supports("brandnew_arch")
assert counter["__total__"] > first_total
+ def test_pre_main_version_snapshot_refetches(self, monkeypatch):
+ # A snapshot written before main_version existed must not hide the main install.
+ counter = {}
+ monkeypatch.setattr("urllib.request.urlopen", _fake_urlopen_factory(counter))
+ latest_transformers_supports("brandnew_arch")
+ old = dict(tl._memory_snapshot, schema = 1)
+ old.pop("main_version")
+ tl.clear_caches()
+ tl._save_snapshot_file(old)
+ result = latest_transformers_supports("dev_only_arch")
+ assert result["main_version"] == "5.14.0.dev0"
+
+ def test_failed_main_version_lookup_retries_after_backoff(self):
+ snapshot = {"main_checked": True, "main_version": None, "fetched_at": time.time()}
+ assert tl._snapshot_is_fresh(snapshot)
+ snapshot["fetched_at"] -= tl._FAILURE_BACKOFF_SECONDS + 1
+ assert not tl._snapshot_is_fresh(snapshot)
+ snapshot["main_version"] = "5.14.0.dev0"
+ assert tl._snapshot_is_fresh(snapshot)
+ # A failed main mapping fetch is retried after the same backoff.
+ snapshot["main_checked"] = False
+ assert not tl._snapshot_is_fresh(snapshot)
+
def test_corrupt_disk_cache_ignored(self, monkeypatch, tmp_path: Path):
counter = {}
monkeypatch.setattr("urllib.request.urlopen", _fake_urlopen_factory(counter))
@@ -376,6 +403,7 @@ class TestCheckUpgradeForModel:
"pypi_version": "5.13.0",
"supported_in_pypi": True,
"supported_in_main": True,
+ "main_version": "5.14.0.dev0",
}
def test_dev_only_type_signals_main_only(self, tmp_path: Path, monkeypatch):
@@ -746,6 +774,74 @@ class TestInstallLatestTransformers:
assert result["success"] is True
assert recorded["extras"] == ("tokenizers==0.23.0",)
+ def test_main_version_installs_after_consent(self, monkeypatch):
+ monkeypatch.setattr("urllib.request.urlopen", _fake_urlopen_factory({}))
+ monkeypatch.setattr(tl, "compat_plan", lambda v: ((), []))
+ recorded = {}
+
+ def _fake_ensure(
+ version,
+ extra_packages = (),
+ before_swap = None,
+ ):
+ recorded["version"] = version
+ recorded["source"] = tv._install_source(f"transformers=={version}")
+ return True
+
+ monkeypatch.setattr(tl, "_resolve_main_commit", lambda: "a" * 40)
+ monkeypatch.setattr(tl, "_fetch_main_version", lambda ref = "main": "5.14.0.dev0")
+ monkeypatch.setattr(tl, "ensure_latest_transformers_venv", _fake_ensure)
+ monkeypatch.setattr(tl, "latest_venv_pinned_version", lambda: "5.14.0.dev0")
+ result = install_latest_transformers("5.14.0.dev0")
+ assert result["success"] is True and "(main)" in result["message"]
+ assert recorded["version"] == "5.14.0.dev0"
+ # The archive is the commit whose version was checked, not the moving branch.
+ assert recorded["source"].endswith(f"/archive/{'a' * 40}.zip")
+ assert tv._install_source("transformers==5.14.0.dev0").endswith("refs/heads/main.zip")
+
+ def test_main_moved_since_check_rejected(self, monkeypatch):
+ monkeypatch.setattr("urllib.request.urlopen", _fake_urlopen_factory({}))
+ seen = iter(["5.14.0.dev0", "5.15.0.dev0"])
+ monkeypatch.setattr(tl, "_fetch_main_version", lambda ref = "main": next(seen))
+ monkeypatch.setattr(tl, "_resolve_main_commit", lambda: "b" * 40)
+ monkeypatch.setattr(
+ tl,
+ "ensure_latest_transformers_venv",
+ lambda v, extra_packages = (), before_swap = None: (_ for _ in ()).throw(
+ AssertionError("must not install")
+ ),
+ )
+ result = install_latest_transformers("5.14.0.dev0")
+ assert result["success"] is False and "no longer" in result["message"]
+ assert result["latest_main_version"] == "5.15.0.dev0"
+
+ def test_unresolvable_main_commit_rejected(self, monkeypatch):
+ monkeypatch.setattr("urllib.request.urlopen", _fake_urlopen_factory({}))
+ monkeypatch.setattr(tl, "_resolve_main_commit", lambda: None)
+ monkeypatch.setattr(
+ tl,
+ "ensure_latest_transformers_venv",
+ lambda v, extra_packages = (), before_swap = None: (_ for _ in ()).throw(
+ AssertionError("must not install")
+ ),
+ )
+ result = install_latest_transformers("5.14.0.dev0")
+ assert result["success"] is False and "Could not check" in result["message"]
+
+ def test_stale_main_version_rejected(self, monkeypatch):
+ monkeypatch.setattr("urllib.request.urlopen", _fake_urlopen_factory({}))
+ monkeypatch.setattr(
+ tl,
+ "ensure_latest_transformers_venv",
+ lambda v, extra_packages = (), before_swap = None: (_ for _ in ()).throw(
+ AssertionError("must not install")
+ ),
+ )
+ result = install_latest_transformers("5.12.0.dev0")
+ assert result["success"] is False
+ # Retry needs the current main, else it re-sends the stale dev version forever.
+ assert result["latest_main_version"] == "5.14.0.dev0"
+
class TestCompatPlan:
def _patch_env(self, monkeypatch, requires, installed):
@@ -800,6 +896,26 @@ class TestCompatPlan:
extras, blockers = tl.compat_plan("5.99.0")
assert blockers == ["huggingface-hub>=2.1"]
+ def test_sidecar_hub_shadowed_by_base_env_pins(self, monkeypatch):
+ self._patch_env(
+ monkeypatch,
+ ["huggingface-hub<2.0,>=1.31.0"],
+ {"huggingface-hub": "1.32.0", "hf-xet": "1.5.2"},
+ )
+ extras, blockers = tl.compat_plan("5.18.0")
+ assert blockers == []
+ assert extras == ("huggingface-hub==1.32.0", "hf-xet==1.5.2")
+
+ def test_dev_version_reads_main_setup_py(self, monkeypatch):
+ monkeypatch.setattr(
+ tl,
+ "_fetch_requires_dist",
+ lambda v: (_ for _ in ()).throw(AssertionError("dev builds are not on PyPI")),
+ )
+ monkeypatch.setattr(tl, "_fetch_main_requires", lambda: ["numpy>=99.0"])
+ extras, blockers = tl.compat_plan("5.14.0.dev0")
+ assert blockers == ["numpy>=99.0"]
+
def test_unfetchable_requires_dist_blocks_install(self, monkeypatch):
# Proceeding unverified could pin a sidecar whose imports crash workers.
monkeypatch.setattr(tl, "_fetch_requires_dist", lambda v: None)
@@ -1502,3 +1618,44 @@ def test_upgrade_offer_survives_a_broken_hardware_import(monkeypatch):
monkeypatch.setitem(sys.modules, "utils.hardware", broken)
assert tl._architecture_cannot_come_from_transformers() is False
+
+
+def test_fetch_main_requires_parses_setup_py(monkeypatch):
+ setup_py = textwrap.dedent(
+ """
+ _deps = [
+ "huggingface-hub>=1.31.0,<2.0",
+ "numpy>=1.17",
+ "pytest>=7.2.0",
+ "tokenizers>=0.22.0,<=0.23.0",
+ ]
+
+ install_requires = [
+ deps["huggingface-hub"],
+ deps["numpy"],
+ deps["tokenizers"],
+ ]
+ """
+ )
+ monkeypatch.setattr(tl, "_fetch_text", lambda url: setup_py)
+ assert tl._fetch_main_requires() == [
+ "huggingface-hub>=1.31.0,<2.0",
+ "numpy>=1.17",
+ "tokenizers>=0.22.0,<=0.23.0",
+ ]
+
+
+def test_fetch_main_requires_reads_the_pinned_commit(monkeypatch):
+ seen = []
+ monkeypatch.setattr(tl, "_fetch_text", lambda url: seen.append(url))
+ tl._fetch_main_requires()
+ with tv.transformers_main_at("e" * 40):
+ tl._fetch_main_requires()
+ assert seen[0].endswith("/main/setup.py") and seen[1].endswith(f"/{'e' * 40}/setup.py")
+
+
+def test_fetch_main_version_requires_dev_string(monkeypatch):
+ monkeypatch.setattr(tl, "_fetch_text", lambda url: '__version__ = "5.18.0"\n')
+ assert tl._fetch_main_version() is None
+ monkeypatch.setattr(tl, "_fetch_text", lambda url: '__version__ = "5.19.0.dev0"\n')
+ assert tl._fetch_main_version() == "5.19.0.dev0"
diff --git a/studio/backend/tests/test_transformers_version.py b/studio/backend/tests/test_transformers_version.py
index 0038e9da84f..54e34863bd8 100644
--- a/studio/backend/tests/test_transformers_version.py
+++ b/studio/backend/tests/test_transformers_version.py
@@ -3293,8 +3293,8 @@ class TestLatestTierForces16Bit:
"_guard_chat_load_against_training"
), "the upgrade check must run before the training guard"
assert (
- "supported_in_pypi" in body.split("_guard_chat_load_against_training")[0]
- ), "an installable upgrade must force 16-bit sizing for the guard"
+ ".installable" in body.split("_guard_chat_load_against_training")[0]
+ ), "an installable upgrade (PyPI or main) must force 16-bit sizing for the guard"
def test_validate_offered_upgrade_preserves_custom_code_4bit(self):
# A merely-offered (not installed) upgrade must NOT force 16-bit sizing when the
@@ -4252,3 +4252,59 @@ class TestDamagedLatestSidecarRepairHandoff:
tv._probe_tier("some/model", None, "test", include_default = True, floor = "default")
!= "latest"
)
+
+
+class TestTransformersMainSource:
+ def test_dev_pin_installs_from_main_archive(self):
+ import utils.transformers_version as tv
+
+ assert tv._install_source("transformers==5.19.0.dev0").endswith(
+ "/transformers/archive/refs/heads/main.zip"
+ )
+ with tv.transformers_main_at("c" * 40):
+ assert tv._install_source("transformers==5.19.0.dev0").endswith(f"/{'c' * 40}.zip")
+ assert tv._install_source("transformers==5.19.0.dev0").endswith("refs/heads/main.zip")
+ assert tv._install_source("transformers==5.18.0") == "transformers==5.18.0"
+ assert tv._install_source("tokenizers==0.23.0") == "tokenizers==0.23.0"
+
+ def test_extra_pins_replace_base_sidecar_pins(self):
+ import utils.transformers_version as tv
+
+ pkgs = tv._venv_t5_latest_packages(
+ "5.19.0.dev0", ("huggingface-hub==1.32.0", "hf-xet==1.5.2")
+ )
+ assert "huggingface_hub==1.8.0" not in pkgs and "hf_xet==1.4.2" not in pkgs
+ assert pkgs.count("huggingface-hub==1.32.0") == 1 and "hf-xet==1.5.2" in pkgs
+ assert pkgs[0] == "transformers==5.19.0.dev0"
+
+ def test_main_sidecar_is_never_repaired_without_consent(self, monkeypatch):
+ import utils.transformers_version as tv
+
+ monkeypatch.setattr(
+ tv,
+ "_latest_pin_data",
+ lambda: {"version": "5.19.0.dev0", "packages": ["transformers==5.19.0.dev0"]},
+ )
+ monkeypatch.setattr(tv, "_venv_dir_health", lambda d, p: (False, True))
+ monkeypatch.setattr(tv, "_request_latest_repair", lambda: None)
+ monkeypatch.setattr(
+ tv,
+ "_stage_and_swap_latest_venv",
+ lambda *a, **k: (_ for _ in ()).throw(AssertionError("must not reinstall main")),
+ )
+ assert tv._ensure_venv_t5_latest_exists() is False
+
+ def test_consented_main_install_rebuilds_a_healthy_sidecar(self, monkeypatch):
+ import utils.transformers_version as tv
+
+ packages = tv._venv_t5_latest_packages("5.19.0.dev0")
+ monkeypatch.setattr(
+ tv, "_latest_pin_data", lambda: {"version": "5.19.0.dev0", "packages": list(packages)}
+ )
+ monkeypatch.setattr(tv, "_venv_dir_is_valid_and_undamaged", lambda d, p: True)
+ monkeypatch.setattr(tv, "_top_up_optional_packages", lambda d, p: "reused")
+ monkeypatch.setattr(tv, "_stage_and_swap_latest_venv", lambda *a, **k: "rebuilt")
+ assert tv.ensure_latest_transformers_venv("5.19.0.dev0") == "reused"
+ # Same .devN, newer main commit: the sidecar may lack the newly requested architecture.
+ with tv.transformers_main_at("d" * 40):
+ assert tv.ensure_latest_transformers_venv("5.19.0.dev0") == "rebuilt"
diff --git a/studio/backend/utils/transformers_latest.py b/studio/backend/utils/transformers_latest.py
index aec16a5c377..7569621bced 100644
--- a/studio/backend/utils/transformers_latest.py
+++ b/studio/backend/utils/transformers_latest.py
@@ -9,7 +9,7 @@ Unsloth cannot load it today. This module answers, without authentication, code
or trust_remote_code:
1. Does the LATEST transformers release on PyPI ship this ``model_type``?
- 2. Does transformers ``main`` on GitHub ship it (dev-only, not yet installable)?
+ 2. Does transformers ``main`` on GitHub ship it (installable from main after consent)?
Sources (all unauthenticated; raw.githubusercontent.com is not API rate-limited and
api.github.com is deliberately never used):
@@ -34,8 +34,10 @@ persistent ``.venv_t5_latest`` sidecar via
:func:`utils.transformers_version.ensure_latest_transformers_venv`.
"""
+import contextlib
import json
import os
+import re
import threading
import time
from pathlib import Path
@@ -81,9 +83,11 @@ _CACHE_TTL_SECONDS = 24 * 60 * 60
_FAILURE_BACKOFF_SECONDS = 300
_CACHE_FILE_NAME = "transformers_latest_check.json"
-_SNAPSHOT_SCHEMA = 1
+# 2 adds main_version: a schema-1 file would hide the main install until its TTL.
+_SNAPSHOT_SCHEMA = 2
-# Snapshot: {"schema", "fetched_at", "pypi_version", "pypi_model_types", "main_model_types"}.
+# Snapshot: {"schema", "fetched_at", "pypi_version", "pypi_model_types", "main_model_types",
+# "main_checked", "main_version"}.
# Install-in-progress state lives in utils.transformers_version (the sidecar swap reservation).
_lock = threading.Lock()
_memory_snapshot: dict | None = None
@@ -252,10 +256,15 @@ def _save_snapshot_file(snapshot: dict) -> None:
def _snapshot_is_fresh(snapshot: dict | None) -> bool:
- return (
- snapshot is not None
- and (time.time() - float(snapshot.get("fetched_at", 0))) < _CACHE_TTL_SECONDS
+ if snapshot is None:
+ return False
+ # A failed main lookup (mappings or version) would otherwise hide the main install all day.
+ ttl = (
+ _CACHE_TTL_SECONDS
+ if snapshot.get("main_checked") and snapshot.get("main_version")
+ else _FAILURE_BACKOFF_SECONDS
)
+ return (time.time() - float(snapshot.get("fetched_at", 0))) < ttl
def _refresh_snapshot() -> dict | None:
@@ -272,6 +281,7 @@ def _refresh_snapshot() -> dict | None:
if pypi_types is None:
return None
main_types = _fetch_remote_model_types("main")
+ main_version = _fetch_main_version() if main_types is not None else None
return {
"schema": _SNAPSHOT_SCHEMA,
"fetched_at": time.time(),
@@ -279,6 +289,7 @@ def _refresh_snapshot() -> dict | None:
"pypi_model_types": sorted(pypi_types),
"main_model_types": sorted(main_types) if main_types is not None else [],
"main_checked": main_types is not None,
+ "main_version": main_version,
}
@@ -424,6 +435,7 @@ def latest_transformers_supports(model_type: str) -> dict | None:
"pypi_version": snapshot["pypi_version"],
"supported_in_pypi": model_type in set(snapshot["pypi_model_types"]),
"supported_in_main": model_type in set(snapshot["main_model_types"]),
+ "main_version": snapshot.get("main_version"),
}
@@ -500,6 +512,7 @@ def check_upgrade_for_model(model_name: str, hf_token: str | None = None) -> dic
"pypi_version": supports[0]["pypi_version"],
"supported_in_pypi": supported_in_pypi,
"supported_in_main": supported_in_main,
+ "main_version": supports[0].get("main_version"),
}
except Exception as exc:
logger.debug("Latest-transformers check failed for '%s': %s", model_name, exc)
@@ -519,6 +532,59 @@ def _canonical_dep_name(name: str) -> str:
return name.lower().replace("_", "-")
+_MAIN_RAW = "https://raw.githubusercontent.com/huggingface/transformers/main"
+
+
+def _fetch_main_version(ref: str = "main") -> str | None:
+ """``__version__`` on transformers *ref* (a ``.devN`` string), or None."""
+ from utils.transformers_version import _is_valid_version_string
+
+ body = _fetch_text(f"{_MAIN_RAW.rsplit('/', 1)[0]}/{ref}/src/transformers/__init__.py")
+ if body is None or body == _FETCH_MISSING:
+ return None
+ match = re.search(r'^__version__\s*=\s*"([^"]+)"', body, re.MULTILINE)
+ if (
+ match is None
+ or ".dev" not in match.group(1)
+ or not _is_valid_version_string(match.group(1))
+ ):
+ return None
+ return match.group(1)
+
+
+_MAIN_REFS = "https://github.com/huggingface/transformers.git/info/refs?service=git-upload-pack"
+
+
+def _resolve_main_commit() -> str | None:
+ """The commit main points at, from git's ref advertisement (not the rate-limited API)."""
+ body = _fetch_text(_MAIN_REFS)
+ if body is None or body == _FETCH_MISSING:
+ return None
+ match = re.search(r"([0-9a-f]{40}) refs/heads/main(?:\x00|\n)", body)
+ return match.group(1) if match else None
+
+
+def _fetch_main_requires() -> list[str] | None:
+ """Core install_requires of transformers main (at the commit being installed), from setup.py."""
+ from utils import transformers_version as tv
+
+ ref = tv._main_archive_commit or "main"
+ body = _fetch_text(f"{_MAIN_RAW.rsplit('/', 1)[0]}/{ref}/setup.py")
+ if body is None or body == _FETCH_MISSING:
+ return None
+ deps_block = re.search(r"^_deps = \[(.*?)^\]", body, re.MULTILINE | re.DOTALL)
+ install_block = re.search(r"^install_requires = \[(.*?)^\]", body, re.MULTILINE | re.DOTALL)
+ if deps_block is None or install_block is None:
+ return None
+ deps = {}
+ for spec in re.findall(r'"([^"]+)"', deps_block.group(1)):
+ deps[re.split(r"[<>=!~ \[;]", spec, maxsplit = 1)[0]] = spec
+ names = re.findall(r'deps\["([^"]+)"\]', install_block.group(1))
+ if not names or any(name not in deps for name in names):
+ return None
+ return [deps[name] for name in names]
+
+
def _fetch_requires_dist(version: str) -> list[str] | None:
"""Core (marker-free, non-extra) requires_dist of transformers *version* from PyPI."""
body = _fetch_text(f"https://pypi.org/pypi/transformers/{version}/json")
@@ -568,7 +634,7 @@ def compat_plan(version: str) -> tuple[tuple[str, ...], list[str]]:
install: proceeding unverified could pin a sidecar whose imports then crash the
workers, and the caller just reached PyPI for the version check so a retry is cheap.
"""
- reqs = _fetch_requires_dist(version)
+ reqs = _fetch_main_requires() if ".dev" in version else _fetch_requires_dist(version)
if reqs is None:
return (), ["dependency metadata for this release (could not be fetched from PyPI; retry)"]
try:
@@ -591,7 +657,15 @@ def compat_plan(version: str) -> tuple[tuple[str, ...], list[str]]:
continue
if name in _SIDECAR_PROVIDED:
if not req.specifier.contains(_SIDECAR_PROVIDED[name], prereleases = True):
- blockers.append(raw)
+ # studio.txt already ships a newer hub: pin the base env's hub + hf-xet pair instead.
+ base_pins = _base_env_sidecar_pins()
+ base_name_pin = next((p for p in base_pins if p.startswith(f"{name}==")), None)
+ if base_name_pin and req.specifier.contains(
+ base_name_pin.split("==", 1)[1], prereleases = True
+ ):
+ extras.extend(p for p in base_pins if p not in extras)
+ else:
+ blockers.append(raw)
continue
try:
installed = _installed_version(req.name)
@@ -610,6 +684,20 @@ def compat_plan(version: str) -> tuple[tuple[str, ...], list[str]]:
return tuple(extras), blockers
+def _base_env_sidecar_pins() -> list[str]:
+ """Exact pins of the base env's own huggingface-hub and hf-xet (empty if either is missing)."""
+ from importlib.metadata import PackageNotFoundError
+ from importlib.metadata import version as _installed_version
+
+ pins = []
+ for name in _SIDECAR_PROVIDED:
+ try:
+ pins.append(f"{name}=={_installed_version(name)}")
+ except PackageNotFoundError:
+ return []
+ return pins
+
+
def is_install_in_progress() -> bool:
"""True while a latest-transformers install or lazy repair holds the sidecar swap
reservation. Training and export starts check this so a fresh worker never
@@ -680,26 +768,53 @@ def _install_latest_transformers_locked(version: str, before_swap = None) -> dic
"version": version,
"message": "Could not verify the latest transformers release on PyPI.",
}
- if version != snapshot["pypi_version"]:
+ from_main = (
+ version != snapshot["pypi_version"]
+ and snapshot.get("main_checked")
+ and version == snapshot.get("main_version")
+ )
+ if version != snapshot["pypi_version"] and not from_main:
return {
"success": False,
"version": version,
"message": f"Requested version {version!r} is not the latest transformers "
f"release ({snapshot['pypi_version']}).",
- # Lets the consent dialog retry with the release that superseded the
- # one /validate saw, instead of re-sending the stale version forever.
+ # Retry uses these instead of re-sending the stale version forever.
"latest_version": snapshot["pypi_version"],
+ "latest_main_version": snapshot.get("main_version"),
}
- extra_packages, blockers = compat_plan(version)
- if blockers:
+ main_commit = current_main = None
+ if from_main:
+ # Check the version at one commit and install that commit, so main cannot move between.
+ main_commit = _resolve_main_commit()
+ current_main = _fetch_main_version(main_commit) if main_commit else None
+ if from_main and current_main != version:
return {
"success": False,
"version": version,
- "message": "Cannot install transformers "
- f"{version}: this environment does not satisfy {', '.join(blockers)}. "
- "An Unsloth update is required first.",
+ "message": f"transformers main is no longer {version}; retry to install the current main."
+ if current_main
+ else "Could not check transformers main; retry.",
+ "latest_version": snapshot["pypi_version"],
+ "latest_main_version": current_main,
}
- if not ensure_latest_transformers_venv(version, extra_packages, before_swap = before_swap):
+ from utils.transformers_version import transformers_main_at
+
+ # Requirements and archive both come from the pinned commit.
+ with transformers_main_at(main_commit) if main_commit else contextlib.nullcontext():
+ extra_packages, blockers = compat_plan(version)
+ if blockers:
+ return {
+ "success": False,
+ "version": version,
+ "message": "Cannot install transformers "
+ f"{version}: this environment does not satisfy {', '.join(blockers)}. "
+ "An Unsloth update is required first.",
+ }
+ installed = ensure_latest_transformers_venv(
+ version, extra_packages, before_swap = before_swap
+ )
+ if not installed:
return {
"success": False,
"version": version,
@@ -709,7 +824,7 @@ def _install_latest_transformers_locked(version: str, before_swap = None) -> dic
return {
"success": True,
"version": version,
- "message": f"Installed transformers {version} into the latest sidecar "
+ "message": f"Installed transformers {version}{' (main)' if from_main else ''} into the latest sidecar "
f"(pinned: {latest_venv_pinned_version()}).",
}
diff --git a/studio/backend/utils/transformers_version.py b/studio/backend/utils/transformers_version.py
index b6e25bad238..cf0ab115a9f 100644
--- a/studio/backend/utils/transformers_version.py
+++ b/studio/backend/utils/transformers_version.py
@@ -2408,6 +2408,7 @@ def _venv_t5_is_valid() -> bool:
def _install_to_dir(pkg: str, target_dir: str) -> bool:
"""Install a single package into *target_dir*, preferring uv then pip."""
+ pkg = _install_source(pkg)
# Try uv first (faster) if on PATH -- do NOT install uv at runtime.
if shutil.which("uv"):
result = subprocess.run(
@@ -3325,12 +3326,44 @@ def _venv_t5_latest_packages(version: str, extra_packages: tuple[str, ...] = ())
"""Package set for the latest sidecar; mirrors the fixed .venv_t5_* sidecars.
*extra_packages* carries dep-compat shadows (e.g. a newer tokenizers) computed by
utils.transformers_latest before install."""
- return (
+ base = (
f"transformers=={version}",
"huggingface_hub==1.8.0",
"hf_xet==1.4.2",
"tiktoken",
- ) + tuple(extra_packages)
+ )
+ overridden = {_pin_spec_name(p) for p in extra_packages}
+ return tuple(p for p in base if _pin_spec_name(p) not in overridden) + tuple(extra_packages)
+
+
+def _pin_spec_name(spec: str) -> str:
+ # PEP 503 name normalization, so huggingface_hub and huggingface-hub collide.
+ return re.sub(r"[-_.]+", "-", re.split(r"[<>=!~ @;\[]", spec, maxsplit = 1)[0]).lower()
+
+
+# PyPI never hosts a transformers .devN build, so a dev pin means main (the zip needs no git).
+_TRANSFORMERS_MAIN_ARCHIVE = (
+ "transformers @ https://github.com/huggingface/transformers/archive/{ref}.zip"
+)
+# The main commit the consented install checked; installs are serialized by the swap reservation.
+_main_archive_commit: str | None = None
+
+
+def transformers_main_at(commit: str):
+ """Install transformers main from *commit* (not the moving branch) inside this block."""
+ global _main_archive_commit
+ previous, _main_archive_commit = _main_archive_commit, commit
+ try:
+ yield
+ finally:
+ _main_archive_commit = previous
+
+
+def _install_source(pkg: str) -> str:
+ if re.fullmatch(r"transformers==[0-9.]+\.dev[0-9]+", pkg):
+ return _TRANSFORMERS_MAIN_ARCHIVE.format(ref = _main_archive_commit or "refs/heads/main")
+ return pkg
# Single reservation for ANY .venv_t5_latest replacement (consented install or lazy
@@ -3615,6 +3648,14 @@ def _ensure_venv_t5_latest_exists() -> bool:
# the sidecar whichever we take: it cannot see sub-file damage itself, and a mapping
# cached before the damage keeps it off the scanning path. A successful repair clears it.
_request_latest_repair()
+ if ".dev" in version:
+ # A rebuild would install main code nobody consented to; broken -> the dialog offers it again.
+ logger.warning(
+ ".venv_t5_latest (transformers %s from main) is incomplete; load the model again "
+ "to reinstall it.",
+ version,
+ )
+ return False
if _env_offline():
logger.warning(
".venv_t5_latest (transformers %s) is incomplete and offline mode is set; "
@@ -3682,6 +3723,8 @@ def ensure_latest_transformers_venv(
pin = _latest_pin_data()
if (
pin is not None
+ # A consented main install always rebuilds: main gains architectures without a .devN bump.
+ and _main_archive_commit is None
and pin["version"] == version
and tuple(pin["packages"]) == packages
and _venv_dir_is_valid_and_undamaged(_VENV_T5_LATEST_DIR, packages)
diff --git a/studio/frontend/src/features/training/lib/training-transformers-upgrade.ts b/studio/frontend/src/features/training/lib/training-transformers-upgrade.ts
index e815bb2e9f2..a7af627e46e 100644
--- a/studio/frontend/src/features/training/lib/training-transformers-upgrade.ts
+++ b/studio/frontend/src/features/training/lib/training-transformers-upgrade.ts
@@ -6,6 +6,7 @@ import {
type TransformersUpgradeCheck,
checkTransformersUpgrade,
confirmTransformersUpgradeIfNeeded,
+ upgradeInstallVersion,
useTransformersUpgradeDialogStore,
} from "@/features/transformers-upgrade";
@@ -49,11 +50,10 @@ export function trainingTransformersUpgradeNotice(
check: TransformersUpgradeCheck,
loadsIn4Bit: boolean,
): TrainingTransformersUpgradeNotice {
- const installable = Boolean(
- check.upgrade?.supported_in_pypi && check.upgrade?.pypi_version,
- );
+ const installVersion = upgradeInstallVersion(check.upgrade);
+ const installable = installVersion !== null;
return {
- installVersion: installable ? (check.upgrade?.pypi_version ?? null) : null,
+ installVersion,
fourBitUnavailable: check.forces16Bit && loadsIn4Bit,
installSwitchesTo16Bit: installable && !check.forces16Bit && loadsIn4Bit,
};
@@ -73,7 +73,7 @@ export function getTrainingTransformersUpgradeRequiredMessage(
export function getTrainingTransformersUpgradeUnavailableMessage(
modelName: string,
): string {
- return `${modelName} is not supported yet by the installed transformers, and no released transformers version supports it either: the architecture is only on the transformers development branch, which Unsloth does not install. Wait for the next transformers release, or pick a model the installed transformers supports.`;
+ return `${modelName} is not supported yet by the installed transformers, and no released transformers version supports it either: the architecture is only on the transformers development branch, whose version could not be checked right now. Try again in a few minutes to install it, or pick a model the installed transformers supports.`;
}
/** The resume that installing would strand: the checkpoint is attested against a 4-bit
@@ -130,11 +130,7 @@ export async function confirmTrainingTransformersUpgrade({
requiresTrustRemoteCode,
};
}
- // Only a released version is ever installed, so every branch that talks about
- // installing checks this first.
- const installable = Boolean(
- check.upgrade.supported_in_pypi && check.upgrade.pypi_version,
- );
+ const installable = upgradeInstallVersion(check.upgrade) !== null;
if (check.installBreaksExactResume) {
// The checkpoint is attested against a 4-bit load the latest sidecar refuses, and
// that sidecar is a persistent overlay: consenting would strand it for good.
@@ -160,9 +156,8 @@ export async function confirmTrainingTransformersUpgrade({
requiresTrustRemoteCode,
};
}
- // Dev-only: no release to install, so nothing can strand anything, and "start a new
- // run instead" cannot work either. Fall through to the dev-only path, which says the
- // true thing: wait for the next release.
+ // Nothing installable (main's version unknown), so nothing can strand anything, and
+ // "start a new run instead" cannot work either. Fall through to the retry message.
}
const upgraded = await confirmTransformersUpgradeIfNeeded({
@@ -187,8 +182,7 @@ export async function confirmTrainingTransformersUpgrade({
.catch(() => undefined);
}
if (!upgraded) {
- // "Start again to install it" only means something when there is something to
- // install; a dev-only upgrade would send the user round a loop that never ends.
+ // "Start again to install it" only means something when there is something to install.
return {
proceed: false,
error: installable
diff --git a/studio/frontend/src/features/transformers-upgrade/api/transformers-upgrade-api.ts b/studio/frontend/src/features/transformers-upgrade/api/transformers-upgrade-api.ts
index 94ee30c64fe..56342e09213 100644
--- a/studio/frontend/src/features/transformers-upgrade/api/transformers-upgrade-api.ts
+++ b/studio/frontend/src/features/transformers-upgrade/api/transformers-upgrade-api.ts
@@ -77,6 +77,8 @@ interface InstallLatestTransformersResponse {
/** On a version-mismatch failure: the release that superseded the requested
* one, so Retry can use it. */
latest_version?: string | null;
+ /** On a version-mismatch failure: transformers main's current version. */
+ latest_main_version?: string | null;
}
/** Consented install of the latest transformers into the sidecar; synchronous, can take minutes.
diff --git a/studio/frontend/src/features/transformers-upgrade/components/transformers-upgrade-dialog.tsx b/studio/frontend/src/features/transformers-upgrade/components/transformers-upgrade-dialog.tsx
index 8a6cd3947a9..897c505fee9 100644
--- a/studio/frontend/src/features/transformers-upgrade/components/transformers-upgrade-dialog.tsx
+++ b/studio/frontend/src/features/transformers-upgrade/components/transformers-upgrade-dialog.tsx
@@ -15,7 +15,10 @@ import { Spinner } from "@/components/ui/spinner";
import { cn } from "@/lib/utils";
import { PackageIcon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import { upgradeDialogActions } from "../lib/upgrade-dialog-actions";
+import {
+ upgradeDialogActions,
+ upgradeInstallVersion,
+} from "../lib/upgrade-dialog-actions";
import { useTransformersUpgradeDialogStore } from "../stores/transformers-upgrade-dialog-store";
function modelDisplayName(modelName: string | null): string {
@@ -39,9 +42,8 @@ export function TransformersUpgradeDialog() {
const displayName = modelDisplayName(modelName);
const modelType = upgrade?.model_type ?? "unknown";
- const version = upgrade?.pypi_version ?? null;
- // Only released PyPI versions are installable; dev (main) builds are never offered.
- const { installable, devOnly, customCode } = upgradeDialogActions({
+ const version = upgradeInstallVersion(upgrade);
+ const { installable, fromMain, devOnly, customCode } = upgradeDialogActions({
upgrade,
phase,
trustRemoteCodeFallback,
@@ -73,7 +75,18 @@ export function TransformersUpgradeDialog() {
<span className="font-mono text-foreground">{modelType}</span>{" "}
architecture, which your installed transformers does not
support yet.{" "}
- {installable ? (
+ {installable && fromMain ? (
+ <>
+ No transformers release supports it yet, but the
+ development branch (main) does. Install transformers{" "}
+ <span className="font-medium text-foreground">
+ {version}
+ </span>{" "}
+ from main to load it. Development builds are not releases
+ and can change; the install runs once and loading
+ continues automatically afterwards.
+ </>
+ ) : installable ? (
<>
Install transformers{" "}
<span className="font-medium text-foreground">
@@ -86,9 +99,8 @@ export function TransformersUpgradeDialog() {
<>
Even the latest transformers release on PyPI does not
support it yet: the architecture is only available on the
- transformers development branch (main), and Unsloth does
- not install development builds. Support arrives with the
- next transformers release on PyPI.
+ transformers development branch (main), whose version
+ could not be checked right now. Try again later.
</>
) : (
<>
diff --git a/studio/frontend/src/features/transformers-upgrade/index.ts b/studio/frontend/src/features/transformers-upgrade/index.ts
index 3d079e55927..ce9e50ac553 100644
--- a/studio/frontend/src/features/transformers-upgrade/index.ts
+++ b/studio/frontend/src/features/transformers-upgrade/index.ts
@@ -7,6 +7,7 @@ export {
checkTransformersUpgrade,
installLatestTransformers,
} from "./api/transformers-upgrade-api";
+export { upgradeInstallVersion } from "./lib/upgrade-dialog-actions";
export { useTransformersUpgradeDialogStore } from "./stores/transformers-upgrade-dialog-store";
export type {
ModelCachePin,
diff --git a/studio/frontend/src/features/transformers-upgrade/lib/upgrade-dialog-actions.ts b/studio/frontend/src/features/transformers-upgrade/lib/upgrade-dialog-actions.ts
index aca974d3d01..f0456c227ad 100644
--- a/studio/frontend/src/features/transformers-upgrade/lib/upgrade-dialog-actions.ts
+++ b/studio/frontend/src/features/transformers-upgrade/lib/upgrade-dialog-actions.ts
@@ -8,15 +8,30 @@ import type {
/** Which ways out the consent dialog offers, besides Cancel. */
export interface UpgradeDialogActions {
- /** A released version exists, so the install is a real action. */
+ /** A released version, or transformers main, can be installed. */
installable: boolean;
- /** Only transformers main ships the architecture; nothing to install. */
+ /** The install is transformers main: no release ships the architecture yet. */
+ fromMain: boolean;
+ /** Only transformers main ships the architecture and its version is unknown. */
devOnly: boolean;
/** Offer "Continue with custom code": the model's own modeling code loads it on the
* transformers already installed, so the caller's trust_remote_code gate is a way out. */
customCode: boolean;
}
+/** The version an install sends: the PyPI release, else transformers main. */
+export function upgradeInstallVersion(
+ upgrade: TransformersUpgradeInfo | null,
+): string | null {
+ if (upgrade?.supported_in_pypi && upgrade?.pypi_version) {
+ return upgrade.pypi_version;
+ }
+ if (upgrade?.supported_in_main && upgrade?.main_version) {
+ return upgrade.main_version;
+ }
+ return null;
+}
+
/** Decide the dialog's actions from the check that raised it.
*
* The custom-code fallback used to appear only with nothing to install, or after an
@@ -33,11 +48,13 @@ export function upgradeDialogActions({
phase: TransformersUpgradePhase;
trustRemoteCodeFallback: boolean;
}): UpgradeDialogActions {
- const installable = Boolean(
- upgrade?.supported_in_pypi && upgrade?.pypi_version,
- );
+ const fromPypi = Boolean(upgrade?.supported_in_pypi && upgrade?.pypi_version);
+ const fromMain =
+ !fromPypi && Boolean(upgrade?.supported_in_main && upgrade?.main_version);
+ const installable = fromPypi || fromMain;
return {
installable,
+ fromMain,
devOnly: !installable && Boolean(upgrade?.supported_in_main),
// Never mid-install: the install is running and this button would abandon it.
customCode: trustRemoteCodeFallback && phase !== "installing",
diff --git a/studio/frontend/src/features/transformers-upgrade/stores/transformers-upgrade-dialog-store.ts b/studio/frontend/src/features/transformers-upgrade/stores/transformers-upgrade-dialog-store.ts
index 0d377af8f9b..21980719b54 100644
--- a/studio/frontend/src/features/transformers-upgrade/stores/transformers-upgrade-dialog-store.ts
+++ b/studio/frontend/src/features/transformers-upgrade/stores/transformers-upgrade-dialog-store.ts
@@ -3,6 +3,7 @@
import { create } from "zustand";
import { installLatestTransformers } from "../api/transformers-upgrade-api";
+import { upgradeInstallVersion } from "../lib/upgrade-dialog-actions";
import type {
TransformersUpgradeInfo,
TransformersUpgradePhase,
@@ -89,7 +90,7 @@ export const useTransformersUpgradeDialogStore =
},
install: async () => {
const { upgrade, phase, forceCancelActive } = get();
- const version = upgrade?.pypi_version;
+ const version = upgradeInstallVersion(upgrade);
if (!version || phase === "installing") return;
const requestResolver = pendingResolver;
set({ phase: "installing", errorMessage: null });
@@ -137,8 +138,15 @@ export const useTransformersUpgradeDialogStore =
errorMessage: result.message || "Failed to install transformers.",
serverUnloadedChat:
get().serverUnloadedChat || Boolean(result.model_unloaded),
- ...(result.latest_version && upgrade
- ? { upgrade: { ...upgrade, pypi_version: result.latest_version } }
+ ...(upgrade && (result.latest_version || result.latest_main_version)
+ ? {
+ upgrade: {
+ ...upgrade,
+ pypi_version: result.latest_version ?? upgrade.pypi_version,
+ main_version:
+ result.latest_main_version ?? upgrade.main_version,
+ },
+ }
: {}),
});
}
diff --git a/studio/frontend/src/features/transformers-upgrade/types.ts b/studio/frontend/src/features/transformers-upgrade/types.ts
index 221930366ba..e1b13efb18f 100644
--- a/studio/frontend/src/features/transformers-upgrade/types.ts
+++ b/studio/frontend/src/features/transformers-upgrade/types.ts
@@ -9,8 +9,10 @@ export interface TransformersUpgradeInfo {
pypi_version?: string | null;
/** Latest PyPI release ships this model_type (installable after consent). */
supported_in_pypi?: boolean;
- /** Only transformers main ships it (dev-only; not installable). */
+ /** transformers main ships it; installable from main after consent when main_version is set. */
supported_in_main?: boolean;
+ /** transformers main version (a .devN string) at check time. */
+ main_version?: string | null;
}
export type TransformersUpgradePhase = "consent" | "installing" | "error";
diff --git a/studio/frontend/tests/helpers/transformers-upgrade-stub.d.mts b/studio/frontend/tests/helpers/transformers-upgrade-stub.d.mts
index 6539d06fcaf..7f94c2ac630 100644
--- a/studio/frontend/tests/helpers/transformers-upgrade-stub.d.mts
+++ b/studio/frontend/tests/helpers/transformers-upgrade-stub.d.mts
@@ -60,3 +60,5 @@ export declare const useTransformersUpgradeDialogStore: {
consumeServerUnloadedChat(): boolean;
};
};
+
+export declare function upgradeInstallVersion(upgrade: unknown): string | null;
diff --git a/studio/frontend/tests/helpers/transformers-upgrade-stub.mjs b/studio/frontend/tests/helpers/transformers-upgrade-stub.mjs
index aeb5cf8a655..c3f2bf813b9 100644
--- a/studio/frontend/tests/helpers/transformers-upgrade-stub.mjs
+++ b/studio/frontend/tests/helpers/transformers-upgrade-stub.mjs
@@ -70,3 +70,14 @@ export const useTransformersUpgradeDialogStore = {
};
},
};
+
+// Same rule as lib/upgrade-dialog-actions.ts: the PyPI release, else transformers main.
+export function upgradeInstallVersion(upgrade) {
+ if (upgrade?.supported_in_pypi && upgrade?.pypi_version) {
+ return upgrade.pypi_version;
+ }
+ if (upgrade?.supported_in_main && upgrade?.main_version) {
+ return upgrade.main_version;
+ }
+ return null;
+}
diff --git a/studio/frontend/tests/training-transformers-upgrade.test.ts b/studio/frontend/tests/training-transformers-upgrade.test.ts
index 70706645638..eb7605404f1 100644
--- a/studio/frontend/tests/training-transformers-upgrade.test.ts
+++ b/studio/frontend/tests/training-transformers-upgrade.test.ts
@@ -244,7 +244,7 @@ test("a resume with nothing to install is told the truth about why", async () =>
assert.equal(outcome.proceed, false);
assert.doesNotMatch(String(outcome.error), /Start a new run/);
assert.match(String(outcome.error), /development branch/);
- assert.match(String(outcome.error), /next transformers release/);
+ assert.match(String(outcome.error), /could not be checked right now/);
});
test("declining a dev-only upgrade is not told to start again and install it", async () => {
@@ -267,7 +267,7 @@ test("declining a dev-only upgrade is not told to start again and install it", a
assert.equal(outcome.proceed, false);
assert.doesNotMatch(String(outcome.error), /Start the run again/);
assert.match(String(outcome.error), /development branch/);
- assert.match(String(outcome.error), /next transformers release/);
+ assert.match(String(outcome.error), /could not be checked right now/);
});
test("declining an installable upgrade is still told how to get it", async () => {
diff --git a/studio/frontend/tests/transformers-upgrade-dialog-actions.test.ts b/studio/frontend/tests/transformers-upgrade-dialog-actions.test.ts
index 9de7310aa7a..9aa17689d96 100644
--- a/studio/frontend/tests/transformers-upgrade-dialog-actions.test.ts
+++ b/studio/frontend/tests/transformers-upgrade-dialog-actions.test.ts
@@ -10,7 +10,10 @@
import assert from "node:assert/strict";
import test from "node:test";
-import { upgradeDialogActions } from "../src/features/transformers-upgrade/lib/upgrade-dialog-actions.ts";
+import {
+ upgradeDialogActions,
+ upgradeInstallVersion,
+} from "../src/features/transformers-upgrade/lib/upgrade-dialog-actions.ts";
import type { TransformersUpgradeInfo } from "../src/features/transformers-upgrade/types.ts";
const INSTALLABLE: TransformersUpgradeInfo = {
@@ -76,7 +79,7 @@ test("a running install offers nothing that would abandon it", () => {
assert.equal(actions.customCode, false);
});
-test("a dev-only upgrade has nothing to install and says so", () => {
+test("a main-only upgrade without a known main version has nothing to install", () => {
const actions = upgradeDialogActions({
upgrade: DEV_ONLY,
phase: "consent",
@@ -101,7 +104,42 @@ test("an upgrade no transformers ships at all offers only Cancel", () => {
assert.deepEqual(actions, {
installable: false,
+ fromMain: false,
devOnly: false,
customCode: false,
});
});
+
+test("a main-only architecture installs transformers main after consent", () => {
+ const upgrade: TransformersUpgradeInfo = {
+ ...DEV_ONLY,
+ // biome-ignore lint/style/useNamingConvention: API schema
+ main_version: "5.19.0.dev0",
+ };
+ const actions = upgradeDialogActions({
+ upgrade,
+ phase: "consent",
+ trustRemoteCodeFallback: false,
+ });
+
+ assert.equal(actions.installable, true);
+ assert.equal(actions.fromMain, true);
+ assert.equal(actions.devOnly, false);
+ assert.equal(upgradeInstallVersion(upgrade), "5.19.0.dev0");
+});
+
+test("a released version wins over main", () => {
+ const upgrade: TransformersUpgradeInfo = {
+ ...INSTALLABLE,
+ // biome-ignore lint/style/useNamingConvention: API schema
+ main_version: "5.19.0.dev0",
+ };
+ const actions = upgradeDialogActions({
+ upgrade,
+ phase: "consent",
+ trustRemoteCodeFallback: false,
+ });
+
+ assert.equal(actions.fromMain, false);
+ assert.equal(upgradeInstallVersion(upgrade), "5.15.0");
+});