mirror of
https://github.com/deepset-ai/haystack.git
synced 2026-01-07 20:46:31 +00:00
refactor: Pinecone tests (#3555)
* add pytest option to unmock pinecone * first try * handle missing answer * fix labels metadata * more tests * adapt workflow * typo * address review comments
This commit is contained in:
parent
559730649b
commit
057a8c0b4f
96
.github/workflows/tests.yml
vendored
96
.github/workflows/tests.yml
vendored
@ -324,7 +324,6 @@ jobs:
|
||||
channel: '#haystack'
|
||||
if: failure() && github.repository_owner == 'deepset-ai' && github.ref == 'refs/heads/main'
|
||||
|
||||
|
||||
integration-tests-weaviate:
|
||||
name: Integration / Weaviate / ${{ matrix.os }}
|
||||
needs:
|
||||
@ -363,6 +362,37 @@ jobs:
|
||||
channel: '#haystack'
|
||||
if: failure() && github.repository_owner == 'deepset-ai' && github.ref == 'refs/heads/main'
|
||||
|
||||
integration-tests-pinecone:
|
||||
name: Integration / pinecone / ${{ matrix.os }}
|
||||
needs:
|
||||
- unit-tests
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest,macos-latest,windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Python
|
||||
uses: ./.github/actions/python_cache/
|
||||
|
||||
- name: Install Haystack
|
||||
run: pip install .[pinecone]
|
||||
|
||||
- name: Run tests
|
||||
env:
|
||||
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
|
||||
run: |
|
||||
pytest --maxfail=5 -m "document_store and integration" test/document_stores/test_pinecone.py
|
||||
|
||||
- uses: act10ns/slack@v1
|
||||
with:
|
||||
status: ${{ job.status }}
|
||||
channel: '#haystack'
|
||||
if: failure() && github.repository_owner == 'deepset-ai' && github.ref == 'refs/heads/main'
|
||||
|
||||
|
||||
#
|
||||
# TODO: the following steps need to be revisited
|
||||
#
|
||||
@ -540,71 +570,7 @@ jobs:
|
||||
# pytest ${{ env.PYTEST_PARAMS }} -m "milvus and not integration" ${{ env.SUITES_EXCLUDED_FROM_WINDOWS }} test/document_stores/ --document_store_type=milvus
|
||||
|
||||
|
||||
pinecone-tests-linux:
|
||||
needs: [mypy, pylint, black]
|
||||
runs-on: ubuntu-latest
|
||||
if: contains(github.event.pull_request.labels.*.name, 'topic:pinecone') || !github.event.pull_request.draft
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Python
|
||||
uses: ./.github/actions/python_cache/
|
||||
|
||||
# TODO Let's try to remove this one from the unit tests
|
||||
- name: Install pdftotext
|
||||
run: wget --no-check-certificate https://dl.xpdfreader.com/xpdf-tools-linux-4.04.tar.gz && tar -xvf xpdf-tools-linux-4.04.tar.gz && sudo cp xpdf-tools-linux-4.04/bin64/pdftotext /usr/local/bin
|
||||
|
||||
- name: Install Haystack
|
||||
run: pip install .[pinecone]
|
||||
|
||||
- name: Run tests
|
||||
env:
|
||||
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
|
||||
TOKENIZERS_PARALLELISM: 'false'
|
||||
run: |
|
||||
pytest ${{ env.PYTEST_PARAMS }} -m "pinecone and not integration" test/document_stores/ --document_store_type=pinecone
|
||||
|
||||
- uses: act10ns/slack@v1
|
||||
with:
|
||||
status: ${{ job.status }}
|
||||
channel: '#haystack'
|
||||
if: failure() && github.repository_owner == 'deepset-ai' && github.ref == 'refs/heads/main'
|
||||
|
||||
pinecone-tests-windows:
|
||||
needs: [mypy, pylint, black]
|
||||
runs-on: windows-latest
|
||||
if: contains(github.event.pull_request.labels.*.name, 'topic:pinecone') && contains(github.event.pull_request.labels.*.name, 'topic:windows') || !github.event.pull_request.draft
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Python
|
||||
uses: ./.github/actions/python_cache/
|
||||
with:
|
||||
prefix: windows
|
||||
|
||||
- name: Install pdftotext
|
||||
run: |
|
||||
choco install xpdf-utils
|
||||
choco install openjdk11
|
||||
refreshenv
|
||||
|
||||
- name: Install Haystack
|
||||
run: pip install .[pinecone]
|
||||
|
||||
- name: Run tests
|
||||
env:
|
||||
TOKENIZERS_PARALLELISM: 'false'
|
||||
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
|
||||
run: |
|
||||
pytest ${{ env.PYTEST_PARAMS }} -m "pinecone and not integration" ${{ env.SUITES_EXCLUDED_FROM_WINDOWS }} test/document_stores/ --document_store_type=pinecone
|
||||
|
||||
- uses: act10ns/slack@v1
|
||||
with:
|
||||
status: ${{ job.status }}
|
||||
channel: '#haystack'
|
||||
if: failure() && github.repository_owner == 'deepset-ai' && github.ref == 'refs/heads/main'
|
||||
|
||||
rest-and-ui:
|
||||
needs: [mypy, pylint, black]
|
||||
|
||||
@ -7,6 +7,9 @@ def pytest_addoption(parser):
|
||||
parser.addoption(
|
||||
"--mock-dc", action="store_true", default=True, help="Mock HTTP requests to dC while running tests"
|
||||
)
|
||||
parser.addoption(
|
||||
"--mock-pinecone", action="store_true", default=True, help="Mock HTTP requests to Pinecone while running tests"
|
||||
)
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
|
||||
@ -1340,11 +1340,6 @@ class PineconeDocumentStore(BaseDocumentStore):
|
||||
meta = {
|
||||
"label-id": label.id,
|
||||
"query": label.query,
|
||||
"label-answer-answer": label.answer.answer,
|
||||
"label-answer-type": label.answer.type,
|
||||
"label-answer-score": label.answer.score,
|
||||
"label-answer-context": label.answer.context,
|
||||
"label-answer-document-id": label.answer.document_id,
|
||||
"label-is-correct-answer": label.is_correct_answer,
|
||||
"label-is-correct-document": label.is_correct_document,
|
||||
"label-document-content": label.document.content,
|
||||
@ -1355,19 +1350,38 @@ class PineconeDocumentStore(BaseDocumentStore):
|
||||
"label-updated-at": label.updated_at,
|
||||
"label-pipeline-id": label.pipeline_id,
|
||||
}
|
||||
# Get offset data
|
||||
if label.answer.offsets_in_document:
|
||||
meta["label-answer-offsets-in-document-start"] = label.answer.offsets_in_document[0].start
|
||||
meta["label-answer-offsets-in-document-end"] = label.answer.offsets_in_document[0].end
|
||||
else:
|
||||
meta["label-answer-offsets-in-document-start"] = None
|
||||
meta["label-answer-offsets-in-document-end"] = None
|
||||
if label.answer.offsets_in_context:
|
||||
meta["label-answer-offsets-in-context-start"] = label.answer.offsets_in_context[0].start
|
||||
meta["label-answer-offsets-in-context-end"] = label.answer.offsets_in_context[0].end
|
||||
else:
|
||||
meta["label-answer-offsets-in-context-start"] = None
|
||||
meta["label-answer-offsets-in-context-end"] = None
|
||||
# Get document metadata
|
||||
if label.document.meta is not None:
|
||||
for k, v in label.document.meta.items():
|
||||
meta[f"label-document-meta-{k}"] = v
|
||||
# Get label metadata
|
||||
if label.meta is not None:
|
||||
for k, v in label.meta.items():
|
||||
meta[f"label-meta-{k}"] = v
|
||||
# Get Answer data
|
||||
if label.answer is not None:
|
||||
meta.update(
|
||||
{
|
||||
"label-answer-answer": label.answer.answer,
|
||||
"label-answer-type": label.answer.type,
|
||||
"label-answer-score": label.answer.score,
|
||||
"label-answer-context": label.answer.context,
|
||||
"label-answer-document-id": label.answer.document_id,
|
||||
}
|
||||
)
|
||||
# Get offset data
|
||||
if label.answer.offsets_in_document:
|
||||
meta["label-answer-offsets-in-document-start"] = label.answer.offsets_in_document[0].start
|
||||
meta["label-answer-offsets-in-document-end"] = label.answer.offsets_in_document[0].end
|
||||
else:
|
||||
meta["label-answer-offsets-in-document-start"] = None
|
||||
meta["label-answer-offsets-in-document-end"] = None
|
||||
if label.answer.offsets_in_context:
|
||||
meta["label-answer-offsets-in-context-start"] = label.answer.offsets_in_context[0].start
|
||||
meta["label-answer-offsets-in-context-end"] = label.answer.offsets_in_context[0].end
|
||||
else:
|
||||
meta["label-answer-offsets-in-context-start"] = None
|
||||
meta["label-answer-offsets-in-context-end"] = None
|
||||
metadata[label.id] = meta
|
||||
metadata = self._meta_for_pinecone(metadata)
|
||||
return metadata
|
||||
@ -1377,40 +1391,47 @@ class PineconeDocumentStore(BaseDocumentStore):
|
||||
Converts a list of metadata dictionaries to a list of Labels.
|
||||
"""
|
||||
labels = []
|
||||
for doc in documents:
|
||||
label_meta = {k: v for k, v in doc.meta.items() if k[:6] == "label-" or k == "query"}
|
||||
other_meta = {k: v for k, v in doc.meta.items() if k[:6] != "label-" and k != "query"}
|
||||
for d in documents:
|
||||
label_meta = {k: v for k, v in d.meta.items() if k[:6] == "label-" or k == "query"}
|
||||
other_meta = {k: v for k, v in d.meta.items() if k[:6] != "label-" and k != "query"}
|
||||
# Create document
|
||||
doc = Document(
|
||||
id=label_meta["label-document-id"],
|
||||
content=doc.content,
|
||||
meta=other_meta,
|
||||
score=doc.score,
|
||||
embedding=doc.embedding,
|
||||
id=label_meta["label-document-id"], content=d.content, meta={}, score=d.score, embedding=d.embedding
|
||||
)
|
||||
# Extract document metadata
|
||||
for k, v in d.meta.items():
|
||||
if k.startswith("label-document-meta-"):
|
||||
doc.meta[k[20:]] = v
|
||||
# Extract offsets
|
||||
offsets: Dict[str, Optional[List[Span]]] = {"document": None, "context": None}
|
||||
for mode in offsets.keys():
|
||||
if label_meta[f"label-answer-offsets-in-{mode}-start"] is not None:
|
||||
if label_meta.get(f"label-answer-offsets-in-{mode}-start") is not None:
|
||||
offsets[mode] = [
|
||||
Span(
|
||||
label_meta[f"label-answer-offsets-in-{mode}-start"],
|
||||
label_meta[f"label-answer-offsets-in-{mode}-end"],
|
||||
)
|
||||
]
|
||||
# if label_meta["label-answer-answer"] is None:
|
||||
# label_meta["label-answer-answer"] = ""
|
||||
answer = Answer(
|
||||
answer=label_meta["label-answer-answer"]
|
||||
or "", # If we leave as None a schema validation error will be thrown
|
||||
type=label_meta["label-answer-type"],
|
||||
score=label_meta["label-answer-score"],
|
||||
context=label_meta["label-answer-context"],
|
||||
offsets_in_document=offsets["document"],
|
||||
offsets_in_context=offsets["context"],
|
||||
document_id=label_meta["label-answer-document-id"],
|
||||
meta=other_meta,
|
||||
)
|
||||
# Extract Answer
|
||||
answer = None
|
||||
if label_meta.get("label-answer-answer") is not None:
|
||||
answer = Answer(
|
||||
answer=label_meta["label-answer-answer"]
|
||||
or "", # If we leave as None a schema validation error will be thrown
|
||||
type=label_meta["label-answer-type"],
|
||||
score=label_meta["label-answer-score"],
|
||||
context=label_meta["label-answer-context"],
|
||||
offsets_in_document=offsets["document"],
|
||||
offsets_in_context=offsets["context"],
|
||||
document_id=label_meta["label-answer-document-id"],
|
||||
meta=other_meta,
|
||||
)
|
||||
# Extract Label metadata
|
||||
label_meta_metadata = {}
|
||||
for k, v in d.meta.items():
|
||||
if k.startswith("label-meta-"):
|
||||
label_meta_metadata[k[11:]] = v
|
||||
# Rebuild Label object
|
||||
label = Label(
|
||||
id=label_meta["label-id"],
|
||||
query=label_meta["query"],
|
||||
@ -1422,7 +1443,7 @@ class PineconeDocumentStore(BaseDocumentStore):
|
||||
is_correct_answer=label_meta["label-is-correct-answer"],
|
||||
is_correct_document=label_meta["label-is-correct-document"],
|
||||
origin=label_meta["label-origin"],
|
||||
meta={},
|
||||
meta=label_meta_metadata,
|
||||
filters=None,
|
||||
)
|
||||
labels.append(label)
|
||||
|
||||
@ -318,7 +318,7 @@ class DocumentStoreBaseTestAbstract:
|
||||
|
||||
ds.write_documents(updated_docs, duplicate_documents="skip")
|
||||
for d in ds.get_all_documents():
|
||||
assert d.meta["name"] != "Updated"
|
||||
assert d.meta.get("name") != "Updated"
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_duplicate_documents_overwrite(self, ds, documents):
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
from typing import List, Union, Dict, Any
|
||||
|
||||
import os
|
||||
from datetime import datetime
|
||||
from inspect import getmembers, isclass, isfunction
|
||||
|
||||
import pytest
|
||||
@ -11,6 +10,7 @@ from haystack.schema import Document
|
||||
from haystack.errors import FilterError
|
||||
|
||||
|
||||
from .test_base import DocumentStoreBaseTestAbstract
|
||||
from ..mocks import pinecone as pinecone_mock
|
||||
from ..conftest import SAMPLES_PATH
|
||||
|
||||
@ -19,21 +19,17 @@ from ..conftest import SAMPLES_PATH
|
||||
META_FIELDS = ["meta_field", "name", "date", "numeric_field", "odd_document"]
|
||||
|
||||
|
||||
#
|
||||
# FIXME This class should extend the base Document Store test class once it exists.
|
||||
# At that point some of the fixtures will be duplicate, so review them.
|
||||
#
|
||||
class TestPineconeDocumentStore:
|
||||
class TestPineconeDocumentStore(DocumentStoreBaseTestAbstract):
|
||||
|
||||
# Fixtures
|
||||
|
||||
@pytest.fixture
|
||||
def doc_store(self, monkeypatch, request) -> PineconeDocumentStore:
|
||||
def ds(self, monkeypatch, request) -> PineconeDocumentStore:
|
||||
"""
|
||||
This fixture provides an empty document store and takes care of cleaning up after each test
|
||||
"""
|
||||
# If it's a unit test, mock Pinecone
|
||||
if not "integration" in request.keywords:
|
||||
if request.config.getoption("--mock-pinecone"):
|
||||
for fname, function in getmembers(pinecone_mock, isfunction):
|
||||
monkeypatch.setattr(f"pinecone.{fname}", function, raising=False)
|
||||
for cname, class_ in getmembers(pinecone_mock, isclass):
|
||||
@ -50,12 +46,12 @@ class TestPineconeDocumentStore:
|
||||
)
|
||||
|
||||
@pytest.fixture
|
||||
def doc_store_with_docs(self, doc_store: PineconeDocumentStore, docs: List[Document]) -> PineconeDocumentStore:
|
||||
def doc_store_with_docs(self, ds: PineconeDocumentStore, documents: List[Document]) -> PineconeDocumentStore:
|
||||
"""
|
||||
This fixture provides a pre-populated document store and takes care of cleaning up after each test
|
||||
"""
|
||||
doc_store.write_documents(docs)
|
||||
return doc_store
|
||||
ds.write_documents(documents)
|
||||
return ds
|
||||
|
||||
@pytest.fixture
|
||||
def docs_all_formats(self) -> List[Union[Document, Dict[str, Any]]]:
|
||||
@ -68,6 +64,8 @@ class TestPineconeDocumentStore:
|
||||
"date": "2019-10-01",
|
||||
"numeric_field": 5.0,
|
||||
"odd_document": True,
|
||||
"year": "2021",
|
||||
"month": "02",
|
||||
},
|
||||
# "dict" format
|
||||
{
|
||||
@ -78,6 +76,8 @@ class TestPineconeDocumentStore:
|
||||
"date": "2020-03-01",
|
||||
"numeric_field": 5.5,
|
||||
"odd_document": False,
|
||||
"year": "2021",
|
||||
"month": "02",
|
||||
},
|
||||
},
|
||||
# Document object
|
||||
@ -89,6 +89,8 @@ class TestPineconeDocumentStore:
|
||||
"date": "2018-10-01",
|
||||
"numeric_field": 4.5,
|
||||
"odd_document": True,
|
||||
"year": "2020",
|
||||
"month": "02",
|
||||
},
|
||||
),
|
||||
Document(
|
||||
@ -99,6 +101,7 @@ class TestPineconeDocumentStore:
|
||||
"date": "2021-02-01",
|
||||
"numeric_field": 3.0,
|
||||
"odd_document": False,
|
||||
"year": "2020",
|
||||
},
|
||||
),
|
||||
Document(
|
||||
@ -109,102 +112,157 @@ class TestPineconeDocumentStore:
|
||||
"date": "2019-01-01",
|
||||
"numeric_field": 0.0,
|
||||
"odd_document": True,
|
||||
"year": "2020",
|
||||
},
|
||||
),
|
||||
Document(
|
||||
content="My name is Adele and I live in London",
|
||||
meta={
|
||||
"meta_field": "test-5",
|
||||
"name": "file_5.txt",
|
||||
"date": "2019-01-01",
|
||||
"numeric_field": 0.0,
|
||||
"odd_document": True,
|
||||
"year": "2021",
|
||||
},
|
||||
),
|
||||
# Without meta
|
||||
Document(content="My name is Ahmed and I live in Cairo"),
|
||||
Document(content="My name is Bruce and I live in Gotham"),
|
||||
Document(content="My name is Peter and I live in Quahog"),
|
||||
]
|
||||
|
||||
@pytest.fixture
|
||||
def docs(self, docs_all_formats: List[Union[Document, Dict[str, Any]]]) -> List[Document]:
|
||||
def documents(self, docs_all_formats: List[Union[Document, Dict[str, Any]]]) -> List[Document]:
|
||||
return [Document.from_dict(doc) if isinstance(doc, dict) else doc for doc in docs_all_formats]
|
||||
|
||||
#
|
||||
# Tests
|
||||
#
|
||||
|
||||
@pytest.mark.pinecone
|
||||
@pytest.mark.integration
|
||||
def test_ne_filters(self, ds, documents):
|
||||
ds.write_documents(documents)
|
||||
|
||||
result = ds.get_all_documents(filters={"year": {"$ne": "2020"}})
|
||||
assert len(result) == 3
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_get_label_count(self, ds, labels):
|
||||
with pytest.raises(NotImplementedError):
|
||||
ds.get_label_count()
|
||||
|
||||
# NOTE: the PineconeDocumentStore behaves differently to the others when filters are applied.
|
||||
# While this should be considered a bug, the relative tests are skipped in the meantime
|
||||
|
||||
@pytest.mark.skip
|
||||
@pytest.mark.integration
|
||||
def test_compound_filters(self, ds, documents):
|
||||
pass
|
||||
|
||||
@pytest.mark.skip
|
||||
@pytest.mark.integration
|
||||
def test_nin_filters(self, ds, documents):
|
||||
pass
|
||||
|
||||
@pytest.mark.skip
|
||||
@pytest.mark.integration
|
||||
def test_ne_filters(self, ds, documents):
|
||||
pass
|
||||
|
||||
@pytest.mark.skip
|
||||
@pytest.mark.integration
|
||||
def test_nin_filters(self, ds, documents):
|
||||
pass
|
||||
|
||||
@pytest.mark.skip
|
||||
@pytest.mark.integration
|
||||
def test_comparison_filters(self, ds, documents):
|
||||
pass
|
||||
|
||||
@pytest.mark.skip
|
||||
@pytest.mark.integration
|
||||
def test_nested_condition_filters(self, ds, documents):
|
||||
pass
|
||||
|
||||
@pytest.mark.skip
|
||||
@pytest.mark.integration
|
||||
def test_nested_condition_not_filters(self, ds, documents):
|
||||
pass
|
||||
|
||||
# NOTE: labels metadata are not supported
|
||||
|
||||
@pytest.mark.skip
|
||||
@pytest.mark.integration
|
||||
def test_delete_labels_by_filter(self, ds, labels):
|
||||
pass
|
||||
|
||||
@pytest.mark.skip
|
||||
@pytest.mark.integration
|
||||
def test_delete_labels_by_filter_id(self, ds, labels):
|
||||
pass
|
||||
|
||||
@pytest.mark.skip
|
||||
@pytest.mark.integration
|
||||
def test_simplified_filters(self, ds, documents):
|
||||
pass
|
||||
|
||||
# NOTE: Pinecone does not support dates, so it can't do lte or gte on date fields. When a new release introduces this feature,
|
||||
# the entire family of test_get_all_documents_extended_filter_* tests will become identical to the one present in the
|
||||
# base document store suite, and can be removed from here.
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_get_all_documents_extended_filter_eq(self, doc_store_with_docs: PineconeDocumentStore):
|
||||
eq_docs = doc_store_with_docs.get_all_documents(filters={"meta_field": {"$eq": "test-1"}})
|
||||
normal_docs = doc_store_with_docs.get_all_documents(filters={"meta_field": "test-1"})
|
||||
assert eq_docs == normal_docs
|
||||
|
||||
@pytest.mark.pinecone
|
||||
# NOTE: Pinecone does not support dates, so it can't do lte or gte on date fields. When a new release introduces this feature,
|
||||
# the entire family of test_get_all_documents_extended_filter_* tests will become identical to the one present in the
|
||||
# base document store suite, and can be removed from here.
|
||||
@pytest.mark.integration
|
||||
def test_get_all_documents_extended_filter_in(self, doc_store_with_docs: PineconeDocumentStore):
|
||||
in_docs = doc_store_with_docs.get_all_documents(filters={"meta_field": {"$in": ["test-1", "test-2", "n.a."]}})
|
||||
normal_docs = doc_store_with_docs.get_all_documents(filters={"meta_field": ["test-1", "test-2", "n.a."]})
|
||||
assert in_docs == normal_docs
|
||||
|
||||
@pytest.mark.pinecone
|
||||
# NOTE: Pinecone does not support dates, so it can't do lte or gte on date fields. When a new release introduces this feature,
|
||||
# the entire family of test_get_all_documents_extended_filter_* tests will become identical to the one present in the
|
||||
# base document store suite, and can be removed from here.
|
||||
@pytest.mark.integration
|
||||
def test_get_all_documents_extended_filter_ne(self, doc_store_with_docs: PineconeDocumentStore):
|
||||
retrieved_docs = doc_store_with_docs.get_all_documents(filters={"meta_field": {"$ne": "test-1"}})
|
||||
assert all("test-1" != d.meta.get("meta_field", None) for d in retrieved_docs)
|
||||
|
||||
@pytest.mark.pinecone
|
||||
# NOTE: Pinecone does not support dates, so it can't do lte or gte on date fields. When a new release introduces this feature,
|
||||
# the entire family of test_get_all_documents_extended_filter_* tests will become identical to the one present in the
|
||||
# base document store suite, and can be removed from here.
|
||||
@pytest.mark.integration
|
||||
def test_get_all_documents_extended_filter_nin(self, doc_store_with_docs: PineconeDocumentStore):
|
||||
retrieved_docs = doc_store_with_docs.get_all_documents(
|
||||
filters={"meta_field": {"$nin": ["test-1", "test-2", "n.a."]}}
|
||||
)
|
||||
assert {"test-1", "test-2"}.isdisjoint({d.meta.get("meta_field", None) for d in retrieved_docs})
|
||||
|
||||
@pytest.mark.pinecone
|
||||
# NOTE: Pinecone does not support dates, so it can't do lte or gte on date fields. When a new release introduces this feature,
|
||||
# the entire family of test_get_all_documents_extended_filter_* tests will become identical to the one present in the
|
||||
# base document store suite, and can be removed from here.
|
||||
@pytest.mark.integration
|
||||
def test_get_all_documents_extended_filter_gt(self, doc_store_with_docs: PineconeDocumentStore):
|
||||
retrieved_docs = doc_store_with_docs.get_all_documents(filters={"numeric_field": {"$gt": 3.0}})
|
||||
assert all(d.meta["numeric_field"] > 3.0 for d in retrieved_docs)
|
||||
|
||||
@pytest.mark.pinecone
|
||||
# NOTE: Pinecone does not support dates, so it can't do lte or gte on date fields. When a new release introduces this feature,
|
||||
# the entire family of test_get_all_documents_extended_filter_* tests will become identical to the one present in the
|
||||
# base document store suite, and can be removed from here.
|
||||
@pytest.mark.integration
|
||||
def test_get_all_documents_extended_filter_gte(self, doc_store_with_docs: PineconeDocumentStore):
|
||||
retrieved_docs = doc_store_with_docs.get_all_documents(filters={"numeric_field": {"$gte": 3.0}})
|
||||
assert all(d.meta["numeric_field"] >= 3.0 for d in retrieved_docs)
|
||||
|
||||
@pytest.mark.pinecone
|
||||
# NOTE: Pinecone does not support dates, so it can't do lte or gte on date fields. When a new release introduces this feature,
|
||||
# the entire family of test_get_all_documents_extended_filter_* tests will become identical to the one present in the
|
||||
# base document store suite, and can be removed from here.
|
||||
@pytest.mark.integration
|
||||
def test_get_all_documents_extended_filter_lt(self, doc_store_with_docs: PineconeDocumentStore):
|
||||
retrieved_docs = doc_store_with_docs.get_all_documents(filters={"numeric_field": {"$lt": 3.0}})
|
||||
assert all(d.meta["numeric_field"] < 3.0 for d in retrieved_docs)
|
||||
|
||||
@pytest.mark.pinecone
|
||||
# NOTE: Pinecone does not support dates, so it can't do lte or gte on date fields. When a new release introduces this feature,
|
||||
# the entire family of test_get_all_documents_extended_filter_* tests will become identical to the one present in the
|
||||
# base document store suite, and can be removed from here.
|
||||
@pytest.mark.integration
|
||||
def test_get_all_documents_extended_filter_lte(self, doc_store_with_docs: PineconeDocumentStore):
|
||||
retrieved_docs = doc_store_with_docs.get_all_documents(filters={"numeric_field": {"$lte": 3.0}})
|
||||
assert all(d.meta["numeric_field"] <= 3.0 for d in retrieved_docs)
|
||||
|
||||
@pytest.mark.pinecone
|
||||
# NOTE: Pinecone does not support dates, so it can't do lte or gte on date fields. When a new release introduces this feature,
|
||||
# the entire family of test_get_all_documents_extended_filter_* tests will become identical to the one present in the
|
||||
# base document store suite, and can be removed from here.
|
||||
@pytest.mark.integration
|
||||
def test_get_all_documents_extended_filter_compound_dates(self, doc_store_with_docs: PineconeDocumentStore):
|
||||
filters = {"date": {"$lte": "2020-12-31", "$gte": "2019-01-01"}}
|
||||
|
||||
with pytest.raises(FilterError, match=r"Comparison value for '\$[l|g]te' operation must be a float or int."):
|
||||
doc_store_with_docs.get_all_documents(filters=filters)
|
||||
|
||||
@pytest.mark.pinecone
|
||||
# NOTE: Pinecone does not support dates, so it can't do lte or gte on date fields. When a new release introduces this feature,
|
||||
# the entire family of test_get_all_documents_extended_filter_* tests will become identical to the one present in the
|
||||
# base document store suite, and can be removed from here.
|
||||
@pytest.mark.integration
|
||||
def test_get_all_documents_extended_filter_compound_dates_and_other_field_explicit(
|
||||
self, doc_store_with_docs: PineconeDocumentStore
|
||||
):
|
||||
@ -218,10 +276,7 @@ class TestPineconeDocumentStore:
|
||||
with pytest.raises(FilterError, match="Comparison value for '\$[l|g]te' operation must be a float or int."):
|
||||
doc_store_with_docs.get_all_documents(filters=filters)
|
||||
|
||||
@pytest.mark.pinecone
|
||||
# NOTE: Pinecone does not support dates, so it can't do lte or gte on date fields. When a new release introduces this feature,
|
||||
# the entire family of test_get_all_documents_extended_filter_* tests will become identical to the one present in the
|
||||
# base document store suite, and can be removed from here.
|
||||
@pytest.mark.integration
|
||||
def test_get_all_documents_extended_filter_compound_dates_and_other_field_simplified(
|
||||
self, doc_store_with_docs: PineconeDocumentStore
|
||||
):
|
||||
@ -233,10 +288,7 @@ class TestPineconeDocumentStore:
|
||||
with pytest.raises(FilterError, match="Comparison value for '\$[l|g]te' operation must be a float or int."):
|
||||
doc_store_with_docs.get_all_documents(filters=filters_simplified)
|
||||
|
||||
@pytest.mark.pinecone
|
||||
# NOTE: Pinecone does not support dates, so it can't do lte or gte on date fields. When a new release introduces this feature,
|
||||
# the entire family of test_get_all_documents_extended_filter_* tests will become identical to the one present in the
|
||||
# base document store suite, and can be removed from here.
|
||||
@pytest.mark.integration
|
||||
def test_get_all_documents_extended_filter_compound_dates_and_or_explicit(
|
||||
self, doc_store_with_docs: PineconeDocumentStore
|
||||
):
|
||||
@ -250,10 +302,7 @@ class TestPineconeDocumentStore:
|
||||
with pytest.raises(FilterError, match="Comparison value for '\$[l|g]te' operation must be a float or int."):
|
||||
doc_store_with_docs.get_all_documents(filters=filters)
|
||||
|
||||
@pytest.mark.pinecone
|
||||
# NOTE: Pinecone does not support dates, so it can't do lte or gte on date fields. When a new release introduces this feature,
|
||||
# the entire family of test_get_all_documents_extended_filter_* tests will become identical to the one present in the
|
||||
# base document store suite, and can be removed from here.
|
||||
@pytest.mark.integration
|
||||
def test_get_all_documents_extended_filter_compound_dates_and_or_simplified(
|
||||
self, doc_store_with_docs: PineconeDocumentStore
|
||||
):
|
||||
@ -265,10 +314,7 @@ class TestPineconeDocumentStore:
|
||||
with pytest.raises(FilterError, match="Comparison value for '\$[l|g]te' operation must be a float or int."):
|
||||
doc_store_with_docs.get_all_documents(filters=filters_simplified)
|
||||
|
||||
@pytest.mark.pinecone
|
||||
# NOTE: Pinecone does not support dates, so it can't do lte or gte on date fields. When a new release introduces this feature,
|
||||
# the entire family of test_get_all_documents_extended_filter_* tests will become identical to the one present in the
|
||||
# base document store suite, and can be removed from here.
|
||||
@pytest.mark.integration
|
||||
def test_get_all_documents_extended_filter_compound_dates_and_or_and_not_explicit(
|
||||
self, doc_store_with_docs: PineconeDocumentStore
|
||||
):
|
||||
@ -284,10 +330,7 @@ class TestPineconeDocumentStore:
|
||||
with pytest.raises(FilterError, match="Comparison value for '\$[l|g]te' operation must be a float or int."):
|
||||
doc_store_with_docs.get_all_documents(filters=filters)
|
||||
|
||||
@pytest.mark.pinecone
|
||||
# NOTE: Pinecone does not support dates, so it can't do lte or gte on date fields. When a new release introduces this feature,
|
||||
# the entire family of test_get_all_documents_extended_filter_* tests will become identical to the one present in the
|
||||
# base document store suite, and can be removed from here.
|
||||
@pytest.mark.integration
|
||||
def test_get_all_documents_extended_filter_compound_dates_and_or_and_not_simplified(
|
||||
self, doc_store_with_docs: PineconeDocumentStore
|
||||
):
|
||||
@ -301,10 +344,7 @@ class TestPineconeDocumentStore:
|
||||
with pytest.raises(FilterError, match="Comparison value for '\$[l|g]te' operation must be a float or int."):
|
||||
doc_store_with_docs.get_all_documents(filters=filters_simplified)
|
||||
|
||||
@pytest.mark.pinecone
|
||||
# NOTE: Pinecone does not support dates, so it can't do lte or gte on date fields. When a new release introduces this feature,
|
||||
# the entire family of test_get_all_documents_extended_filter_* tests will become identical to the one present in the
|
||||
# base document store suite, and can be removed from here.
|
||||
@pytest.mark.integration
|
||||
def test_get_all_documents_extended_filter_compound_nested_not(self, doc_store_with_docs: PineconeDocumentStore):
|
||||
# Test nested logical operations within "$not", important as we apply De Morgan's laws in Weaviatedocstore
|
||||
filters = {
|
||||
@ -318,10 +358,7 @@ class TestPineconeDocumentStore:
|
||||
with pytest.raises(FilterError, match="Comparison value for '\$[l|g]t' operation must be a float or int."):
|
||||
doc_store_with_docs.get_all_documents(filters=filters)
|
||||
|
||||
@pytest.mark.pinecone
|
||||
# NOTE: Pinecone does not support dates, so it can't do lte or gte on date fields. When a new release introduces this feature,
|
||||
# the entire family of test_get_all_documents_extended_filter_* tests will become identical to the one present in the
|
||||
# base document store suite, and can be removed from here.
|
||||
@pytest.mark.integration
|
||||
def test_get_all_documents_extended_filter_compound_same_level_not(
|
||||
self, doc_store_with_docs: PineconeDocumentStore
|
||||
):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user