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
Studio: run sandbox matplotlib headless (#7789)
Nilay991c6ad9d964
diff --git a/studio/backend/core/inference/tools.py b/studio/backend/core/inference/tools.pyindex 78716c99876..aaa840eaae0 100644--- a/studio/backend/core/inference/tools.py+++ b/studio/backend/core/inference/tools.py@@ -6575,6 +6575,8 @@ def _build_safe_env(workdir: str) -> dict[str, str]:"LANG": os.environ.get("LANG", "C.UTF-8"),"TERM": "dumb","PYTHONIOENCODING": "utf-8",+ # A GUI backend opens a native window and blocks plt.show() until closed.+ "MPLBACKEND": "Agg",# sitecustomize shim: remaps ChatGPT code-interpreter paths (/mnt/data# etc.) onto the sandbox CWD; see sandbox_site/sitecustomize.py."PYTHONPATH": _SANDBOX_SITE_DIR,@@ -6779,6 +6781,7 @@ def _build_bypass_env(workdir: str) -> dict[str, str]:for var in _BYPASS_ENV_WINDOWS_PROFILE_VARS:if var in os.environ:env[var] = workdir+ env.setdefault("MPLBACKEND", "Agg")return envdiff --git a/studio/backend/tests/test_sandbox_tools.py b/studio/backend/tests/test_sandbox_tools.pyindex 98ac9658e91..40c77f53ae0 100644--- a/studio/backend/tests/test_sandbox_tools.py+++ b/studio/backend/tests/test_sandbox_tools.py@@ -294,6 +294,7 @@ class TestSandboxEnvIsolation:"LANG","TERM","PYTHONIOENCODING",+ "MPLBACKEND","PYTHONPATH","VIRTUAL_ENV","SystemRoot",@@ -302,6 +303,7 @@ class TestSandboxEnvIsolation:}extras = set(env.keys()) - allowedassert not extras, f"sandbox env added unexpected keys: {extras}"+ assert env["MPLBACKEND"] == "Agg"# PYTHONPATH is whitelist-built, never inherited: only the sandbox# sitecustomize shim dir (code-interpreter path remap).assert env["PYTHONPATH"].endswith("sandbox_site")