MCPcopy Create free account
hub / github.com/algorithmicsuperintelligence/optillm / start_test_server

Function start_test_server

tests/test_utils.py:39–63  ·  view source on GitHub ↗

Start optillm server for testing Returns the process handle

(model: str = TEST_MODEL, port: int = 8000)

Source from the content-addressed store, hash-verified

37 return False
38
39def start_test_server(model: str = TEST_MODEL, port: int = 8000) -> subprocess.Popen:
40 """
41 Start optillm server for testing
42 Returns the process handle
43 """
44 # Set environment for local inference
45 env = os.environ.copy()
46 env["OPTILLM_API_KEY"] = "optillm"
47 # Enable MPS fallback to CPU for unsupported operations (fixes macOS compatibility)
48 env["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
49
50 # Get the project root directory (parent of tests directory)
51 project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
52
53 # Start server from project root where optillm.py is located
54 proc = subprocess.Popen([
55 sys.executable, "optillm.py",
56 "--model", model,
57 "--port", str(port)
58 ], env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=project_root)
59
60 # Wait for server to start
61 time.sleep(5)
62
63 return proc
64
65def stop_test_server(proc: subprocess.Popen):
66 """Stop the test server"""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected