From 5cb5839cc69325959458489c822e58f3b5f82a6e Mon Sep 17 00:00:00 2001 From: MKuBMax Date: Sun, 19 Apr 2026 21:01:35 +0800 Subject: [PATCH] Bypass proxy for CLI health checks --- omlx/cli.py | 4 +++- tests/test_cli.py | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/omlx/cli.py b/omlx/cli.py index 2262d9ab6..3fef86ff8 100644 --- a/omlx/cli.py +++ b/omlx/cli.py @@ -276,7 +276,9 @@ def launch_command(args): # Check if oMLX server is running base_url = f"http://{host}:{port}" try: - resp = requests.get(f"{base_url}/health", timeout=3) + session = requests.Session() + session.trust_env = False + resp = session.get(f"{base_url}/health", timeout=3) resp.raise_for_status() except Exception: print(f"oMLX server is not running at {base_url}") diff --git a/tests/test_cli.py b/tests/test_cli.py index c1f689b1b..2890b8d72 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -271,10 +271,18 @@ def test_launch_command_passes_model_type_to_integration(self): tools_profile="coding", ) - with patch("requests.get", side_effect=[health_response, status_response]): - with patch("omlx.integrations.get_integration", return_value=integration): - with patch("omlx.settings.GlobalSettings.load", return_value=settings): - launch_command(args) + session = MagicMock() + session.get.return_value = health_response + + with patch("requests.Session", return_value=session) as session_ctor: + with patch("requests.get", return_value=status_response): + with patch("omlx.integrations.get_integration", return_value=integration): + with patch("omlx.settings.GlobalSettings.load", return_value=settings): + launch_command(args) + + session_ctor.assert_called_once() + assert session.trust_env is False + session.get.assert_called_once_with("http://127.0.0.1:8000/health", timeout=3) integration.launch.assert_called_once_with( port=8000,