-
Notifications
You must be signed in to change notification settings - Fork 254
fix: Remove unnecessary connection test and add close/close_async methods to WeaviateDocumentStore
#2891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Remove unnecessary connection test and add close/close_async methods to WeaviateDocumentStore
#2891
Changes from all commits
335aa84
0d30948
e095289
e71e3e5
4a119ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| version: '3.4' | ||
| services: | ||
| weaviate: | ||
| command: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,10 @@ | |
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from collections.abc import AsyncGenerator | ||
|
|
||
| import pytest | ||
| import pytest_asyncio | ||
| from haystack.dataclasses.document import Document | ||
|
|
||
| from haystack_integrations.document_stores.weaviate import WeaviateDocumentStore | ||
|
|
@@ -11,8 +14,8 @@ | |
|
|
||
| @pytest.mark.integration | ||
| class TestWeaviateDocumentStoreAsync: | ||
| @pytest.fixture | ||
| def document_store(self, request) -> WeaviateDocumentStore: | ||
| @pytest_asyncio.fixture | ||
| async def document_store(self, request) -> AsyncGenerator[WeaviateDocumentStore, None, None]: | ||
| collection_settings = { | ||
| "class": f"{request.node.name}", | ||
| "invertedIndexConfig": {"indexNullState": True}, | ||
|
|
@@ -29,6 +32,34 @@ def document_store(self, request) -> WeaviateDocumentStore: | |
| ) | ||
| yield store | ||
| store.client.collections.delete(collection_settings["class"]) | ||
| store.close() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this needed?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A lot of the async tests call
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see. This document store does not have the |
||
| await store.close_async() | ||
|
|
||
|
anakin87 marked this conversation as resolved.
|
||
| @pytest.mark.asyncio | ||
| async def test_close_async(self, document_store: WeaviateDocumentStore) -> None: | ||
| # Initialise client and collection | ||
| assert await document_store.async_client is not None | ||
| assert await document_store.async_collection is not None | ||
|
|
||
| await document_store.close_async() | ||
|
|
||
| assert document_store._async_client is None | ||
| assert document_store._async_collection is None | ||
|
|
||
| # Initialise client and collection, then test it stills works after reopening | ||
| assert await document_store.async_client is not None | ||
| assert await document_store.async_collection is not None | ||
|
|
||
| document_store.write_documents( | ||
| [ | ||
| Document(content="Haskell is a functional programming language"), | ||
| Document(content="Lisp is a functional programming language"), | ||
| Document(content="Python is an object oriented programming language"), | ||
| ] | ||
| ) | ||
| filters = {"field": "content", "operator": "==", "value": "Haskell"} | ||
|
|
||
| assert await document_store.count_documents_by_filter_async(filters) == 1 | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_bm25_retrieval_async(self, document_store): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not remove this line, unless it's needed for some reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see it's now an obsolete field that can be safely removed