Open-source inference server and production cluster for all the models your agent needs.
Python bgecolbertdata-pipelinedeep-learningembeddingsinferenceinference-serverinformation-retrievalllmmlmlopsnatural-language-processingnlppythonrerankingretrievalretrieval-augmented-generationsemantic-searchspladevector-search
fix(benchmarks): preserve shutdown after process inspection errors
svonavac3017d583c74
diff --git a/tools/benchmarks/model_recovery/probe.py b/tools/benchmarks/model_recovery/probe.pyindex d4cba9ecf..2376f9e44 100644--- a/tools/benchmarks/model_recovery/probe.py+++ b/tools/benchmarks/model_recovery/probe.py@@ -82,7 +82,7 @@ class RequestProbe:self.request_started = startederror = Nonetry:- kwargs = {+ kwargs: dict[str, Any] = {"temperature": 0.0,"wait_for_capacity": warm,"max_oom_retries": 0,@@ -350,12 +350,24 @@ async def run(args: argparse.Namespace, evidence: Evidence) -> bool:await asyncio.gather(recovery_task, return_exceptions=True)for client in clients:client.close()- for child in psutil.Process(os.getpid()).children(recursive=True):+ inspection_errors: list[dict[str, Any]] = []+ try:+ children = psutil.Process(os.getpid()).children(recursive=True)+ except psutil.Error as exc:+ children = []+ inspection_errors.append({"stage": "enumerate", "error_type": type(exc).__name__})+ for child in children:try:child_identities.add((child.pid, child.create_time()))except psutil.NoSuchProcess:pass- evidence.emit("before_shutdown", tracked_child_pids=sorted(pid for pid, _ in child_identities))+ except psutil.Error as exc:+ inspection_errors.append({"stage": "identity", "pid": child.pid, "error_type": type(exc).__name__})+ evidence.emit(+ "before_shutdown",+ tracked_child_pids=sorted(pid for pid, _ in child_identities),+ inspection_errors=inspection_errors,+ )server.should_exit = Truetry:await asyncio.wait_for(asyncio.shield(serve_task), timeout=90)@@ -367,7 +379,7 @@ async def run(args: argparse.Namespace, evidence: Evidence) -> bool:alive.append(pid)except psutil.NoSuchProcess:pass- cleanup_ok = not alive and (registry is None or not registry.loaded_model_names)+ cleanup_ok = not inspection_errors and not alive and (registry is None or not registry.loaded_model_names)evidence.emit("cleanup",okay=cleanup_ok,diff --git a/tools/benchmarks/model_recovery/tests/test_probe.py b/tools/benchmarks/model_recovery/tests/test_probe.pynew file mode 100644index 000000000..a1bef808e--- /dev/null+++ b/tools/benchmarks/model_recovery/tests/test_probe.py@@ -0,0 +1,68 @@+"""Failure-path checks for recovery evidence and owned server shutdown."""++import argparse+import asyncio+import json+from pathlib import Path+from types import SimpleNamespace++import psutil+import pytest++from tools.benchmarks.model_recovery import probe++[email protected]("failure_stage", ["enumerate", "identity"])+async def test_process_inspection_failure_does_not_skip_shutdown_or_summary(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch, failure_stage: str+) -> None:+ monkeypatch.setattr(probe.os, "environ", probe.os.environ.copy())+ registry = SimpleNamespace(_loaded={}, loaded_model_names=[])+ app = SimpleNamespace(state=SimpleNamespace(registry=registry))+ monkeypatch.setattr(probe.AppFactory, "create_app", lambda _config: app)+ monkeypatch.setattr(probe, "snapshot", lambda _registry: {"models": {}})++ class Server:+ started = True+ should_exit = False+ shutdown_complete = False++ async def serve(self, **_kwargs: object) -> None:+ await asyncio.sleep(0)+ assert self.should_exit+ self.shutdown_complete = True++ server = Server()+ monkeypatch.setattr(probe.uvicorn, "Server", lambda _config: server)++ class Child:+ pid = 12345++ def create_time(self) -> float:+ raise psutil.AccessDenied(self.pid)++ class Parent:+ def children(self, **_kwargs: object) -> list[Child]:+ if failure_stage == "enumerate":+ raise psutil.AccessDenied+ return [Child()]++ monkeypatch.setattr(probe.psutil, "Process", lambda _pid: Parent())+ args = argparse.Namespace(smoke=True, deadline_s=10, output=tmp_path / "evidence")+ evidence = probe.Evidence(args.output)++ # The empty registry forces an ordinary protocol failure before warmup.+ # Process inspection must not replace that failure or bypass teardown.+ assert await probe.run(args, evidence) is False+ assert server.should_exit+ assert server.shutdown_complete+ assert any(row["event"] == "protocol_failed" for row in evidence.rows)+ inspection = next(row for row in evidence.rows if row["event"] == "before_shutdown")+ assert inspection["inspection_errors"][0]["stage"] == failure_stage+ assert inspection["inspection_errors"][0]["error_type"] == "AccessDenied"+ cleanup = next(row for row in evidence.rows if row["event"] == "cleanup")+ assert cleanup["okay"] is False+ summary = json.loads((args.output / "summary.json").read_text())+ assert summary["passed"] is False+ assert summary["cleanup_ok"] is False