Skip to content

Commit 20375ca

Browse files
authored
chore: code refactor and docs update (#15)
* chore: moved docs from docusaurus to mkdocs * updated change log * code clean up * chore: document update * docs update * fav icon changes * readme update
1 parent a63b842 commit 20375ca

9 files changed

Lines changed: 251 additions & 124 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,21 @@
2121

2222
**Table of Contents**
2323

24+
- [Breaking Changes in Version 2.0.0](#breaking-changes-in-version-200)
2425
- [Overview](#overview)
2526
- [Installation](#installation)
2627
- [Usage](#usage)
2728
- [License](#license)
2829

30+
## Breaking Changes in Version 2.0.0
31+
32+
> **Important Note:**
33+
> In version 2.0.0, the following component names have been changed:
34+
> - `CouchbaseDocumentStore` is now `CouchbaseSearchDocumentStore`
35+
> - `CouchbaseEmbeddingRetriever` is now `CouchbaseSearchEmbeddingRetriever`
36+
>
37+
> Please update your code accordingly if upgrading from an earlier version.
38+
2939
## Overview
3040

3141
An integration of [Couchbase](https://www.couchbase.com) NoSQL database with [Haystack v2.0](https://docs.haystack.deepset.ai/v2.0/docs/intro)

docs/reference/document_stores/auth.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
::: couchbase_haystack.document_stores.auth.CouchbaseCertificateAuthenticator
1717
options:
1818
show_root_heading: false
19-
heading_level: 3
19+
heading_level: 3

docs/reference/document_stores/cluster_options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
::: couchbase_haystack.document_stores.cluster_options.CouchbaseClusterOptions
44
options:
55
show_root_heading: false
6-
heading_level: 2
6+
heading_level: 2

mkdocs.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ nav:
1616
- License: license.md
1717
- Code Reference:
1818
- CouchbaseSearchDocumentStore: reference/document_stores/document_store.md
19-
- Authentication:
20-
- CouchbaseAuthenticator: reference/document_stores/auth.md
21-
- CouchbasePasswordAuthenticator: reference/document_stores/auth.md
22-
- CouchbaseCertificateAuthenticator: reference/document_stores/auth.md
19+
- Authentication: reference/document_stores/auth.md
2320
- CouchbaseClusterOptions: reference/document_stores/cluster_options.md
2421
- Retrievers:
2522
- CouchbaseSearchEmbeddingRetriever: reference/components/retrievers/embedding_retriever.md
@@ -29,6 +26,7 @@ nav:
2926
theme:
3027
name: material
3128
logo: assets/logo.svg
29+
favicon: assets/logo.svg
3230
features:
3331
- navigation.tabs
3432
- navigation.tabs.sticky
@@ -77,7 +75,7 @@ plugins:
7775
- https://docs.python.org/3/objects.inv
7876
- https://mkdocstrings.github.io/objects.inv
7977
- https://mkdocstrings.github.io/griffe/objects.inv
80-
- https://neo4j.com/docs/api/python-driver/current/objects.inv
78+
- https://docs.couchbase.com/sdk-api/couchbase-python-client/objects.inv
8179
options:
8280
docstring_options:
8381
ignore_init_summary: yes

src/couchbase_haystack/components/retrievers/embedding_retriever.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212

1313
@component
1414
class CouchbaseSearchEmbeddingRetriever:
15-
"""
16-
Retrieves documents from the CouchbaseSearchDocumentStore by embedding similarity.
15+
"""Retrieves documents from the CouchbaseSearchDocumentStore by embedding similarity.
1716
1817
The similarity is dependent on the vector_search_index used in the CouchbaseSearchDocumentStore and the chosen metric
1918
during the creation of the index (i.e. dot product, or l2 norm). See CouchbaseSearchDocumentStore for more
@@ -54,8 +53,7 @@ def __init__(
5453
document_store: CouchbaseSearchDocumentStore,
5554
top_k: int = 10,
5655
):
57-
"""
58-
Create the CouchbaseSearchDocumentStore component.
56+
"""Create the CouchbaseSearchDocumentStore component.
5957
6058
Note: Currently, the filter option is not supported with embedding queries.
6159
Instead, you can provide a couchbase search query while running the embedding query.
@@ -76,10 +74,9 @@ def __init__(
7674
self.top_k = top_k
7775

7876
def to_dict(self) -> Dict[str, Any]:
79-
"""
80-
Serializes the component to a dictionary.
77+
"""Serializes the component to a dictionary.
8178
82-
:returns:
79+
Returns:
8380
Dictionary with serialized data.
8481
"""
8582
return default_to_dict(
@@ -90,13 +87,13 @@ def to_dict(self) -> Dict[str, Any]:
9087

9188
@classmethod
9289
def from_dict(cls, data: Dict[str, Any]) -> "CouchbaseSearchDocumentStore":
93-
"""
94-
Deserializes the component from a dictionary.
90+
"""Deserializes the component from a dictionary.
9591
96-
:param data:
97-
Dictionary to deserialize from.
98-
:returns:
99-
Deserialized component.
92+
Args:
93+
data: Dictionary to deserialize from.
94+
95+
Returns:
96+
Deserialized component.
10097
"""
10198
data["init_parameters"]["document_store"] = CouchbaseSearchDocumentStore.from_dict(
10299
data["init_parameters"]["document_store"]
@@ -111,8 +108,7 @@ def run(
111108
search_query: Optional[SearchQuery] = None,
112109
limit: Optional[int] = None,
113110
) -> Dict[str, List[Document]]:
114-
"""
115-
Retrieve documents from the CouchbaseSearchDocumentStore, based on the provided embedding similarity.
111+
"""Retrieve documents from the CouchbaseSearchDocumentStore, based on the provided embedding similarity.
116112
117113
Args:
118114
query_embedding: Embedding of the query.

src/couchbase_haystack/document_stores/auth.py

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ def get_cb_auth(self) -> Union[PasswordAuthenticator, CertificateAuthenticator]:
1212

1313

1414
class CouchbasePasswordAuthenticator(CouchbaseAuthenticator):
15-
"""
15+
"""Password-based authenticator for Couchbase.
16+
1617
Args:
17-
username (str): Username to use for authentication.
18-
password (str): Password to use for authentication.
19-
cert_path (str): Path of the certificate trust store. Defaults to None.
18+
username: Username to use for authentication.
19+
password: Password to use for authentication.
20+
cert_path: Path of the certificate trust store. Defaults to None.
2021
"""
2122

2223
def __init__(
@@ -38,10 +39,9 @@ def get_cb_auth(self) -> PasswordAuthenticator:
3839
return PasswordAuthenticator(self.username.resolve_value(), self.password.resolve_value(), self.cert_path, **self.kwargs)
3940

4041
def to_dict(self) -> Dict[str, Any]:
41-
"""
42-
Serializes the component to a dictionary.
42+
"""Serializes the component to a dictionary.
4343
44-
:returns:
44+
Returns:
4545
Dictionary with serialized data.
4646
"""
4747
return default_to_dict(
@@ -54,26 +54,25 @@ def to_dict(self) -> Dict[str, Any]:
5454

5555
@classmethod
5656
def from_dict(cls, data: Dict[str, Any]) -> "CouchbasePasswordAuthenticator":
57-
"""
58-
Deserializes the component from a dictionary.
57+
"""Deserializes the component from a dictionary.
58+
59+
Args:
60+
data: Dictionary to deserialize from.
5961
60-
:param data:
61-
Dictionary to deserialize from.
62-
:returns:
63-
Deserialized component.
62+
Returns:
63+
Deserialized component.
6464
"""
6565
deserialize_secrets_inplace(data["init_parameters"], keys=["username", "password"])
6666
return default_from_dict(cls, data)
6767

6868

6969
class CouchbaseCertificateAuthenticator(dict):
70-
"""
71-
Certificate-based authenticator for Couchbase.
70+
"""Certificate-based authenticator for Couchbase.
7271
7372
Args:
74-
cert_path (str): Path to the client certificate file. Defaults to None.
75-
key_path (str): Path to the client key file. Defaults to None.
76-
trust_store_path (str): Path to the certificate trust store. Defaults to None.
73+
cert_path: Path to the client certificate file. Defaults to None.
74+
key_path: Path to the client key file. Defaults to None.
75+
trust_store_path: Path to the certificate trust store. Defaults to None.
7776
"""
7877

7978
def __init__(self, cert_path: Optional[str] = None, key_path: Optional[str] = None, trust_store_path: Optional[str] = None):
@@ -91,22 +90,21 @@ def get_cb_auth(self) -> CertificateAuthenticator:
9190
return CertificateAuthenticator(cert_path=self.cert_path, key_path=self.key_path, trust_store_path=self.trust_store_path)
9291

9392
def to_dict(self) -> Dict[str, Any]:
94-
"""
95-
Serializes the component to a dictionary.
93+
"""Serializes the component to a dictionary.
9694
97-
:returns:
95+
Returns:
9896
Dictionary with serialized data.
9997
"""
10098
return default_to_dict(self, cert_path=self.cert_path, key_path=self.key_path, trust_store_path=self.trust_store_path)
10199

102100
@classmethod
103101
def from_dict(cls, data: Dict[str, Any]) -> "CouchbaseCertificateAuthenticator":
104-
"""
105-
Deserializes the component from a dictionary.
102+
"""Deserializes the component from a dictionary.
103+
104+
Args:
105+
data: Dictionary to deserialize from.
106106
107-
:param data:
108-
Dictionary to deserialize from.
109-
:returns:
110-
Deserialized component.
107+
Returns:
108+
Deserialized component.
111109
"""
112110
return default_from_dict(cls, data)

src/couchbase_haystack/document_stores/cluster_options.py

Lines changed: 82 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99

1010
class CouchbaseClusterOptions(dict):
11+
"""ClusterOptions is a dictionary that contains the options for the Couchbase cluster."""
12+
1113
__cluster_level_timedelta_fields: ClassVar[List[str]] = [
1214
"tcp_keep_alive_interval",
1315
"config_poll_interval",
@@ -136,18 +138,87 @@ def __init__(
136138
disable_mozilla_ca_certificates: Optional[bool] = None,
137139
dump_configuration: Optional[bool] = None,
138140
):
139-
"""ClusterOptions instance."""
141+
"""Initialize CouchbaseClusterOptions with explicit parameters.
142+
143+
Args:
144+
profile: The profile to use for the Couchbase cluster. Defaults to None.
145+
bootstrap_timeout: The timeout for the bootstrap operation. Defaults to None.
146+
resolve_timeout: The timeout for the resolve operation. Defaults to None.
147+
connect_timeout: The timeout for the connect operation. Defaults to None.
148+
kv_timeout: The timeout for the KV operation. Defaults to None.
149+
kv_durable_timeout: The timeout for the KV durable operation. Defaults to None.
150+
views_timeout: The timeout for the views operation. Defaults to None.
151+
query_timeout: The timeout for the query operation. Defaults to None.
152+
analytics_timeout: The timeout for the analytics operation. Defaults to None.
153+
search_timeout: The timeout for the search operation. Defaults to None.
154+
management_timeout: The timeout for the management operation. Defaults to None.
155+
dns_srv_timeout: The timeout for the DNS SRV operation. Defaults to None.
156+
idle_http_connection_timeout: The timeout for idle HTTP connections. Defaults to None.
157+
config_idle_redial_timeout: The timeout for idle config redials. Defaults to None.
158+
config_total_timeout: The total timeout for config operations. Defaults to None.
159+
tracing_threshold_kv: The threshold for KV tracing. Defaults to None.
160+
tracing_threshold_view: The threshold for view tracing. Defaults to None.
161+
tracing_threshold_query: The threshold for query tracing. Defaults to None.
162+
tracing_threshold_search: The threshold for search tracing. Defaults to None.
163+
tracing_threshold_analytics: The threshold for analytics tracing. Defaults to None.
164+
tracing_threshold_eventing: The threshold for eventing tracing. Defaults to None.
165+
tracing_threshold_management: The threshold for management tracing. Defaults to None.
166+
tracing_threshold_queue_size: The queue size for tracing threshold. Defaults to None.
167+
tracing_threshold_queue_flush_interval: The interval for tracing threshold queue flushing. Defaults to None.
168+
tracing_orphaned_queue_size: The queue size for tracing orphaned events. Defaults to None.
169+
tracing_orphaned_queue_flush_interval: The interval for tracing orphaned queue flushing. Defaults to None.
170+
enable_tls: Whether to enable TLS. Defaults to None.
171+
enable_mutation_tokens: Whether to enable mutation tokens. Defaults to None.
172+
enable_tcp_keep_alive: Whether to enable TCP keep-alive. Defaults to None.
173+
ip_protocol: The IP protocol to use. Defaults to None.
174+
enable_dns_srv: Whether to enable DNS SRV. Defaults to None.
175+
show_queries: Whether to show queries. Defaults to None.
176+
enable_unordered_execution: Whether to enable unordered execution. Defaults to None.
177+
enable_clustermap_notification: Whether to enable clustermap notification. Defaults to None.
178+
enable_compression: Whether to enable compression. Defaults to None.
179+
enable_tracing: Whether to enable tracing. Defaults to None.
180+
enable_metrics: Whether to enable metrics. Defaults to None.
181+
network: The network to use. Defaults to None.
182+
tls_verify: The TLS verification mode. Defaults to None.
183+
tcp_keep_alive_interval: The interval for TCP keep-alive. Defaults to None.
184+
config_poll_interval: The interval for config polling. Defaults to None.
185+
config_poll_floor: The floor for config polling. Defaults to None.
186+
max_http_connections: The maximum number of HTTP connections. Defaults to None.
187+
user_agent_extra: Extra user agent information. Defaults to None.
188+
logging_meter_emit_interval: The interval for logging meter emission. Defaults to None.
189+
log_redaction: Whether to redact logs. Defaults to None.
190+
compression: The compression to use. Defaults to None.
191+
compression_min_size: The minimum size for compression. Defaults to None.
192+
compression_min_ratio: The minimum ratio for compression. Defaults to None.
193+
dns_nameserver: The DNS nameserver to use. Defaults to None.
194+
dns_port: The DNS port to use. Defaults to None.
195+
disable_mozilla_ca_certificates: Whether to disable Mozilla CA certificates. Defaults to None.
196+
dump_configuration: Whether to dump configuration. Defaults to None.
197+
"""
140198

141199
@overload
142200
def __init__(self, **kwargs):
143-
"""ClusterOptions instance."""
201+
"""Initialize CouchbaseClusterOptions with keyword arguments.
202+
203+
Any parameter accepted by the explicit overload can be passed as a keyword argument.
204+
"""
144205

145206
def __init__(self, **kwargs):
207+
"""Initialize CouchbaseClusterOptions by passing all keyword arguments to the parent dictionary class."""
146208
super().__init__(**kwargs)
147209

148210
def get_cluster_options(
149211
self, auth: Union[CouchbasePasswordAuthenticator, CouchbaseCertificateAuthenticator]
150212
) -> "ClusterOptions":
213+
"""Creates a ClusterOptions object with the provided authenticator.
214+
215+
Args:
216+
auth: The authenticator to use for the Couchbase cluster.
217+
218+
Returns:
219+
A ClusterOptions object configured with the provided authenticator and any other options.
220+
"""
221+
151222
options = list(self.keys())
152223
obj = {}
153224
obj["authenticator"] = auth
@@ -156,13 +227,11 @@ def get_cluster_options(
156227
return ClusterOptions(**obj)
157228

158229
def to_dict(self) -> Dict[str, Any]:
159-
"""
160-
Serializes the component to a dictionary.
230+
"""Serializes the component to a dictionary.
161231
162-
:returns:
232+
Returns:
163233
Dictionary with serialized data.
164234
"""
165-
166235
obj: Dict[str, Any] = {}
167236

168237
# cluster level direct fields includes timeout and trace as they are flattened
@@ -184,14 +253,14 @@ def to_dict(self) -> Dict[str, Any]:
184253
return default_to_dict(self, **obj)
185254

186255
@classmethod
187-
def from_dict(cls, data: Dict[str, Any]) -> "ClusterOptions":
188-
"""
189-
Deserializes the component from a dictionary.
256+
def from_dict(cls, data: Dict[str, Any]) -> "CouchbaseClusterOptions":
257+
"""Deserializes the component from a dictionary.
258+
259+
Args:
260+
data: Dictionary to deserialize from.
190261
191-
:param data:
192-
Dictionary to deserialize from.
193-
:returns:
194-
Deserialized component.
262+
Returns:
263+
Deserialized component.
195264
"""
196265
obj = {}
197266
# cluster level direct fields includes timeout and trace as they are flattened

0 commit comments

Comments
 (0)