uptrain
uptrain copied to clipboard
Getting TLSV1_ALERT_INTERNAL_ERROR when attempting to hit demo.uptrain.ai
Describe the bug
When running the following code, I got a TLS error. At one point, this code did run. I had to update Uptrain and some other libraries to account for a newer version Pydantic in our system.
from uptrain import APIClient
eval_client = APIClient(uptrain_api_key=UPTRAIN_API_KEY)
eval_client.log_and_evaluate(
project_name='VertexAI-QnA-Bot-Evals',
data=results,
checks=[Evals.CONTEXT_RELEVANCE, Evals.FACTUAL_ACCURACY]
);
Here is the complete traceback:
2024-08-05 10:05:11.485 | INFO | uptrain.framework.remote:log_and_evaluate:677 - Sending evaluation request for rows 0 to <50 to the Uptrain server
2024-08-05 10:05:11.611 | INFO | uptrain.framework.remote:log_and_evaluate:697 - Retrying evaluation request
2024-08-05 10:05:11.612 | INFO | uptrain.framework.remote:log_and_evaluate:677 - Sending evaluation request for rows 0 to <50 to the Uptrain server
2024-08-05 10:05:11.726 | INFO | uptrain.framework.remote:log_and_evaluate:697 - Retrying evaluation request
2024-08-05 10:05:11.727 | INFO | uptrain.framework.remote:log_and_evaluate:677 - Sending evaluation request for rows 0 to <50 to the Uptrain server
2024-08-05 10:05:11.838 | INFO | uptrain.framework.remote:log_and_evaluate:697 - Retrying evaluation request
2024-08-05 10:05:11.839 | ERROR | uptrain.framework.remote:log_and_evaluate:699 - Evaluation failed with error: [SSL: TLSV1_ALERT_INTERNAL_ERROR] tlsv1 alert internal error (_ssl.c:1006)
---------------------------------------------------------------------------
ConnectError Traceback (most recent call last)
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_transports/default.py:69](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_transports/default.py#line=68), in map_httpcore_exceptions()
68 try:
---> 69 yield
70 except Exception as exc:
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_transports/default.py:233](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_transports/default.py#line=232), in HTTPTransport.handle_request(self, request)
232 with map_httpcore_exceptions():
--> 233 resp = self._pool.handle_request(req)
235 assert isinstance(resp.stream, typing.Iterable)
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py:216](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py#line=215), in ConnectionPool.handle_request(self, request)
215 self._close_connections(closing)
--> 216 raise exc from None
218 # Return the response. Note that in this case we still have to manage
219 # the point at which the response is closed.
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py:196](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py#line=195), in ConnectionPool.handle_request(self, request)
194 try:
195 # Send the request on the assigned connection.
--> 196 response = connection.handle_request(
197 pool_request.request
198 )
199 except ConnectionNotAvailable:
200 # In some cases a connection may initially be available to
201 # handle a request, but then become unavailable.
202 #
203 # In this case we clear the connection and try again.
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_sync/connection.py:99](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_sync/connection.py#line=98), in HTTPConnection.handle_request(self, request)
98 self._connect_failed = True
---> 99 raise exc
101 return self._connection.handle_request(request)
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_sync/connection.py:76](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_sync/connection.py#line=75), in HTTPConnection.handle_request(self, request)
75 if self._connection is None:
---> 76 stream = self._connect(request)
78 ssl_object = stream.get_extra_info("ssl_object")
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_sync/connection.py:154](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_sync/connection.py#line=153), in HTTPConnection._connect(self, request)
153 with Trace("start_tls", logger, request, kwargs) as trace:
--> 154 stream = stream.start_tls(**kwargs)
155 trace.return_value = stream
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_backends/sync.py:152](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_backends/sync.py#line=151), in SyncStream.start_tls(self, ssl_context, server_hostname, timeout)
148 exc_map: ExceptionMapping = {
149 socket.timeout: ConnectTimeout,
150 OSError: ConnectError,
151 }
--> 152 with map_exceptions(exc_map):
153 try:
File [~/.pyenv/versions/3.11.6/lib/python3.11/contextlib.py:155](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/contextlib.py#line=154), in _GeneratorContextManager.__exit__(self, typ, value, traceback)
154 try:
--> 155 self.gen.throw(typ, value, traceback)
156 except StopIteration as exc:
157 # Suppress StopIteration *unless* it's the same exception that
158 # was passed to throw(). This prevents a StopIteration
159 # raised inside the "with" statement from being suppressed.
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_exceptions.py:14](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_exceptions.py#line=13), in map_exceptions(map)
13 if isinstance(exc, from_exc):
---> 14 raise to_exc(exc) from exc
15 raise
ConnectError: [SSL: TLSV1_ALERT_INTERNAL_ERROR] tlsv1 alert internal error (_ssl.c:1006)
The above exception was the direct cause of the following exception:
ConnectError Traceback (most recent call last)
Cell In[19], line 5
1 from uptrain import APIClient
3 eval_client = APIClient(uptrain_api_key=UPTRAIN_API_KEY)
----> 5 eval_client.log_and_evaluate(
6 project_name='VertexAI-QnA-Bot-Evals',
7 data=results,
8 checks=[Evals.CONTEXT_RELEVANCE, Evals.FACTUAL_ACCURACY]
9 );
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/uptrain/framework/remote.py:700](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/uptrain/framework/remote.py#line=699), in APIClient.log_and_evaluate(self, project_name, data, checks, evaluation_name, scenario_description, schema, metadata)
698 if try_num == NUM_TRIES - 1:
699 logger.error(f"Evaluation failed with error: {e}")
--> 700 raise e
702 if response_json is not None:
703 results.extend(response_json)
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/uptrain/framework/remote.py:680](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/uptrain/framework/remote.py#line=679), in APIClient.log_and_evaluate(self, project_name, data, checks, evaluation_name, scenario_description, schema, metadata)
676 try:
677 logger.info(
678 f"Sending evaluation request for rows {i} to <{i+BATCH_SIZE} to the Uptrain server"
679 )
--> 680 response = self.client.post(
681 url,
682 json={
683 "data": data[i : i + BATCH_SIZE],
684 "checks": ser_checks,
685 "metadata": {
686 "project": project_name,
687 "evaluation": evaluation_name,
688 "schema": schema.model_dump(),
689 **metadata,
690 "uptrain_settings": self.settings.model_dump(),
691 },
692 },
693 )
694 response_json = raise_or_return(response)
695 break
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_client.py:1145](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_client.py#line=1144), in Client.post(self, url, content, data, files, json, params, headers, cookies, auth, follow_redirects, timeout, extensions)
1124 def post(
1125 self,
1126 url: URLTypes,
(...)
1138 extensions: RequestExtensions | None = None,
1139 ) -> Response:
1140 """
1141 Send a `POST` request.
1142
1143 **Parameters**: See `httpx.request`.
1144 """
-> 1145 return self.request(
1146 "POST",
1147 url,
1148 content=content,
1149 data=data,
1150 files=files,
1151 json=json,
1152 params=params,
1153 headers=headers,
1154 cookies=cookies,
1155 auth=auth,
1156 follow_redirects=follow_redirects,
1157 timeout=timeout,
1158 extensions=extensions,
1159 )
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_client.py:827](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_client.py#line=826), in Client.request(self, method, url, content, data, files, json, params, headers, cookies, auth, follow_redirects, timeout, extensions)
812 warnings.warn(message, DeprecationWarning)
814 request = self.build_request(
815 method=method,
816 url=url,
(...)
825 extensions=extensions,
826 )
--> 827 return self.send(request, auth=auth, follow_redirects=follow_redirects)
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_client.py:914](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_client.py#line=913), in Client.send(self, request, stream, auth, follow_redirects)
906 follow_redirects = (
907 self.follow_redirects
908 if isinstance(follow_redirects, UseClientDefault)
909 else follow_redirects
910 )
912 auth = self._build_request_auth(request, auth)
--> 914 response = self._send_handling_auth(
915 request,
916 auth=auth,
917 follow_redirects=follow_redirects,
918 history=[],
919 )
920 try:
921 if not stream:
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_client.py:942](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_client.py#line=941), in Client._send_handling_auth(self, request, auth, follow_redirects, history)
939 request = next(auth_flow)
941 while True:
--> 942 response = self._send_handling_redirects(
943 request,
944 follow_redirects=follow_redirects,
945 history=history,
946 )
947 try:
948 try:
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_client.py:979](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_client.py#line=978), in Client._send_handling_redirects(self, request, follow_redirects, history)
976 for hook in self._event_hooks["request"]:
977 hook(request)
--> 979 response = self._send_single_request(request)
980 try:
981 for hook in self._event_hooks["response"]:
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_client.py:1015](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_client.py#line=1014), in Client._send_single_request(self, request)
1010 raise RuntimeError(
1011 "Attempted to send an async request with a sync Client instance."
1012 )
1014 with request_context(request=request):
-> 1015 response = transport.handle_request(request)
1017 assert isinstance(response.stream, SyncByteStream)
1019 response.request = request
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_transports/default.py:232](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_transports/default.py#line=231), in HTTPTransport.handle_request(self, request)
218 assert isinstance(request.stream, SyncByteStream)
220 req = httpcore.Request(
221 method=request.method,
222 url=httpcore.URL(
(...)
230 extensions=request.extensions,
231 )
--> 232 with map_httpcore_exceptions():
233 resp = self._pool.handle_request(req)
235 assert isinstance(resp.stream, typing.Iterable)
File [~/.pyenv/versions/3.11.6/lib/python3.11/contextlib.py:155](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/contextlib.py#line=154), in _GeneratorContextManager.__exit__(self, typ, value, traceback)
153 value = typ()
154 try:
--> 155 self.gen.throw(typ, value, traceback)
156 except StopIteration as exc:
157 # Suppress StopIteration *unless* it's the same exception that
158 # was passed to throw(). This prevents a StopIteration
159 # raised inside the "with" statement from being suppressed.
160 return exc is not value
File [~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_transports/default.py:86](http://mate.local:8888/home/ksmith/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_transports/default.py#line=85), in map_httpcore_exceptions()
83 raise
85 message = str(exc)
---> 86 raise mapped_exc(message) from exc
ConnectError: [SSL: TLSV1_ALERT_INTERNAL_ERROR] tlsv1 alert internal error (_ssl.c:1006)