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.

Fix the backend CI guards that main fails after the decision and ComfyUI merges (#12958)

Daniel Han08f87d0a39c1
diff --git a/studio/backend/tests/test_comfy_file_detection.py b/studio/backend/tests/test_comfy_file_detection.py
index ebeaaf0f089..618e2061e80 100644
--- a/studio/backend/tests/test_comfy_file_detection.py
+++ b/studio/backend/tests/test_comfy_file_detection.py
@@ -23,7 +23,9 @@ from core.inference import video_families as vf
from core.inference.family_name_match import normalize_family_name, token_in_name, token_length
_FIXTURE = json.loads(
- (Path(__file__).parent / "fixtures" / "comfy_checkpoint_headers.json").read_text()
+ (Path(__file__).parent / "fixtures" / "comfy_checkpoint_headers.json").read_text(
+ encoding = "utf-8"
+ )
)
_AUDIT = {k: v for k, v in _FIXTURE.items() if not k.startswith("diffusers/")}
_DIFFUSERS = {k: v for k, v in _FIXTURE.items() if k.startswith("diffusers/")}
diff --git a/studio/backend/tests/test_decision_native.py b/studio/backend/tests/test_decision_native.py
index a1a58d25bd1..cb7184df3a3 100644
--- a/studio/backend/tests/test_decision_native.py
+++ b/studio/backend/tests/test_decision_native.py
@@ -459,6 +459,30 @@ def test_the_key_is_passed_in_a_private_file_and_files_go_with_the_server(home,
assert not key_file.exists() and not log_file.exists() and not second._key_file.exists()
+def test_a_shutdown_that_begins_during_the_spawn_kills_the_new_server(
+ home, stub, tmp_path, monkeypatch
+):
+ """The latch can be set between the gate and the pid record; _wait_ready rereads it, so the server dies."""
+ from utils import process_lifetime
+ from utils.paths.storage_roots import auth_root
+
+ model = tmp_path / "m.gguf"
+ model.write_bytes(b"GGUF")
+ reads = iter([False, True])
+ monkeypatch.setattr(process_lifetime, "is_process_shutting_down", lambda: next(reads, True))
+ spawned = []
+ spawn = process_lifetime.spawn_on_lifetime_thread
+ monkeypatch.setattr(
+ process_lifetime,
+ "spawn_on_lifetime_thread",
+ lambda start: spawned.append(spawn(start)) or spawned[-1],
+ )
+ with pytest.raises(native_worker.NativeError, match = "stopped while it loaded"):
+ native_worker.NativeClefAgent(model, None, "clef-flash", gpu = False)
+ assert len(spawned) == 1 and spawned[0].poll() is not None
+ assert not list(auth_root().glob("decision_llama_api_key_*"))
+
+
def test_gpu_flags_offload_to_the_freest_device(home, stub, tmp_path):
model = tmp_path / "m.gguf"
model.write_bytes(b"GGUF")
diff --git a/studio/backend/tests/test_job_accounts.py b/studio/backend/tests/test_job_accounts.py
index 4601aed1769..a61fb5fbac6 100644
--- a/studio/backend/tests/test_job_accounts.py
+++ b/studio/backend/tests/test_job_accounts.py
@@ -257,6 +257,8 @@ def test_export_owner_single_mode_preserves_operation_and_status_bytes(export, m
"last_op_status": "success",
"last_op_output_path": None,
"last_op_error": None,
+ # Not a decision model checkpoint, so the decision export details stay null.
+ "decision": None,
}
assert result.model_dump_json() == json.dumps(expected, separators = (",", ":"))
exported = backend.export_lora_adapter("/arbitrary/export")
diff --git a/studio/backend/tests/test_orchestrator_unload_cancel.py b/studio/backend/tests/test_orchestrator_unload_cancel.py
index 93be3a26433..75f44e5fcf7 100644
--- a/studio/backend/tests/test_orchestrator_unload_cancel.py
+++ b/studio/backend/tests/test_orchestrator_unload_cancel.py
@@ -3882,6 +3882,7 @@ def test_every_long_lived_spawner_consults_the_shutdown_latch():
"core/inference/stt_mtmd_sidecar.py",
"core/inference/stt_transformers_worker.py",
"core/rag/embed_llama_server.py",
+ "core/systemone/native_worker.py",
"core/training/training.py",
}
# Adopters this change deliberately leaves ungated, listed so the completeness check
diff --git a/tests/test_decision_gguf_real.py b/tests/test_decision_gguf_real.py
index b5b52361167..787132fcbac 100644
--- a/tests/test_decision_gguf_real.py
+++ b/tests/test_decision_gguf_real.py
@@ -205,9 +205,9 @@ def _serve_and_compare(export_dir, data, reference, rows, label, tmp_path):
results["pytorch"] = {"nll": nll, "ece": ece}
if REPORT:
path = Path(REPORT)
- report = json.loads(path.read_text()) if path.is_file() else {}
+ report = json.loads(path.read_text(encoding = "utf-8")) if path.is_file() else {}
report[label] = results
- path.write_text(json.dumps(report, indent = 2))
+ path.write_text(json.dumps(report, indent = 2), encoding = "utf-8")
print(label, json.dumps(results, indent = 2))
return results