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
Run unsloth_cli/tests in Backend CI (#7598)
Daniel Han0ed26297ed81
diff --git a/.github/workflows/studio-backend-ci.yml b/.github/workflows/studio-backend-ci.ymlindex ec437e0c328..ae91e99b70a 100644--- a/.github/workflows/studio-backend-ci.yml+++ b/.github/workflows/studio-backend-ci.yml@@ -223,6 +223,18 @@ jobs:tests/studio/test_is_mlx_dispatch_gate.py \tests/studio/test_xpu_spoof_pipeline.py+ - name: CLI tests (unsloth_cli)+ # unsloth_cli/tests had no CI at all: `unsloth_cli/**` was only a paths+ # trigger and a ruff target, so 673 tests covering the studio launcher,+ # the pre-exposure gate and the auth secret writers ran nowhere, and+ # four of them had been failing on main unnoticed.+ # Own step, not folded into the tests/ discovery above: pyproject's+ # testpaths is tests/, and this suite needs no PYTHONPATH or CUDA spoof+ # (it self-bootstraps sys.path and imports neither unsloth nor torch).+ # Run the whole directory in one invocation; some files in it are+ # order-dependent and only pass in a full-directory run.+ run: python -m pytest unsloth_cli/tests -q --tb=short+- name: Shell installer tests# Auto-discovered rather than allowlisted. The old hardcoded list had# silently fallen seven files behind tests/run_all.sh, includingdiff --git a/unsloth_cli/tests/test_studio_password_prompt.py b/unsloth_cli/tests/test_studio_password_prompt.pyindex f45b228c84a..48437b06558 100644--- a/unsloth_cli/tests/test_studio_password_prompt.py+++ b/unsloth_cli/tests/test_studio_password_prompt.py@@ -626,6 +626,12 @@ def test_studio_default_in_venv_broken_backend_exits_before_stripping_bootstrap(# Pretend we are already inside the studio venv, with a broken backend.monkeypatch.setattr(sys, "prefix", str(tmp_path / "unsloth_studio"))+ # A built dist is not present in a fresh clone. The missing-frontend gate+ # runs first and has its own test below; stub it so this one reaches the+ # backend check it is actually about.+ monkeypatch.setattr(+ studio_mod, "_find_frontend_dist", lambda: Path("/fake/studio/frontend/dist")+ )def _boom():raise ImportError("cannot import backend run.py")diff --git a/unsloth_cli/tests/test_studio_run_parallel_flag.py b/unsloth_cli/tests/test_studio_run_parallel_flag.pyindex f1a4e69b81c..813a251caa0 100644--- a/unsloth_cli/tests/test_studio_run_parallel_flag.py+++ b/unsloth_cli/tests/test_studio_run_parallel_flag.py@@ -606,8 +606,8 @@ def test_studio_default_exposes_parallel_option():assert "--parallel" in declsassert "--n-parallel" in declsassert (- getattr(opt, "default", None) == 1- ), "studio_default --parallel must default to 1 (pre-PR); `run` is 4"+ getattr(opt, "default", None) == studio_mod._PARALLEL_DEFAULT_PLAIN+ ), "studio_default --parallel must use _PARALLEL_DEFAULT_PLAIN"assert getattr(opt, "min", None) == 1assert getattr(opt, "max", None) == 64@@ -679,7 +679,6 @@ def test_api_only_option_is_registered():"extra,present",[(["--api-only"], True),- (["--secure", "--api-only"], True), # secure headless path([], False),],)@@ -691,6 +690,21 @@ def test_reexec_forwards_api_only(monkeypatch, extra, present):assert ("--api-only" in argv) is present, argv+def test_secure_api_only_is_refused_before_any_reexec(monkeypatch, tmp_path):+ """`--secure --api-only` used to re-exec; the pre-exposure gate now refuses+ it, because api-only has no login page and the bootstrap deadline does not+ apply, so the seeded password could never be changed."""+ studio_mod = _load_run_command()+ monkeypatch.setattr(studio_mod, "STUDIO_HOME", tmp_path)++ result, captured = _invoke_run(monkeypatch, _BASE + ["--secure", "--api-only"])++ assert captured == [], captured+ assert result.exit_code != 0+ combined = (result.output or "") + (getattr(result, "stderr", "") or "")+ assert "default admin password was never changed" in combined.lower()++@pytest.mark.parametrize("extra,expected", [(["--api-only"], True), ([], False)])def test_in_venv_path_passes_api_only_to_run_server(monkeypatch, extra, expected):"""In-venv path must forward --api-only to run_server(api_only=...)."""diff --git a/unsloth_cli/tests/test_studio_secure_flag.py b/unsloth_cli/tests/test_studio_secure_flag.pyindex 2a67aad95a0..5e60d1c40c6 100644--- a/unsloth_cli/tests/test_studio_secure_flag.py+++ b/unsloth_cli/tests/test_studio_secure_flag.py@@ -261,6 +261,11 @@ def test_run_in_venv_passes_secure_and_forces_host(monkeypatch, tmp_path):fake_venv = tmp_path / "unsloth_studio"monkeypatch.setattr(sys, "prefix", str(fake_venv))+ # A built dist is not present in a fresh clone, and without it the public+ # launch gate exits before run_server is ever reached.+ monkeypatch.setattr(+ studio_mod, "_find_frontend_dist", lambda: Path("/fake/studio/frontend/dist")+ )from unsloth_cli import _tool_policy as _tp_mod