Skip to content

fix: Remove unnecessary connection test and add close/close_async methods to WeaviateDocumentStore#2891

Open
maxdswain wants to merge 5 commits intodeepset-ai:mainfrom
maxdswain:Weaviate-connection
Open

fix: Remove unnecessary connection test and add close/close_async methods to WeaviateDocumentStore#2891
maxdswain wants to merge 5 commits intodeepset-ai:mainfrom
maxdswain:Weaviate-connection

Conversation

@maxdswain
Copy link
Contributor

Related Issues

Proposed Changes:

  • Weaviate's python clients now automatically attempt to connect when self._client.connect()/self._async_client.connect() is called allowing both self._client.collections.list_all(simple=True) and self._async_client.collections.list_all(simple=True) to be removed.
  • Add close and async_close methods to WeaviateDocumentStore mirroring what is done in ValkeyDocumentStore and PineconeDocumentStore.
  • Updated relevant tests/fixtures to properly close connections to Weaviate.

How did you test it?

Modified existing integration tests.

Notes for the reviewer

Checklist

@maxdswain maxdswain requested a review from a team as a code owner February 27, 2026 17:19
@maxdswain maxdswain requested review from bogdankostic and removed request for a team February 27, 2026 17:19
@maxdswain maxdswain changed the title fix: Remove unnecessary connection test and add close/close_async methods to WeaviateDocumentStore fix: Remove unnecessary connection test and add close/close_async methods to WeaviateDocumentStore Feb 27, 2026
@github-actions github-actions bot added the type:documentation Improvements or additions to documentation label Feb 27, 2026
@anakin87 anakin87 requested review from anakin87 and removed request for bogdankostic March 3, 2026 09:36
Copy link
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution!

I left some comments.

def close(self) -> None:
"""
Close the synchronous Weaviate client connection.
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all, in this method, I'd set self._collection = None

self._client = None

async def close_async(self) -> None:
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's set self. _async_collection = None here

yield store
store.client.collections.delete(collection_settings["class"])
store.close()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a test_close test, similar in spirit to this Pinecone test

def test_close(self, document_store: PineconeDocumentStore):

)
yield store
store.client.collections.delete(collection_settings["class"])
store.close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed?

Copy link
Contributor Author

@maxdswain maxdswain Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of the async tests call write_documents which uses the sync client so I think it is yes.

store.client.collections.delete(collection_settings["class"])
store.close()
await store.close_async()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a test_close_async test

@maxdswain
Copy link
Contributor Author

Thanks for the feedback and review @anakin87, it's much appreciated I'll make sure to be more thorough in the tests I add in future PRs. I believe I have addressed all of your comments now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:weaviate type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Weaviate: Improve connection check

2 participants