Hi,
I have created a class on a Weaviate cluster using:
client.schema.create(class_config)
I can see the class_config by:
print(client.show_class_config(class_name))
but when trying to see my available classes on my cluster using:
client.show_classes()
it says: βNo classes found on cluster.β. I am not sure why I cannot see it on my cluster. Would you please help me understand the root cause?
Hi @Saeed_Rezaei,
Welcome to our community
Do you see any error logs when creating the collection? Can you share the code of class_config
?
Also, any specific reason not to use the python v4 client? It improved a lot over the v3 one.
Thanks!
Thanks @DudaNogueira
No, I do not see any error logs. First of all I can see there have been stored several objects on my cluster. Also, when I run a vector search, I donβt get any error and I get some results with some scores, but when running the keyword search all the scores are zero. Having said that you can see my code below.
#external files
from preprocessing import FileIO
from weaviate_interface import WeaviateClient, WeaviateIndexer
#standards
import os
import time
import json
from typing import List
from tqdm.notebook import tqdm
from rich import print
#load from local .env file
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv(), override=True)
#read env vars from local .env file
api_key = os.environ['WEAVIATE_API_KEY']
url = os.environ['WEAVIATE_ENDPOINT']
#instantiate client
client = WeaviateClient(api_key, url)
#check if WCS instance is live and ready
client.is_live(), client.is_ready()
data_path = './data/Books-minilmL6-256.parquet'
data = FileIO().load_parquet(data_path)
from class_templates import book_class_properties
print(book_class_properties)
#create your own class name or use the example from above
class_name = 'Books_minilm_256_6'
#Review Indexing Body
class_config = {'classes': [
{"class": class_name,
"description": "Books on Parenting",
"vectorIndexType": "hnsw",
# Vector index specific settings
"vectorIndexConfig": {
"ef": 64,
"efConstruction": 128,
"maxConnections": 32,
},
"vectorizer": "none",
# pre-defined property mappings
"properties": book_class_properties }
]
}
client.schema.create(class_config)
Also when running the following code for indexing the data:
indexer = WeaviateIndexer(client, batch_size=200, num_workers=2)
indexer.batch_index_data(data, class_name)
I get No classes found on cluster.
However, when I go to dashboard, I can see objects have been created on my cluster, and the vector search seems to work perfectly fine.
Are you using any tool to connect to Weaviate?
Also, have you tried the python v4?
What is the server version you are running?
And finally, can you create an end to end code, with some sample data? Otherwise it gets hard to reproduce as there are some external code.
Hi @DudaNogueira ,
I was using the following piece of code using python v4:
#read env vars from local .env file
api_key = os.environ['WEAVIATE_API_KEY']
url = os.environ['WEAVIATE_ENDPOINT']
model_path = 'sentence-transformers/all-MiniLM-L6-v2'
#instantiate client
client = WeaviateWCS(endpoint=url, api_key=api_key, model_name_or_path=model_path)
#example of using the private _client attribute
client._client.is_connected()
And it was working until yesterday, but today when I run that code I get the following error:
---------------------------------------------------------------------------
ConnectError Traceback (most recent call last)
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/httpx/_transports/default.py:69, in map_httpcore_exceptions()
68 try:
---> 69 yield
70 except Exception as exc:
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/httpx/_transports/default.py:233, 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 ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/httpcore/_sync/connection_pool.py:216, 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 ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/httpcore/_sync/connection_pool.py:196, 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 ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/httpcore/_sync/connection.py:99, in HTTPConnection.handle_request(self, request)
98 self._connect_failed = True
---> 99 raise exc
101 return self._connection.handle_request(request)
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/httpcore/_sync/connection.py:76, 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 ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/httpcore/_sync/connection.py:154, 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 ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/httpcore/_backends/sync.py:152, 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 ~/miniconda3/envs/advanced_rag/lib/python3.10/contextlib.py:153, in _GeneratorContextManager.__exit__(self, typ, value, traceback)
152 try:
--> 153 self.gen.throw(typ, value, traceback)
154 except StopIteration as exc:
155 # Suppress StopIteration *unless* it's the same exception that
156 # was passed to throw(). This prevents a StopIteration
157 # raised inside the "with" statement from being suppressed.
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/httpcore/_exceptions.py:14, in map_exceptions(map)
13 if isinstance(exc, from_exc):
---> 14 raise to_exc(exc) from exc
15 raise
ConnectError: [Errno 54] Connection reset by peer
The above exception was the direct cause of the following exception:
ConnectError Traceback (most recent call last)
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/weaviate/connect/v4.py:429, in _Connection.__send(self, method, url, error_msg, status_codes, weaviate_object, params)
422 req = self._client.build_request(
423 method,
424 url,
(...)
427 headers=self.__get_latest_headers(),
428 )
--> 429 res = self._client.send(req)
430 if status_codes is not None and res.status_code not in status_codes.ok:
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/httpx/_client.py:914, in Client.send(self, request, stream, auth, follow_redirects)
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:
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/httpx/_client.py:942, in Client._send_handling_auth(self, request, auth, follow_redirects, history)
941 while True:
--> 942 response = self._send_handling_redirects(
943 request,
944 follow_redirects=follow_redirects,
945 history=history,
946 )
947 try:
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/httpx/_client.py:979, in Client._send_handling_redirects(self, request, follow_redirects, history)
977 hook(request)
--> 979 response = self._send_single_request(request)
980 try:
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/httpx/_client.py:1015, in Client._send_single_request(self, request)
1014 with request_context(request=request):
-> 1015 response = transport.handle_request(request)
1017 assert isinstance(response.stream, SyncByteStream)
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/httpx/_transports/default.py:232, in HTTPTransport.handle_request(self, request)
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)
File ~/miniconda3/envs/advanced_rag/lib/python3.10/contextlib.py:153, in _GeneratorContextManager.__exit__(self, typ, value, traceback)
152 try:
--> 153 self.gen.throw(typ, value, traceback)
154 except StopIteration as exc:
155 # Suppress StopIteration *unless* it's the same exception that
156 # was passed to throw(). This prevents a StopIteration
157 # raised inside the "with" statement from being suppressed.
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/httpx/_transports/default.py:86, in map_httpcore_exceptions()
85 message = str(exc)
---> 86 raise mapped_exc(message) from exc
ConnectError: [Errno 54] Connection reset by peer
The above exception was the direct cause of the following exception:
WeaviateConnectionError Traceback (most recent call last)
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/weaviate/connect/v4.py:141, in _Connection.connect(self, skip_init_checks)
140 try:
--> 141 self._weaviate_version = _ServerVersion.from_string(self.get_meta()["version"])
142 except (WeaviateConnectionError, ReadError, RemoteProtocolError) as e:
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/weaviate/connect/v4.py:578, in _Connection.get_meta(self)
575 """
576 Returns the meta endpoint.
577 """
--> 578 response = self.get(path="/meta")
579 res = _decode_json_response_dict(response, "Meta endpoint")
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/weaviate/connect/v4.py:541, in _Connection.get(self, path, params, error_msg, status_codes)
539 request_url = self.url + self._api_version_path + path
--> 541 return self.__send(
542 "GET", url=request_url, params=params, error_msg=error_msg, status_codes=status_codes
543 )
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/weaviate/connect/v4.py:436, in _Connection.__send(self, method, url, error_msg, status_codes, weaviate_object, params)
435 except ConnectError as conn_err:
--> 436 raise WeaviateConnectionError(error_msg) from conn_err
WeaviateConnectionError: Connection to Weaviate failed.
The above exception was the direct cause of the following exception:
WeaviateStartUpError Traceback (most recent call last)
Cell In[2], line 7
4 model_path = 'sentence-transformers/all-MiniLM-L6-v2'
6 #instantiate client
----> 7 client = WeaviateWCS(endpoint=url, api_key=api_key, model_name_or_path=model_path)
9 #example of using the private _client attribute
10 client._client.is_connected()
File ~/Documents/ML_Courses/corise/advanced_rag2/advanced-rag/notebooks/../src/database/weaviate_interface_v4.py:53, in WeaviateWCS.__init__(self, endpoint, api_key, model_name_or_path, embedded, openai_api_key, skip_init_checks, **kwargs)
51 else:
52 auth_config = AuthApiKey(api_key=api_key)
---> 53 self._client = weaviate.connect_to_wcs(cluster_url=endpoint,
54 auth_credentials=auth_config,
55 skip_init_checks=skip_init_checks)
56 self.model_name_or_path = model_name_or_path
57 self._openai_model = False
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/weaviate/connect/helpers.py:85, in connect_to_wcs(cluster_url, auth_credentials, headers, additional_config, skip_init_checks)
73 grpc_host = f"grpc-{cluster_url}"
75 client = WeaviateClient(
76 connection_params=ConnectionParams(
77 http=ProtocolParams(host=cluster_url, port=443, secure=True),
(...)
83 skip_init_checks=skip_init_checks,
84 )
---> 85 return __connect(client)
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/weaviate/connect/helpers.py:345, in __connect(client)
343 except Exception as e:
344 client.close()
--> 345 raise e
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/weaviate/connect/helpers.py:341, in __connect(client)
339 def __connect(client: WeaviateClient) -> WeaviateClient:
340 try:
--> 341 client.connect()
342 return client
343 except Exception as e:
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/weaviate/client.py:282, in WeaviateClient.connect(self)
280 if self._connection.is_connected():
281 return
--> 282 self._connection.connect(self.__skip_init_checks)
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/weaviate/connect/v4.py:655, in ConnectionV4.connect(self, skip_init_checks)
654 def connect(self, skip_init_checks: bool) -> None:
--> 655 super().connect(skip_init_checks)
656 # create GRPC channel. If Weaviate does not support GRPC then error now.
657 self._grpc_channel = self._connection_params._grpc_channel(
658 async_channel=False, proxies=self._proxies
659 )
File ~/miniconda3/envs/advanced_rag/lib/python3.10/site-packages/weaviate/connect/v4.py:143, in _Connection.connect(self, skip_init_checks)
141 self._weaviate_version = _ServerVersion.from_string(self.get_meta()["version"])
142 except (WeaviateConnectionError, ReadError, RemoteProtocolError) as e:
--> 143 raise WeaviateStartUpError(f"Could not connect to Weaviate:{e}.") from e
145 if not skip_init_checks:
146 try:
WeaviateStartUpError: Could not connect to Weaviate:Connection to Weaviate failed. .
Do you have any idea about it?
hi @Saeed_Rezaei !!
It seems the server is down, so the client is not connected.
If that is a server hosted in our cloud, please, open a support ticket from:
If you are hosting this cluster yourself, do you have any logs from the server?
Thanks!
Yes, apparently the server was down, as it worked late night last night.
Thanks @DudaNogueira !
Ok. Just to confirm, is it back online?
Let me know if you need any help!
Thanks!
Yes, it is back online now.
Just to know what is the expected availability?