Skip to content
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: fixing Chroma tests due chromadb update behaviour change #1148

Merged
merged 7 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ChromaFilter:
"""
Dataclass to store the converted filter structure used in Chroma queries.

Following filter criterias are supported:
Following filter criteria are supported:
- `ids`: A list of document IDs to filter by in Chroma collection.
- `where`: A dictionary of metadata filters applied to the documents.
- `where_document`: A dictionary of content-based filters applied to the documents' content.
Expand Down
20 changes: 1 addition & 19 deletions integrations/chroma/tests/test_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ def test_contains(self, document_store: ChromaDocumentStore, filterable_docs: Li
)

def test_multiple_contains(self, document_store: ChromaDocumentStore, filterable_docs: List[Document]):
filterable_docs = [doc for doc in filterable_docs if doc.content] # remove documents without content
document_store.write_documents(filterable_docs)
filters = {
"operator": "OR",
Expand Down Expand Up @@ -342,25 +343,6 @@ def test_nested_logical_filters(self, document_store: ChromaDocumentStore, filte
],
)

# Override inequality tests from FilterDocumentsTest
# because chroma doesn't return documents with absent meta fields

def test_comparison_not_equal(self, document_store, filterable_docs):
"""Test filter_documents() with != comparator"""
document_store.write_documents(filterable_docs)
result = document_store.filter_documents({"field": "meta.number", "operator": "!=", "value": 100})
self.assert_documents_are_equal(
result, [d for d in filterable_docs if "number" in d.meta and d.meta.get("number") != 100]
)

def test_comparison_not_in(self, document_store, filterable_docs):
"""Test filter_documents() with 'not in' comparator"""
document_store.write_documents(filterable_docs)
result = document_store.filter_documents({"field": "meta.number", "operator": "not in", "value": [2, 9]})
self.assert_documents_are_equal(
result, [d for d in filterable_docs if "number" in d.meta and d.meta.get("number") not in [2, 9]]
)

@pytest.mark.skip(reason="Filter on dataframe contents is not supported.")
def test_comparison_equal_with_dataframe(
self, document_store: ChromaDocumentStore, filterable_docs: List[Document]
Expand Down
Loading