Skip to content

Commit

Permalink
fix linter errors (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
masci authored Jan 29, 2024
1 parent df86747 commit c23a41c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,23 @@ def _build_in_condition(self, key: str, value: List[models.ValueVariants]) -> mo
raise FilterError(msg)
return models.Filter(
should=[
models.FieldCondition(key=key, match=models.MatchText(text=item))
if isinstance(item, str) and " " not in item
else models.FieldCondition(key=key, match=models.MatchValue(value=item))
(
models.FieldCondition(key=key, match=models.MatchText(text=item))
if isinstance(item, str) and " " not in item
else models.FieldCondition(key=key, match=models.MatchValue(value=item))
)
for item in value
]
)

def _build_ne_condition(self, key: str, value: models.ValueVariants) -> models.Condition:
return models.Filter(
must_not=[
models.FieldCondition(key=key, match=models.MatchText(text=value))
if isinstance(value, str) and " " not in value
else models.FieldCondition(key=key, match=models.MatchValue(value=value))
(
models.FieldCondition(key=key, match=models.MatchText(text=value))
if isinstance(value, str) and " " not in value
else models.FieldCondition(key=key, match=models.MatchValue(value=value))
)
]
)

Expand All @@ -135,9 +139,11 @@ def _build_nin_condition(self, key: str, value: List[models.ValueVariants]) -> m
raise FilterError(msg)
return models.Filter(
must_not=[
models.FieldCondition(key=key, match=models.MatchText(text=item))
if isinstance(item, str) and " " not in item
else models.FieldCondition(key=key, match=models.MatchValue(value=item))
(
models.FieldCondition(key=key, match=models.MatchText(text=item))
if isinstance(item, str) and " " not in item
else models.FieldCondition(key=key, match=models.MatchValue(value=item))
)
for item in value
]
)
Expand Down
21 changes: 7 additions & 14 deletions integrations/qdrant/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,29 +86,22 @@ def test_comparison_less_than_equal_with_none(self, document_store, filterable_d
# ======== ========================== ========

@pytest.mark.skip(reason="Qdrant doesn't support comparision with dataframe")
def test_comparison_equal_with_dataframe(self, document_store, filterable_docs):
...
def test_comparison_equal_with_dataframe(self, document_store, filterable_docs): ...

@pytest.mark.skip(reason="Qdrant doesn't support comparision with dataframe")
def test_comparison_not_equal_with_dataframe(self, document_store, filterable_docs):
...
def test_comparison_not_equal_with_dataframe(self, document_store, filterable_docs): ...

@pytest.mark.skip(reason="Qdrant doesn't support comparision with Dates")
def test_comparison_greater_than_with_iso_date(self, document_store, filterable_docs):
...
def test_comparison_greater_than_with_iso_date(self, document_store, filterable_docs): ...

@pytest.mark.skip(reason="Qdrant doesn't support comparision with Dates")
def test_comparison_greater_than_equal_with_iso_date(self, document_store, filterable_docs):
...
def test_comparison_greater_than_equal_with_iso_date(self, document_store, filterable_docs): ...

@pytest.mark.skip(reason="Qdrant doesn't support comparision with Dates")
def test_comparison_less_than_with_iso_date(self, document_store, filterable_docs):
...
def test_comparison_less_than_with_iso_date(self, document_store, filterable_docs): ...

@pytest.mark.skip(reason="Qdrant doesn't support comparision with Dates")
def test_comparison_less_than_equal_with_iso_date(self, document_store, filterable_docs):
...
def test_comparison_less_than_equal_with_iso_date(self, document_store, filterable_docs): ...

@pytest.mark.skip(reason="Cannot distinguish errors yet")
def test_missing_top_level_operator_key(self, document_store, filterable_docs):
...
def test_missing_top_level_operator_key(self, document_store, filterable_docs): ...
51 changes: 17 additions & 34 deletions integrations/qdrant/tests/test_legacy_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ def test_filter_simple_metadata_value(self, document_store: DocumentStore, filte
self.assert_documents_are_equal(result, [doc for doc in filterable_docs if doc.meta.get("page") == "100"])

@pytest.mark.skip(reason="Dataframe filtering is not supported in Qdrant")
def test_filter_document_dataframe(self, document_store: DocumentStore, filterable_docs: List[Document]):
...
def test_filter_document_dataframe(self, document_store: DocumentStore, filterable_docs: List[Document]): ...

def test_eq_filter_explicit(self, document_store: DocumentStore, filterable_docs: List[Document]):
document_store.write_documents(filterable_docs)
Expand All @@ -58,12 +57,10 @@ def test_eq_filter_implicit(self, document_store: DocumentStore, filterable_docs
self.assert_documents_are_equal(result, [doc for doc in filterable_docs if doc.meta.get("page") == "100"])

@pytest.mark.skip(reason="Dataframe filtering is not supported in Qdrant")
def test_eq_filter_table(self, document_store: DocumentStore, filterable_docs: List[Document]):
...
def test_eq_filter_table(self, document_store: DocumentStore, filterable_docs: List[Document]): ...

@pytest.mark.skip(reason="Embedding filtering is not supported in Qdrant")
def test_eq_filter_embedding(self, document_store: DocumentStore, filterable_docs: List[Document]):
...
def test_eq_filter_embedding(self, document_store: DocumentStore, filterable_docs: List[Document]): ...

# LegacyFilterDocumentsNotEqualTest

Expand All @@ -73,12 +70,10 @@ def test_ne_filter(self, document_store: DocumentStore, filterable_docs: List[Do
self.assert_documents_are_equal(result, [doc for doc in filterable_docs if doc.meta.get("page") != "100"])

@pytest.mark.skip(reason="Dataframe filtering is not supported in Qdrant")
def test_ne_filter_table(self, document_store: DocumentStore, filterable_docs: List[Document]):
...
def test_ne_filter_table(self, document_store: DocumentStore, filterable_docs: List[Document]): ...

@pytest.mark.skip(reason="Embedding filtering is not supported in Qdrant")
def test_ne_filter_embedding(self, document_store: DocumentStore, filterable_docs: List[Document]):
...
def test_ne_filter_embedding(self, document_store: DocumentStore, filterable_docs: List[Document]): ...

# LegacyFilterDocumentsInTest

Expand Down Expand Up @@ -122,22 +117,18 @@ def test_in_filter_implicit(self, document_store: DocumentStore, filterable_docs
)

@pytest.mark.skip(reason="Dataframe filtering is not supported in Qdrant")
def test_in_filter_table(self, document_store: DocumentStore, filterable_docs: List[Document]):
...
def test_in_filter_table(self, document_store: DocumentStore, filterable_docs: List[Document]): ...

@pytest.mark.skip(reason="Embedding filtering is not supported in Qdrant")
def test_in_filter_embedding(self, document_store: DocumentStore, filterable_docs: List[Document]):
...
def test_in_filter_embedding(self, document_store: DocumentStore, filterable_docs: List[Document]): ...

# LegacyFilterDocumentsNotInTest

@pytest.mark.skip(reason="Dataframe filtering is not supported in Qdrant")
def test_nin_filter_table(self, document_store: DocumentStore, filterable_docs: List[Document]):
...
def test_nin_filter_table(self, document_store: DocumentStore, filterable_docs: List[Document]): ...

@pytest.mark.skip(reason="Embedding filtering is not supported in Qdrant")
def test_nin_filter_embedding(self, document_store: DocumentStore, filterable_docs: List[Document]):
...
def test_nin_filter_embedding(self, document_store: DocumentStore, filterable_docs: List[Document]): ...

def test_nin_filter(self, document_store: DocumentStore, filterable_docs: List[Document]):
document_store.write_documents(filterable_docs)
Expand All @@ -163,12 +154,10 @@ def test_gt_filter_non_numeric(self, document_store: DocumentStore, filterable_d
document_store.filter_documents(filters={"meta.page": {"$gt": "100"}})

@pytest.mark.skip(reason="Dataframe filtering is not supported in Qdrant")
def test_gt_filter_table(self, document_store: DocumentStore, filterable_docs: List[Document]):
...
def test_gt_filter_table(self, document_store: DocumentStore, filterable_docs: List[Document]): ...

@pytest.mark.skip(reason="Embedding filtering is not supported in Qdrant")
def test_gt_filter_embedding(self, document_store: DocumentStore, filterable_docs: List[Document]):
...
def test_gt_filter_embedding(self, document_store: DocumentStore, filterable_docs: List[Document]): ...

# LegacyFilterDocumentsGreaterThanEqualTest

Expand All @@ -186,12 +175,10 @@ def test_gte_filter_non_numeric(self, document_store: DocumentStore, filterable_
document_store.filter_documents(filters={"meta.page": {"$gte": "100"}})

@pytest.mark.skip(reason="Dataframe filtering is not supported in Qdrant")
def test_gte_filter_table(self, document_store: DocumentStore, filterable_docs: List[Document]):
...
def test_gte_filter_table(self, document_store: DocumentStore, filterable_docs: List[Document]): ...

@pytest.mark.skip(reason="Embedding filtering is not supported in Qdrant")
def test_gte_filter_embedding(self, document_store: DocumentStore, filterable_docs: List[Document]):
...
def test_gte_filter_embedding(self, document_store: DocumentStore, filterable_docs: List[Document]): ...

# LegacyFilterDocumentsLessThanTest

Expand All @@ -209,12 +196,10 @@ def test_lt_filter_non_numeric(self, document_store: DocumentStore, filterable_d
document_store.filter_documents(filters={"meta.page": {"$lt": "100"}})

@pytest.mark.skip(reason="Dataframe filtering is not supported in Qdrant")
def test_lt_filter_table(self, document_store: DocumentStore, filterable_docs: List[Document]):
...
def test_lt_filter_table(self, document_store: DocumentStore, filterable_docs: List[Document]): ...

@pytest.mark.skip(reason="Embedding filtering is not supported in Qdrant")
def test_lt_filter_embedding(self, document_store: DocumentStore, filterable_docs: List[Document]):
...
def test_lt_filter_embedding(self, document_store: DocumentStore, filterable_docs: List[Document]): ...

# LegacyFilterDocumentsLessThanEqualTest

Expand All @@ -232,12 +217,10 @@ def test_lte_filter_non_numeric(self, document_store: DocumentStore, filterable_
document_store.filter_documents(filters={"meta.page": {"$lte": "100"}})

@pytest.mark.skip(reason="Dataframe filtering is not supported in Qdrant")
def test_lte_filter_table(self, document_store: DocumentStore, filterable_docs: List[Document]):
...
def test_lte_filter_table(self, document_store: DocumentStore, filterable_docs: List[Document]): ...

@pytest.mark.skip(reason="Embedding filtering is not supported in Qdrant")
def test_lte_filter_embedding(self, document_store: DocumentStore, filterable_docs: List[Document]):
...
def test_lte_filter_embedding(self, document_store: DocumentStore, filterable_docs: List[Document]): ...

# LegacyFilterDocumentsSimpleLogicalTest

Expand Down

0 comments on commit c23a41c

Please sign in to comment.