Skip to content

Commit ca8cc07

Browse files
committed
code cleanup
1 parent 43c4c2f commit ca8cc07

10 files changed

Lines changed: 55 additions & 55 deletions

File tree

src/couchbase_haystack/document_stores/document_store.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,6 @@ def _embedding_retrieval(
802802
""" # noqa: S608 # query_vector_str is a float array, where_clause is normalized by normalize_sql_filters
803803

804804
try:
805-
806805
query_options = self.query_options.cb_query_options()
807806
# Execute the query
808807
result: QueryResult = self.connection.query(

src/couchbase_haystack/document_stores/search_filters.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def inclusive_start(self) -> Optional[bool]:
2727

2828
@inclusive_start.setter
2929
def inclusive_start(
30-
self, value # type: bool
30+
self,
31+
value, # type: bool
3132
) -> None:
3233
self.set_prop("inclusive_start", value)
3334

@@ -37,7 +38,8 @@ def inclusive_end(self) -> Optional[bool]:
3738

3839
@inclusive_end.setter
3940
def inclusive_end(
40-
self, value # type: bool
41+
self,
42+
value, # type: bool
4143
) -> None:
4244
self.set_prop("inclusive_end", value)
4345

@@ -49,7 +51,8 @@ def inclusive_min(self) -> Optional[bool]:
4951

5052
@inclusive_min.setter
5153
def inclusive_min(
52-
self, value # type: bool
54+
self,
55+
value, # type: bool
5356
) -> None:
5457
self.set_prop("inclusive_min", value)
5558

@@ -59,7 +62,8 @@ def inclusive_max(self) -> Optional[bool]:
5962

6063
@inclusive_max.setter
6164
def inclusive_max(
62-
self, value # type: bool
65+
self,
66+
value, # type: bool
6367
) -> None:
6468
self.set_prop("inclusive_max", value)
6569

tests/common/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ def create_collection_if_not_exists(collection_manager: CollectionManager, scope
4141

4242

4343
def load_json_file(file_path):
44-
with open(file_path, 'r') as file:
44+
with open(file_path, "r") as file:
4545
return json.load(file)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import sys
22

3-
sys.path.insert(0, '../common')
3+
sys.path.insert(0, "../common")

tests/gsi_document_store/test_document_store_integration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from pandas import DataFrame
3030
from uuid import uuid1
3131

32-
model = SentenceTransformer('all-MiniLM-L6-v2')
32+
model = SentenceTransformer("all-MiniLM-L6-v2")
3333

3434
# Test configuration
3535
TEST_BUCKET = os.getenv("BUCKET_NAME")
@@ -218,7 +218,7 @@ def test_write_blob(self, document_store: CouchbaseQueryDocumentStore):
218218
documents = [Document(blob=bytestream)]
219219
for doc in documents:
220220
# Assuming blob_content is in bytes, decode it to string if necessary
221-
embedding = model.encode(bytestream.data.decode('utf-8')).tolist()
221+
embedding = model.encode(bytestream.data.decode("utf-8")).tolist()
222222
doc.embedding = embedding
223223
assert document_store.write_documents(documents) == 1
224224
retrieved_docs = document_store.filter_documents()

tests/gsi_document_store/test_sql_filters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def test_real_world_scenarios(self):
221221

222222
# Compare by normalizing whitespace in both strings
223223
def normalize_whitespace(s):
224-
return ' '.join(s.split())
224+
return " ".join(s.split())
225225

226226
assert normalize_whitespace(actual) == normalize_whitespace(expected)
227227

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import sys
22

3-
sys.path.insert(0, '../common')
3+
sys.path.insert(0, "../common")

tests/search_document_store/test_document_store.py

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from ..common import common
3030

3131

32-
model = SentenceTransformer('all-MiniLM-L6-v2')
32+
model = SentenceTransformer("all-MiniLM-L6-v2")
3333

3434

3535
@patch("couchbase_haystack.document_stores.document_store.Cluster")
@@ -149,7 +149,6 @@ def document_store(self):
149149
cluster.close()
150150

151151
def assert_documents_are_equal(self, received: List[Document], expected: List[Document]):
152-
153152
for r in received:
154153
r.score = None
155154
r.embedding = None
@@ -192,7 +191,7 @@ def test_write_blob(self, document_store: CouchbaseSearchDocumentStore):
192191
documents = [Document(blob=bytestream)]
193192
for doc in documents:
194193
# Assuming blob_content is in bytes, decode it to string if necessary
195-
embedding = model.encode(bytestream.data.decode('utf-8')).tolist()
194+
embedding = model.encode(bytestream.data.decode("utf-8")).tolist()
196195
doc.embedding = embedding
197196
assert document_store.write_documents(documents) == 1
198197
retrieved_docs = document_store.filter_documents()
@@ -283,7 +282,6 @@ class TestSearchDocumentStoreUnit:
283282
@pytest.fixture
284283
def document_store(self):
285284
with patch("couchbase_haystack.document_stores.document_store.Cluster") as mock_cb_cluster:
286-
287285
cluster = mock_cb_cluster.return_value
288286
bucket = cluster.bucket.return_value
289287
scope = bucket.scope.return_value
@@ -310,59 +308,59 @@ def test_to_dict(self, document_store: DocumentStore):
310308
serialized_store = document_store.document_store.to_dict()
311309
# assert serialized_store["init_parameters"].pop("collection_name").startswith("test_collection_")
312310
assert serialized_store == {
313-
'type': 'couchbase_haystack.document_stores.document_store.CouchbaseSearchDocumentStore',
314-
'init_parameters': {
315-
'cluster_connection_string': {'type': 'env_var', 'env_vars': ['CONNECTION_STRING'], 'strict': True},
316-
'authenticator': {
317-
'type': 'couchbase_haystack.document_stores.auth.CouchbasePasswordAuthenticator',
318-
'init_parameters': {
319-
'username': {'type': 'env_var', 'env_vars': ['USER_NAME'], 'strict': True},
320-
'password': {'type': 'env_var', 'env_vars': ['PASSWORD'], 'strict': True},
321-
'cert_path': None,
311+
"type": "couchbase_haystack.document_stores.document_store.CouchbaseSearchDocumentStore",
312+
"init_parameters": {
313+
"cluster_connection_string": {"type": "env_var", "env_vars": ["CONNECTION_STRING"], "strict": True},
314+
"authenticator": {
315+
"type": "couchbase_haystack.document_stores.auth.CouchbasePasswordAuthenticator",
316+
"init_parameters": {
317+
"username": {"type": "env_var", "env_vars": ["USER_NAME"], "strict": True},
318+
"password": {"type": "env_var", "env_vars": ["PASSWORD"], "strict": True},
319+
"cert_path": None,
322320
},
323321
},
324-
'cluster_options': {
325-
'type': 'couchbase_haystack.document_stores.cluster_options.CouchbaseClusterOptions',
326-
'init_parameters': {'profile': 'wan_development'},
322+
"cluster_options": {
323+
"type": "couchbase_haystack.document_stores.cluster_options.CouchbaseClusterOptions",
324+
"init_parameters": {"profile": "wan_development"},
327325
},
328-
'bucket': 'test_bucket',
329-
'scope': 'test_scope',
330-
'collection': 'test_collection',
331-
'vector_search_index': 'vector_search',
332-
'is_global_level_index': IS_GLOBAL_LEVEL_INDEX,
326+
"bucket": "test_bucket",
327+
"scope": "test_scope",
328+
"collection": "test_collection",
329+
"vector_search_index": "vector_search",
330+
"is_global_level_index": IS_GLOBAL_LEVEL_INDEX,
333331
},
334332
}
335333

336334
def test_from_dict(self):
337335
docstore = CouchbaseSearchDocumentStore.from_dict(
338336
{
339-
'type': 'couchbase_haystack.document_stores.document_store.CouchbaseSearchDocumentStore',
340-
'init_parameters': {
341-
'cluster_connection_string': {'type': 'env_var', 'env_vars': ['CONNECTION_STRING'], 'strict': True},
342-
'authenticator': {
343-
'type': 'couchbase_haystack.document_stores.auth.CouchbasePasswordAuthenticator',
344-
'init_parameters': {
345-
'username': {'type': 'env_var', 'env_vars': ['USER_NAME'], 'strict': True},
346-
'password': {'type': 'env_var', 'env_vars': ['PASSWORD'], 'strict': True},
347-
'cert_path': None,
337+
"type": "couchbase_haystack.document_stores.document_store.CouchbaseSearchDocumentStore",
338+
"init_parameters": {
339+
"cluster_connection_string": {"type": "env_var", "env_vars": ["CONNECTION_STRING"], "strict": True},
340+
"authenticator": {
341+
"type": "couchbase_haystack.document_stores.auth.CouchbasePasswordAuthenticator",
342+
"init_parameters": {
343+
"username": {"type": "env_var", "env_vars": ["USER_NAME"], "strict": True},
344+
"password": {"type": "env_var", "env_vars": ["PASSWORD"], "strict": True},
345+
"cert_path": None,
348346
},
349347
},
350-
'cluster_options': {
351-
'type': 'couchbase_haystack.document_stores.cluster_options.CouchbaseClusterOptions',
352-
'init_parameters': {'profile': 'wan_development'},
348+
"cluster_options": {
349+
"type": "couchbase_haystack.document_stores.cluster_options.CouchbaseClusterOptions",
350+
"init_parameters": {"profile": "wan_development"},
353351
},
354-
'bucket': 'test_bucket',
355-
'scope': 'test_scope',
356-
'collection': 'test_collection',
357-
'vector_search_index': 'vector_search',
358-
'is_global_level_index': IS_GLOBAL_LEVEL_INDEX,
352+
"bucket": "test_bucket",
353+
"scope": "test_scope",
354+
"collection": "test_collection",
355+
"vector_search_index": "vector_search",
356+
"is_global_level_index": IS_GLOBAL_LEVEL_INDEX,
359357
},
360358
}
361359
)
362360
assert docstore.cluster_connection_string == Secret.from_env_var("CONNECTION_STRING")
363-
assert docstore.bucket_name == 'test_bucket'
364-
assert docstore.scope_name == 'test_scope'
365-
assert docstore.collection_name == 'test_collection'
361+
assert docstore.bucket_name == "test_bucket"
362+
assert docstore.scope_name == "test_scope"
363+
assert docstore.collection_name == "test_collection"
366364
assert docstore.vector_search_index == "vector_search"
367365
assert docstore.cluster_options["profile"] == KnownConfigProfiles.WanDevelopment
368366
assert docstore.is_global_level_index == IS_GLOBAL_LEVEL_INDEX
@@ -383,6 +381,6 @@ def test_init_default(self, document_store: DocumentStore, monkeypatch):
383381
if IS_GLOBAL_LEVEL_INDEX:
384382
document_store.cluster.search.assert_called_once()
385383
else:
386-
document_store.cluster.bucket.return_value.scope.assert_called_once_with('test_scope')
384+
document_store.cluster.bucket.return_value.scope.assert_called_once_with("test_scope")
387385
document_store.cluster.bucket.return_value.scope.return_value.search.assert_called_once()
388386
assert doc == [Document(id="1a", content="text", score=1)]

tests/search_document_store/test_retriever.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_to_dict(self, doc_store: MagicMock):
6262
"scope": "test_scope",
6363
"collection": "test_collection",
6464
"vector_search_index": "vector_search",
65-
'is_global_level_index': IS_GLOBAL_LEVEL_INDEX,
65+
"is_global_level_index": IS_GLOBAL_LEVEL_INDEX,
6666
},
6767
},
6868
},

tests/search_document_store/test_search_filter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ def test_filter_lt_condition_array_of_number(self):
216216

217217
@pytest.mark.unit
218218
class TestFilterLTE:
219-
220219
# def test_filter_gt_condition_str(self):
221220
# _filter = {"field": "meta.years", "operator": "==", "value": "2019"}
222221
# normalized_filter = _normalize_filters(_filter)

0 commit comments

Comments
 (0)