haystack-core-integrations
haystack-core-integrations copied to clipboard
Weaviate: Improve connection check
Is your feature request related to a problem? Please describe. The current check makes a random call to check if the weaviate server is reachable:
# Test connection, it will raise an exception if it fails.
self._client.schema.get()
Describe the solution you'd like Encapsulate the client creation in a method that also does exception handling and prints user friendly messages when an exception is raised. For example (credit to @Shah91n):
def establish_connection():
try:
client = weaviate.connect_to_wcs(
cluster_url="",
auth_credentials=weaviate.auth.AuthApiKey(""),
headers={"X-OpenAI-Api-Key": ""}
)
ready = client.is_ready()
version = weaviate.__version__
print(f"Weaviate client is ready: {ready}")
print(f"Weaviate Version: {version}")
return client
except Exception as e:
print(f"There is a problem: {e}")
traceback.print_exc()
return None
Describe alternatives you've considered do nothing
Additional context NA
Hi, @hsm207 I would like to take up this issue.
Hi @srini047,
Great! Thanks for volunteering. I'm not a maintainer so I can't assign this issue to you. Maybe @masci can?
Hi @hsm207 , I see this issue outdated considering weaviate now automatically handles the connection persistence and its incorporated in haystack-integrations/integrations/weaviate/src/haystack_integrations/document_stores/weaviate/document_store.py.
But now the issue lies with closing connection, where resources are not freed up. So I would like to extend this issue to address that and contribute the same. This requires handling at the object destructor scope to ensure proper management.