Description
Component
OpenLIT Python SDK
What happened?
openlit.get_eval_types() raises ConnectionError for a connection timeout and TimeoutError for a read timeout. An application catching TimeoutError to retry an evaluation-type lookup therefore misses one kind of timeout.
Steps to reproduce
Run this with the SDK installed. The HTTP call is mocked and no server or credentials are required.
from unittest.mock import patch
import openlit
from requests.exceptions import ConnectTimeout, ReadTimeout
for exception in (ConnectTimeout, ReadTimeout):
with patch("openlit.evals.offline.requests.get", side_effect=exception("timeout")):
try:
openlit.get_eval_types(openlit_api_key="test", openlit_url="http://localhost")
except (ConnectionError, TimeoutError) as error:
print(exception.__name__, type(error).__name__)Current output: ConnectTimeout ConnectionError and ReadTimeout TimeoutError.
Expected behavior
Both timeouts raise TimeoutError. A non-timeout connection failure, such as connection refusal, still raises ConnectionError.
Environment
OpenLIT Python SDK 1.45.0, main 463a1c1b3cd72a94fab4155efe0f28d90d87fe95, Python 3.12.11 on Windows.
Additional context
Codex assisted with investigation and drafting. The output above was reproduced locally.
Pre-submission checklist
- I searched existing issues and didn't find a duplicate
Are you willing to submit PR?
Yes, I am willing to submit a PR!
Activity