From fc15bc12c22a183377e6583ea7aa56a8fec0c5fa Mon Sep 17 00:00:00 2001 From: sahusiddharth Date: Sun, 31 Dec 2023 09:19:29 +0530 Subject: [PATCH 1/2] fix: Error on Chroma DocumentStore creation for pre-existing collection name --- integrations/chroma/src/chroma_haystack/document_store.py | 2 +- integrations/chroma/tests/test_document_store.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/integrations/chroma/src/chroma_haystack/document_store.py b/integrations/chroma/src/chroma_haystack/document_store.py index 8af78f05f..ad4777856 100644 --- a/integrations/chroma/src/chroma_haystack/document_store.py +++ b/integrations/chroma/src/chroma_haystack/document_store.py @@ -41,7 +41,7 @@ def __init__( self._embedding_function_params = embedding_function_params # Create the client instance self._chroma_client = chromadb.Client() - self._collection = self._chroma_client.create_collection( + self._collection = self._chroma_client.get_or_create_collection( name=collection_name, embedding_function=get_embedding_function(embedding_function, **embedding_function_params), ) diff --git a/integrations/chroma/tests/test_document_store.py b/integrations/chroma/tests/test_document_store.py index e99a2bbfd..1d422d1a9 100644 --- a/integrations/chroma/tests/test_document_store.py +++ b/integrations/chroma/tests/test_document_store.py @@ -112,6 +112,11 @@ def test_from_json(self): assert ds._embedding_function == function_name assert ds._embedding_function_params == {"api_key": "1234567890"} + @pytest.mark.integration + def test_same_collection_name_reinitialization(self): + ds = ChromaDocumentStore("test_name") + ds = ChromaDocumentStore("test_name") + @pytest.mark.skip(reason="Filter on array contents is not supported.") @pytest.mark.unit def test_filter_document_array(self, document_store: ChromaDocumentStore, filterable_docs: List[Document]): From 766be127fe2c35bbae3b08e95218e146cdca262a Mon Sep 17 00:00:00 2001 From: sahusiddharth Date: Fri, 5 Jan 2024 08:35:29 +0530 Subject: [PATCH 2/2] linting done --- integrations/chroma/tests/test_document_store.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integrations/chroma/tests/test_document_store.py b/integrations/chroma/tests/test_document_store.py index 1d422d1a9..90761f2e5 100644 --- a/integrations/chroma/tests/test_document_store.py +++ b/integrations/chroma/tests/test_document_store.py @@ -114,8 +114,8 @@ def test_from_json(self): @pytest.mark.integration def test_same_collection_name_reinitialization(self): - ds = ChromaDocumentStore("test_name") - ds = ChromaDocumentStore("test_name") + ChromaDocumentStore("test_name") + ChromaDocumentStore("test_name") @pytest.mark.skip(reason="Filter on array contents is not supported.") @pytest.mark.unit