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
Lint CI: scan committed files, not the tree the background lanes write into (#13728)
Daniel Han8e5b7096975a
diff --git a/.github/workflows/lint-ci.yml b/.github/workflows/lint-ci.ymlindex 061457a6b36..81d71f44c65 100644--- a/.github/workflows/lint-ci.yml+++ b/.github/workflows/lint-ci.yml@@ -258,6 +258,14 @@ jobs:# unsloth/models/rl* today). Sub-second.run: |python <<'PY'+ import os, pathlib, subprocess+ def tracked(*patterns):+ # Committed files only. A background lane builds a venv under .lanes/ while+ # these steps run, and a file pip removes mid-walk crashed an rglob scan.+ # fsdecode, as rglob did: a tracked path need not be valid UTF-8.+ out = subprocess.run(["git", "ls-files", "-z", "--", *patterns],+ capture_output=True, check=True).stdout+ return sorted(pathlib.Path(p) for p in os.fsdecode(out).split("\0") if p)import ast, pathlib, sysSKIP_PARTS = {".venv", "venv", "build", "dist", ".git",@@ -266,7 +274,7 @@ jobs:bad = []scanned = 0- for path in sorted(pathlib.Path(".").rglob("*.py")):+ for path in tracked("*.py"):if any(part in SKIP_PARTS for part in path.parts):continuescanned += 1@@ -312,6 +320,14 @@ jobs:continue-on-error: truerun: |python <<'PY'+ import os, pathlib, subprocess+ def tracked(*patterns):+ # Committed files only. A background lane builds a venv under .lanes/ while+ # these steps run, and a file pip removes mid-walk crashed an rglob scan.+ # fsdecode, as rglob did: a tracked path need not be valid UTF-8.+ out = subprocess.run(["git", "ls-files", "-z", "--", *patterns],+ capture_output=True, check=True).stdout+ return sorted(pathlib.Path(p) for p in os.fsdecode(out).split("\0") if p)import pathlibACCEPTED = (@@ -326,7 +342,7 @@ jobs:studio_missing = []other_missing = []- for path in sorted(pathlib.Path(".").rglob("*.py")):+ for path in tracked("*.py"):if any(part in SKIP_PARTS for part in path.parts):continuetext = path.read_text(encoding="utf-8", errors="replace")@@ -380,6 +396,14 @@ jobs:# added shows up immediately.run: |python <<'PY'+ import os, pathlib, subprocess+ def tracked(*patterns):+ # Committed files only. A background lane builds a venv under .lanes/ while+ # these steps run, and a file pip removes mid-walk crashed an rglob scan.+ # fsdecode, as rglob did: a tracked path need not be valid UTF-8.+ out = subprocess.run(["git", "ls-files", "-z", "--", *patterns],+ capture_output=True, check=True).stdout+ return sorted(pathlib.Path(p) for p in os.fsdecode(out).split("\0") if p)import pathlib, sys, yamlSKIP_PARTS = {".venv", "venv", "build", "dist", ".git",@@ -388,8 +412,7 @@ jobs:bad = []scanned = 0- for path in sorted(list(pathlib.Path(".").rglob("*.yml"))- + list(pathlib.Path(".").rglob("*.yaml"))):+ for path in tracked("*.yml", "*.yaml"):if any(part in SKIP_PARTS for part in path.parts):continuescanned += 1@@ -417,6 +440,14 @@ jobs:# `tsc --noEmit` already validates these in Frontend CI.run: |python <<'PY'+ import os, pathlib, subprocess+ def tracked(*patterns):+ # Committed files only. A background lane builds a venv under .lanes/ while+ # these steps run, and a file pip removes mid-walk crashed an rglob scan.+ # fsdecode, as rglob did: a tracked path need not be valid UTF-8.+ out = subprocess.run(["git", "ls-files", "-z", "--", *patterns],+ capture_output=True, check=True).stdout+ return sorted(pathlib.Path(p) for p in os.fsdecode(out).split("\0") if p)import fnmatch, json, pathlib, sysSKIP_PARTS = {".venv", "venv", "build", "dist", ".git",@@ -427,7 +458,7 @@ jobs:bad = []scanned = 0- for path in sorted(pathlib.Path(".").rglob("*.json")):+ for path in tracked("*.json"):if any(part in SKIP_PARTS for part in path.parts):continueif path.name in SKIP_NAMES:diff --git a/.github/workflows/workflow-trigger-lint.yml b/.github/workflows/workflow-trigger-lint.ymlindex 64a69abcf61..9bd4f52685a 100644--- a/.github/workflows/workflow-trigger-lint.yml+++ b/.github/workflows/workflow-trigger-lint.yml@@ -129,6 +129,7 @@ jobs:run: |python3 -m pytest -q -n 4 \tests/studio/test_absorbed_lanes_still_run.py \+ tests/studio/test_lint_ci_scans_committed_files.py \tests/studio/test_agent_guides_verdicts.py \tests/studio/test_apt_steps_are_bounded.py \tests/studio/test_backend_ci_matrix.py \diff --git a/tests/studio/test_lint_ci_scans_committed_files.py b/tests/studio/test_lint_ci_scans_committed_files.pynew file mode 100644index 00000000000..ae29f5acbda--- /dev/null+++ b/tests/studio/test_lint_ci_scans_committed_files.py@@ -0,0 +1,52 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""Lint CI's file scans read the committed tree, not the working directory.++The Lint CI job runs its checks as one parallel group next to background lanes, and the+load-orchestrator lane builds a venv under ``.lanes/`` while they run. The debugger check+walked ``pathlib.Path(".").rglob("*.py")``, listed a file pip was about to remove+(``.lanes/venv-load-orchestrator/.../~ip/__init__.py``), and crashed on ``read_text`` with+FileNotFoundError, failing PR #13700's lint for a file nobody committed. The YAML and JSON+parse checks walk the same way and would report such a file as unparseable instead.+"""++import re+from pathlib import Path++WORKFLOW = Path(__file__).resolve().parents[2] / ".github" / "workflows" / "lint-ci.yml"+TEXT = WORKFLOW.read_text(encoding = "utf-8")+BLOCKS = [+ m.group("body") for m in re.finditer(r"python <<'PY'\n(?P<body>.*?)\n[ \t]*PY\n", TEXT, re.S)+]+++def test_no_lint_step_walks_the_working_tree():+ walkers = [+ block.splitlines()[0].strip()+ for block in BLOCKS+ if re.search(r"\.rglob\(|os\.walk\(", block)+ ]+ assert not walkers, (+ "a Lint CI step walks the working tree, which the background lanes write into while it "+ f"runs; list committed files with git ls-files instead: {walkers}"+ )+++def test_the_file_scans_list_committed_files():+ scans = {+ "debugger": "no leftover debugger calls",+ "yaml": "YAML files parse cleanly",+ "json": "JSON files parse cleanly",+ }+ for name, marker in scans.items():+ block = next((b for b in BLOCKS if marker in b), None)+ assert block is not None, f"the {name} scan is gone or reworded; update this guard"+ assert (+ '"git", "ls-files"' in block and "tracked(" in block+ ), f"the {name} scan does not read git ls-files"+ # git prints raw path bytes, and a tracked name need not be UTF-8: a strict .decode()+ # would abort the scan where rglob (surrogateescape) did not.+ assert (+ "os.fsdecode(out)" in block and "out.decode()" not in block+ ), f"the {name} scan decodes git's paths strictly"