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.

Stop two backend tests from asking the host what the answer is (#8022)

Daniel Han7222cdb045f2
diff --git a/studio/backend/tests/test_hf_xet_fallback.py b/studio/backend/tests/test_hf_xet_fallback.py
index d432bf63299..8455faaf8a2 100644
--- a/studio/backend/tests/test_hf_xet_fallback.py
+++ b/studio/backend/tests/test_hf_xet_fallback.py
@@ -478,6 +478,9 @@ def test_a_worker_spawned_during_the_gpu_init_retry_does_not_inherit_the_overrid
sys.meta_path.insert(0, finder)
try:
shim = importlib.import_module("utils.hf_xet_fallback")
+ # There is only a retry to spawn into on a host with no accelerator (see _gpu_present),
+ # so pin that rather than letting the runner's hardware decide the assertion.
+ monkeypatch.setattr(shim, "_gpu_present", lambda: False)
shim.DownloadStallError # drives the load: plain attempt, then the retry
assert len(child_envs) == 2, child_envs
# The retry is the attempt that sets it; neither child may see it.
diff --git a/studio/backend/tests/test_text_io_encoding.py b/studio/backend/tests/test_text_io_encoding.py
index 7eae3c7fefc..04f233d5e9a 100644
--- a/studio/backend/tests/test_text_io_encoding.py
+++ b/studio/backend/tests/test_text_io_encoding.py
@@ -601,6 +601,10 @@ def test_a_corrupt_pid_file_does_not_abort_shutdown(tmp_path: Path, monkeypatch)
pid_file = tmp_path / "studio.pid"
pid_file.write_bytes(b"\x80\xff")
monkeypatch.setattr(studio_run, "_PID_FILE", pid_file)
+ # _legacy_heir scans the real Studio root, so without this the last assertion asks whether
+ # a server happens to be running on the machine: with one, the record is handed over rather
+ # than unlinked. The handoff has its own test below.
+ monkeypatch.setattr(studio_run, "_legacy_heir", lambda: None)
studio_run._remove_pid_file()
# Not this process's PID, so the file stays; the point is that it returned.
assert pid_file.exists()
@@ -610,6 +614,26 @@ def test_a_corrupt_pid_file_does_not_abort_shutdown(tmp_path: Path, monkeypatch)
assert not pid_file.exists()
+def test_the_legacy_pid_record_is_handed_to_a_live_sibling(tmp_path: Path, monkeypatch) -> None:
+ """Only one server owns studio.pid, so deleting it while a sibling still serves would leave
+ that sibling unstoppable from an older CLI that reads no other file."""
+ import sys
+
+ backend = str(Path(__file__).resolve().parent.parent)
+ if backend not in sys.path:
+ sys.path.insert(0, backend)
+ import run as studio_run
+
+ pid_file = tmp_path / "studio.pid"
+ pid_file.write_text(str(os.getpid()), encoding = "utf-8")
+ monkeypatch.setattr(studio_run, "_PID_FILE", pid_file)
+ monkeypatch.setattr(studio_run, "_legacy_heir", lambda: 4242)
+
+ studio_run._remove_pid_file()
+
+ assert pid_file.read_text(encoding = "utf-8") == "4242"
+
+
def test_the_kwargs_guard_only_judges_dicts_that_reach_a_call(tmp_path: Path) -> None:
"""Only a dict splatted into a call is subprocess configuration. An unrelated
payload that happens to carry "text": True is not, and neither is one whose