Hi there!
On importing data to weaviate, I check if the class exists.
But quite often it fails to check if a class exists.
requests.exceptions.ConnectionError: Checking class existence could not be done.
I think it’s because the server closes the connection unexpectedly.
This is how I check for the class existence.
# PYTHON CODE TO SAVE OBJECT
source_class = settings.KNOWLEDGE_SOURCE_CLASS.format(user_id)
content_class = settings.CONTENT_CLASS.format(user_id)
try:
if not client.schema.exists(source_class):
print("[!] Schema doesn't exist. Initializing...")
logger.debug(f"Initializing {user_id} schema")
knowledge_source = {...}
content = {...}
client.schema.create({"classes": [knowledge_source, content]})
I end up getting the following error:
File "/home/glitch/nous-backend/src/indexer.py", line 34, in indexer
if not client.schema.exists(source_class):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/glitch/nous-backend/.venv/lib/python3.11/site-packages/weaviate/schema/crud_schema.py", line 318, in exists
raise RequestsConnectionError(
requests.exceptions.ConnectionError: Checking class existence could not be done.
Going through the stack trace i think these are the chunks:
.....
File "/usr/lib/python3.11/http/client.py", line 287, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
.....
File "/usr/lib/python3.11/http/client.py", line 287, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
During handling of the above exception, another exception occurred:
.......
File "/home/glitch/nous-backend/.venv/lib/python3.11/site-packages/requests/adapters.py", line 501, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
The above exception was the direct cause of the following exception:
.....
File "/home/glitch/nous-backend/.venv/lib/python3.11/site-packages/weaviate/schema/crud_schema.py", line 318, in exists
raise RequestsConnectionError(
requests.exceptions.ConnectionError: Checking class existence could not be done.