haystack-core-integrations icon indicating copy to clipboard operation
haystack-core-integrations copied to clipboard

Weaviate: Improve connection check

Open hsm207 opened this issue 1 year ago • 3 comments

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

hsm207 avatar Feb 22 '24 14:02 hsm207

Hi, @hsm207 I would like to take up this issue.

srini047 avatar May 04 '24 06:05 srini047

Hi @srini047,

Great! Thanks for volunteering. I'm not a maintainer so I can't assign this issue to you. Maybe @masci can?

hsm207 avatar May 04 '24 08:05 hsm207

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.

srini047 avatar Jun 26 '24 15:06 srini047