Skip to content

Commit cb71551

Browse files
committed
formatting
1 parent ccca143 commit cb71551

3 files changed

Lines changed: 39 additions & 37 deletions

File tree

integrations/valkey/examples/example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Dependencies
1+
# Dependencies
22
# [dependency-groups]
33
# examples = [
44
# "markdown-it-py",

integrations/valkey/src/haystack_integrations/document_stores/valkey/document_store.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -135,26 +135,26 @@ class ValkeyDocumentStore(DocumentStore):
135135
_DUMMY_VALUE = -10.0
136136

137137
def __init__(
138-
self,
139-
# Connection configuration
140-
nodes_list: list[tuple[str, int]] | None = None,
141-
*,
142-
cluster_mode: bool = False,
143-
# Security and authentication configuration
144-
use_tls: bool = False,
145-
username: Secret | None = Secret.from_env_var("VALKEY_USERNAME", strict=False), # noqa: B008
146-
password: Secret | None = Secret.from_env_var("VALKEY_PASSWORD", strict=False), # noqa: B008
147-
# Client timeout and retry configuration
148-
request_timeout: int = 500,
149-
retry_attempts: int = 3,
150-
retry_base_delay_ms: int = 1000,
151-
retry_exponent_base: int = 2,
152-
# Document store operation configuration
153-
batch_size: int = 100,
154-
# Index and vector configuration
155-
index_name: str = "haystack_document",
156-
distance_metric: Literal["l2", "cosine", "ip"] = "cosine",
157-
embedding_dim: int = 768,
138+
self,
139+
# Connection configuration
140+
nodes_list: list[tuple[str, int]] | None = None,
141+
*,
142+
cluster_mode: bool = False,
143+
# Security and authentication configuration
144+
use_tls: bool = False,
145+
username: Secret | None = Secret.from_env_var("VALKEY_USERNAME", strict=False), # noqa: B008
146+
password: Secret | None = Secret.from_env_var("VALKEY_PASSWORD", strict=False), # noqa: B008
147+
# Client timeout and retry configuration
148+
request_timeout: int = 500,
149+
retry_attempts: int = 3,
150+
retry_base_delay_ms: int = 1000,
151+
retry_exponent_base: int = 2,
152+
# Document store operation configuration
153+
batch_size: int = 100,
154+
# Index and vector configuration
155+
index_name: str = "haystack_document",
156+
distance_metric: Literal["l2", "cosine", "ip"] = "cosine",
157+
embedding_dim: int = 768,
158158
):
159159
self._index_name = index_name
160160
self._distance_metric = self._parse_metric(distance_metric)
@@ -605,7 +605,7 @@ def write_documents(self, documents: list[Document], policy: DuplicatePolicy = D
605605
return written_count
606606

607607
async def write_documents_async(
608-
self, documents: list[Document], policy: DuplicatePolicy = DuplicatePolicy.NONE
608+
self, documents: list[Document], policy: DuplicatePolicy = DuplicatePolicy.NONE
609609
) -> int:
610610
"""
611611
Asynchronously write documents to the document store.
@@ -658,7 +658,7 @@ def write_single_doc(doc: Document) -> Any:
658658

659659
written_count = 0
660660
for i in range(0, len(documents), self._batch_size):
661-
batch = documents[i : i + self._batch_size]
661+
batch = documents[i: i + self._batch_size]
662662
try:
663663
await asyncio.gather(*[write_single_doc(doc) for doc in batch])
664664
written_count += len(batch)
@@ -807,12 +807,12 @@ async def delete_all_documents_async(self) -> None:
807807
raise ValkeyDocumentStoreError(msg) from e
808808

809809
def _embedding_retrieval(
810-
self,
811-
embedding: list[float],
812-
filters: dict[str, Any] | None = None,
813-
limit: int = 10,
814-
*,
815-
with_embedding: bool = True,
810+
self,
811+
embedding: list[float],
812+
filters: dict[str, Any] | None = None,
813+
limit: int = 10,
814+
*,
815+
with_embedding: bool = True,
816816
) -> list[Document]:
817817
"""
818818
Retrieve documents using vector similarity.
@@ -882,12 +882,12 @@ def _embedding_retrieval(
882882
raise ValkeyDocumentStoreError(msg) from e
883883

884884
async def _embedding_retrieval_async(
885-
self,
886-
embedding: list[float],
887-
filters: dict[str, Any] | None = None,
888-
limit: int = 10,
889-
*,
890-
with_embedding: bool = True,
885+
self,
886+
embedding: list[float],
887+
filters: dict[str, Any] | None = None,
888+
limit: int = 10,
889+
*,
890+
with_embedding: bool = True,
891891
) -> list[Document]:
892892
"""
893893
Asynchronously retrieve documents using vector similarity.
@@ -1027,7 +1027,7 @@ def _parse_documents_from_ft(raw: Any, *, with_embedding: bool) -> list[Document
10271027

10281028
@staticmethod
10291029
def _build_search_query_and_options(
1030-
embedding: list[float], filters: dict[str, Any] | None, limit: int, *, with_embedding: bool
1030+
embedding: list[float], filters: dict[str, Any] | None, limit: int, *, with_embedding: bool
10311031
) -> tuple[str, FtSearchOptions]:
10321032
# Validate and normalize filters
10331033
if filters:

integrations/valkey/tests/test_document_store.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ def test_search_with_meta_score_filter(self, document_store):
586586
assert "score" in doc.meta # User metadata score
587587
assert doc.meta["score"] >= 0.7
588588

589+
589590
class TestValkeyDocumentStoreStaticMethods:
590591
"""Test static methods that were refactored from instance methods."""
591592

@@ -612,7 +613,7 @@ def test_to_float32_bytes(self):
612613
assert len(result) == len(vec) * 4
613614

614615
# Verify correct values by unpacking
615-
unpacked = [struct.unpack("<f", result[i : i + 4])[0] for i in range(0, len(result), 4)]
616+
unpacked = [struct.unpack("<f", result[i: i + 4])[0] for i in range(0, len(result), 4)]
616617
assert unpacked == pytest.approx(vec, rel=1e-6)
617618

618619
def test_verify_node_list_valid(self):
@@ -774,6 +775,7 @@ def test_static_methods_dont_need_instance(self):
774775
ValkeyDocumentStore._validate_documents([Document(id="1", content="test")])
775776
ValkeyDocumentStore._validate_policy(DuplicatePolicy.NONE)
776777

778+
777779
class TestValkeyDocumentStoreConverters:
778780
def test_to_dict(self):
779781
document_store = ValkeyDocumentStore(

0 commit comments

Comments
 (0)