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
Compare the upgraded studio.db by the rows the old build wrote, not its bytes (#11678)
Daniel Han0c8babaf91e5
diff --git a/studio/backend/tests/multi_account/legacy_probe.py b/studio/backend/tests/multi_account/legacy_probe.pyindex 78cd37f42ac..57046dd6755 100644--- a/studio/backend/tests/multi_account/legacy_probe.py+++ b/studio/backend/tests/multi_account/legacy_probe.py@@ -14,6 +14,7 @@ from .seed import (PASSWORD,SENTINEL,THREAD_ID,+ legacy_studio_rows,old_auth_row,seed_legacy_install,)@@ -23,6 +24,7 @@ def main() -> None:home = Path(os.environ["UNSLOTH_STUDIO_HOME"])original = seed_legacy_install(home)auth_row = old_auth_row(home / "auth" / "auth.db")+ studio_rows = legacy_studio_rows(home / "studio.db")application = importlib.import_module("main")for name, payload in original.items():assert (home / name).read_bytes() == payload, f"Import changed {name}"@@ -66,10 +68,15 @@ def main() -> None:assert login.json()["access_token"]finally:client.close()+ # auth.db and studio.db gain columns when a current build opens them, so both are compared by what+ # the old build wrote rather than byte for byte. Everything else must be untouched.for name, payload in original.items():- if name != "auth/auth.db":+ if name not in ("auth/auth.db", "studio.db"):assert (home / name).read_bytes() == payload, f"Owner read changed {name}"assert old_auth_row(home / "auth" / "auth.db") == auth_row+ assert (+ legacy_studio_rows(home / "studio.db") == studio_rows+ ), "Owner read changed legacy studio.db rows"assert not (home / "accounts").exists()print(json.dumps({"preserved_files": len(original), "owner_login": True}))diff --git a/studio/backend/tests/multi_account/seed.py b/studio/backend/tests/multi_account/seed.pyindex dffd51b714c..252b956440c 100644--- a/studio/backend/tests/multi_account/seed.py+++ b/studio/backend/tests/multi_account/seed.py@@ -129,6 +129,43 @@ def seed_legacy_install(home: Path) -> dict[str, bytes]:}+def legacy_studio_columns() -> dict[str, tuple[str, ...]]:+ """Every table in the frozen studio.db schema, with the columns it had then."""+ with closing(sqlite3.connect(":memory:")) as conn:+ conn.executescript(+ Path(__file__).with_name("legacy_studio_schema.sql").read_text(encoding = "utf-8")+ )+ tables = [+ row[0]+ for row in conn.execute(+ "SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%' "+ "ORDER BY name"+ )+ ]+ return {+ table: tuple(row[1] for row in conn.execute(f'PRAGMA table_info("{table}")'))+ for table in tables+ }+++def legacy_studio_rows(path: Path) -> dict[str, list[tuple]]:+ """Every row of every legacy table, read through its legacy columns only.++ A current build adds columns to studio.db as it opens it (`ALTER TABLE ... ADD COLUMN`), which+ changes the file's bytes but not a byte of what the old build wrote. This is the part an upgrade+ has to preserve, and the part an old build reading its own named columns would see. A dropped or+ renamed legacy column raises here rather than comparing equal.+ """+ rows = {}+ with closing(sqlite3.connect(f"file:{path}?mode=ro", uri = True)) as conn:+ for table, columns in legacy_studio_columns().items():+ quoted = ", ".join(f'"{column}"' for column in columns)+ rows[table] = sorted(+ conn.execute(f'SELECT {quoted} FROM "{table}"').fetchall(), key = repr+ )+ return rows++def old_auth_row(path: Path) -> tuple:with closing(sqlite3.connect(path)) as conn:return conn.execute(