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.

Repair two more backend checks red on main (#15003)

Daniel Han0114fac15b20
diff --git a/studio/backend/tests/test_diffusion_zimage_cfg_split.py b/studio/backend/tests/test_diffusion_zimage_cfg_split.py
index 7b04220fb89..558e4bd4f3c 100644
--- a/studio/backend/tests/test_diffusion_zimage_cfg_split.py
+++ b/studio/backend/tests/test_diffusion_zimage_cfg_split.py
@@ -365,7 +365,7 @@ def test_studio_load_arms_the_split_compiled_only():
import ast
import pathlib
- source = pathlib.Path(zs.__file__).with_name("diffusion.py").read_text()
+ source = pathlib.Path(zs.__file__).with_name("diffusion.py").read_text(encoding = "utf-8")
calls = [
node
for node in ast.walk(ast.parse(source))
diff --git a/studio/backend/tests/test_inference_dispatcher_resilience.py b/studio/backend/tests/test_inference_dispatcher_resilience.py
index 3e67eb803b6..097254c3c3c 100644
--- a/studio/backend/tests/test_inference_dispatcher_resilience.py
+++ b/studio/backend/tests/test_inference_dispatcher_resilience.py
@@ -93,32 +93,59 @@ def test_dispatcher_survives_mailbox_put_error():
assert not t.is_alive()
-def test_route_llama_streaming_async_clients_disable_proxy_env():
- """Local llama-server streaming proxies must ignore ambient HTTP_PROXY."""
- source = (Path(__file__).resolve().parent.parent / "routes" / "inference.py").read_text(
- encoding = "utf-8"
- )
- tree = ast.parse(source)
- calls = []
- for node in ast.walk(tree):
- if not isinstance(node, ast.Call):
- continue
- func = node.func
- if not (
- isinstance(func, ast.Attribute)
- and func.attr == "AsyncClient"
+def _is_local_async_client(func) -> bool:
+ # gated_async_client (#14546) wraps httpx.AsyncClient so archive embedding pauses for the request.
+ if isinstance(func, ast.Attribute):
+ return (
+ func.attr == "AsyncClient"
and isinstance(func.value, ast.Name)
and func.value.id == "httpx"
- ):
- continue
- calls.append(node)
+ )
+ return isinstance(func, ast.Name) and func.id == "gated_async_client"
+
+
+def test_route_llama_streaming_async_clients_disable_proxy_env():
+ """Local llama-server streaming proxies must ignore ambient HTTP_PROXY."""
+ backend = Path(__file__).resolve().parent.parent
+ source = (backend / "routes" / "inference.py").read_text(encoding = "utf-8")
+ calls = [
+ node
+ for node in ast.walk(ast.parse(source))
+ if isinstance(node, ast.Call) and _is_local_async_client(node.func)
+ ]
assert len(calls) == 5
for call in calls:
assert any(
kw.arg == "trust_env" and isinstance(kw.value, ast.Constant) and kw.value.value is False
for kw in call.keywords
- ), f"httpx.AsyncClient at line {call.lineno} must set trust_env=False"
+ ), f"the local AsyncClient at line {call.lineno} must set trust_env=False"
+
+ # The wrapper must hand trust_env (all its kwargs) to the httpx client it builds.
+ gate = ast.parse(
+ (backend / "core" / "inference" / "inference_gate.py").read_text(encoding = "utf-8")
+ )
+ wrapper = next(
+ n
+ for n in ast.walk(gate)
+ if isinstance(n, ast.FunctionDef) and n.name == "gated_async_client"
+ )
+ built = [
+ n
+ for n in ast.walk(wrapper)
+ if isinstance(n, ast.Call)
+ and _is_local_async_client(n.func)
+ and not isinstance(n.func, ast.Name)
+ ]
+ assert built and all(
+ any(
+ kw.arg is None
+ and isinstance(kw.value, ast.Name)
+ and kw.value.id == wrapper.args.kwarg.arg
+ for kw in n.keywords
+ )
+ for n in built
+ ), "gated_async_client must forward **kwargs to httpx.AsyncClient"
def _direct_reader_host():