weaviate-haystack 8.0.0__tar.gz → 8.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/CHANGELOG.md +28 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/PKG-INFO +1 -1
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/docker-compose.yml +1 -1
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/src/haystack_integrations/document_stores/weaviate/document_store.py +87 -15
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/tests/test_bm25_retriever.py +3 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/tests/test_document_store.py +173 -2
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/tests/test_document_store_async.py +16 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/tests/test_embedding_retriever.py +3 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/tests/test_hybrid_retriever.py +4 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/.gitignore +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/LICENSE.txt +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/README.md +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/pydoc/config_docusaurus.yml +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/pyproject.toml +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/src/haystack_integrations/components/retrievers/py.typed +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/src/haystack_integrations/components/retrievers/weaviate/__init__.py +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/src/haystack_integrations/components/retrievers/weaviate/bm25_retriever.py +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/src/haystack_integrations/components/retrievers/weaviate/embedding_retriever.py +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/src/haystack_integrations/components/retrievers/weaviate/hybrid_retriever.py +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/src/haystack_integrations/document_stores/py.typed +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/src/haystack_integrations/document_stores/weaviate/__init__.py +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/src/haystack_integrations/document_stores/weaviate/_filters.py +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/src/haystack_integrations/document_stores/weaviate/auth.py +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/tests/__init__.py +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/tests/conftest.py +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/tests/test_auth.py +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/tests/test_bm25_retriever_async.py +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/tests/test_embedding_retriever_async.py +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/tests/test_files/robot1.jpg +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/tests/test_filters.py +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/tests/test_hybrid_retriever_async.py +0 -0
- {weaviate_haystack-8.0.0 → weaviate_haystack-8.1.0}/tests/test_retrieval.py +0 -0
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [integrations/weaviate-v8.0.1] - 2026-11-04
|
|
4
|
+
|
|
5
|
+
### 🐛 Bug Fixes
|
|
6
|
+
|
|
7
|
+
- *(weaviate)* Drop multivector_embedding when writing documents (#4192)
|
|
8
|
+
|
|
9
|
+
### 🧹 Chores
|
|
10
|
+
|
|
11
|
+
- Bump Weaviate test server to 1.39.13 (#4144)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [integrations/weaviate-v8.0.0] - 2026-10-16
|
|
15
|
+
|
|
16
|
+
### 🐛 Bug Fixes
|
|
17
|
+
|
|
18
|
+
- Honor explicit zero distance/certainty, raise FilterError for unknown operators, and use Weaviate's native NOT for negating contains operator (#3957)
|
|
19
|
+
|
|
20
|
+
### 🧪 Testing
|
|
21
|
+
|
|
22
|
+
- Cover Weaviate filters, retriever components and pipeline serde (#3958)
|
|
23
|
+
- Run Weaviate serde and conversion tests in the unit job (#3955)
|
|
24
|
+
|
|
25
|
+
### 🧹 Chores
|
|
26
|
+
|
|
27
|
+
- Alias datetime imports as dt for ruff 0.17 ICN001 (#4088)
|
|
28
|
+
- [**breaking**] Drop Python 3.10 support (#4105)
|
|
29
|
+
|
|
30
|
+
|
|
3
31
|
## [integrations/weaviate-v7.9.0] - 2026-09-21
|
|
4
32
|
|
|
5
33
|
### 🚀 Features
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: weaviate-haystack
|
|
3
|
-
Version: 8.
|
|
3
|
+
Version: 8.1.0
|
|
4
4
|
Summary: An integration of Weaviate vector database with Haystack
|
|
5
5
|
Project-URL: Source, https://github.com/deepset-ai/haystack-core-integrations
|
|
6
6
|
Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/weaviate/README.md
|
|
@@ -9,6 +9,7 @@ import json
|
|
|
9
9
|
from contextlib import suppress
|
|
10
10
|
from dataclasses import asdict
|
|
11
11
|
from typing import Any, NoReturn
|
|
12
|
+
from urllib.parse import urlparse
|
|
12
13
|
|
|
13
14
|
from haystack import logging
|
|
14
15
|
from haystack.core.serialization import default_from_dict, default_to_dict
|
|
@@ -119,6 +120,20 @@ class WeaviateDocumentStore:
|
|
|
119
120
|
|
|
120
121
|
document_store = WeaviateDocumentStore(url="http://localhost:8080")
|
|
121
122
|
```
|
|
123
|
+
|
|
124
|
+
Usage example with REST and gRPC served on different hosts:
|
|
125
|
+
```python
|
|
126
|
+
from haystack_integrations.document_stores.weaviate.document_store import (
|
|
127
|
+
WeaviateDocumentStore,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
document_store = WeaviateDocumentStore(
|
|
131
|
+
url="https://weaviate.example.com",
|
|
132
|
+
grpc_host="weaviate.grpc.example.com",
|
|
133
|
+
grpc_port=443,
|
|
134
|
+
grpc_secure=True,
|
|
135
|
+
)
|
|
136
|
+
```
|
|
122
137
|
"""
|
|
123
138
|
|
|
124
139
|
def __init__(
|
|
@@ -130,6 +145,7 @@ class WeaviateDocumentStore:
|
|
|
130
145
|
additional_headers: dict | None = None,
|
|
131
146
|
embedded_options: EmbeddedOptions | None = None,
|
|
132
147
|
additional_config: AdditionalConfig | None = None,
|
|
148
|
+
grpc_host: str | None = None,
|
|
133
149
|
grpc_port: int = 50051,
|
|
134
150
|
grpc_secure: bool = False,
|
|
135
151
|
) -> None:
|
|
@@ -174,18 +190,33 @@ class WeaviateDocumentStore:
|
|
|
174
190
|
`weaviate.embedded.EmbeddedOptions`.
|
|
175
191
|
:param additional_config:
|
|
176
192
|
Additional and advanced configuration options for weaviate.
|
|
193
|
+
:param grpc_host:
|
|
194
|
+
The host serving the gRPC API, when it differs from the one in `url`. If `None`, the gRPC
|
|
195
|
+
connection reuses the host parsed from `url`. Only used for custom, local or Docker
|
|
196
|
+
deployments: it is ignored, with a warning, when `url` is not set and for Weaviate Cloud URLs,
|
|
197
|
+
which `weaviate.connect_to_weaviate_cloud` configures on its own.
|
|
198
|
+
Setting it also changes how `grpc_secure` is interpreted, see below.
|
|
177
199
|
:param grpc_port:
|
|
178
200
|
The port to use for the gRPC connection.
|
|
179
201
|
:param grpc_secure:
|
|
180
|
-
Whether to use a secure channel for the underlying gRPC API.
|
|
202
|
+
Whether to use a secure channel for the underlying gRPC API. Without `grpc_host` an `https`
|
|
203
|
+
`url` implies a secure gRPC channel even when this is `False`, because both protocols then
|
|
204
|
+
share a host. With `grpc_host` set, the two endpoints are independent and this flag alone
|
|
205
|
+
decides whether the gRPC channel uses TLS.
|
|
181
206
|
"""
|
|
182
207
|
self._url = url
|
|
183
208
|
self._auth_client_secret = auth_client_secret
|
|
184
209
|
self._additional_headers = additional_headers
|
|
185
210
|
self._embedded_options = embedded_options
|
|
186
211
|
self._additional_config = additional_config
|
|
212
|
+
self._grpc_host = grpc_host
|
|
187
213
|
self._grpc_port = grpc_port
|
|
188
214
|
self._grpc_secure = grpc_secure
|
|
215
|
+
if grpc_host and (not url or url.endswith((".weaviate.network", ".weaviate.cloud"))):
|
|
216
|
+
logger.warning(
|
|
217
|
+
"`grpc_host` is ignored when `url` is not set or points to Weaviate Cloud. Got grpc_host={grpc_host}.",
|
|
218
|
+
grpc_host=grpc_host,
|
|
219
|
+
)
|
|
189
220
|
self._client: weaviate.WeaviateClient | None = None
|
|
190
221
|
self._async_client: weaviate.WeaviateAsyncClient | None = None
|
|
191
222
|
self._collection: weaviate.Collection | None = None
|
|
@@ -208,6 +239,50 @@ class WeaviateDocumentStore:
|
|
|
208
239
|
"properties", DOCUMENT_COLLECTION_PROPERTIES
|
|
209
240
|
)
|
|
210
241
|
|
|
242
|
+
def _connection_params(self) -> weaviate.connect.base.ConnectionParams | None:
|
|
243
|
+
"""
|
|
244
|
+
Build the connection parameters for a custom, local or Docker deployment.
|
|
245
|
+
|
|
246
|
+
Returns `None` if no `url` is set, so that the client falls back to `embedded_options`.
|
|
247
|
+
|
|
248
|
+
:raises ValueError:
|
|
249
|
+
If `url` has a scheme other than `http` or `https`, or no host can be parsed from it.
|
|
250
|
+
"""
|
|
251
|
+
if not self._url:
|
|
252
|
+
return None
|
|
253
|
+
|
|
254
|
+
if not self._grpc_host:
|
|
255
|
+
# `from_url` derives the gRPC host from `url`, which is what we want here.
|
|
256
|
+
return weaviate.connect.base.ConnectionParams.from_url(
|
|
257
|
+
url=self._url, grpc_port=self._grpc_port, grpc_secure=self._grpc_secure
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
# `from_url` cannot express a separate gRPC host: it reuses the host from `url` for gRPC, and
|
|
261
|
+
# `ConnectionParams` then refuses that pair when the two ports also match. That is exactly the
|
|
262
|
+
# ingress setup `grpc_host` exists for, with REST and gRPC both published on 443, so the HTTP
|
|
263
|
+
# side is derived here by the same rules `from_url` applies and both sides are passed
|
|
264
|
+
# explicitly. `from_params` runs the same collision check, so a genuine same-host/same-port
|
|
265
|
+
# misconfiguration still fails.
|
|
266
|
+
parsed_url = urlparse(self._url)
|
|
267
|
+
if parsed_url.scheme not in ("http", "https"):
|
|
268
|
+
msg = f"Unsupported scheme: {parsed_url.scheme}"
|
|
269
|
+
raise ValueError(msg)
|
|
270
|
+
if parsed_url.hostname is None:
|
|
271
|
+
msg = f"Could not parse a host out of url: {self._url}"
|
|
272
|
+
raise ValueError(msg)
|
|
273
|
+
http_secure = parsed_url.scheme == "https"
|
|
274
|
+
return weaviate.connect.base.ConnectionParams.from_params(
|
|
275
|
+
http_host=parsed_url.hostname,
|
|
276
|
+
http_port=parsed_url.port if parsed_url.port is not None else (443 if http_secure else 80),
|
|
277
|
+
http_secure=http_secure,
|
|
278
|
+
grpc_host=self._grpc_host,
|
|
279
|
+
grpc_port=self._grpc_port,
|
|
280
|
+
# Unlike `from_url`, the scheme of `url` says nothing about the gRPC endpoint here: it is a
|
|
281
|
+
# different host, so it can terminate TLS independently. `grpc_secure` is therefore taken
|
|
282
|
+
# literally, as `from_params` and `weaviate.connect_to_custom` both require it to be.
|
|
283
|
+
grpc_secure=self._grpc_secure,
|
|
284
|
+
)
|
|
285
|
+
|
|
211
286
|
def _connection_headers(self) -> dict[str, Any]:
|
|
212
287
|
"""
|
|
213
288
|
Builds the headers passed to the Weaviate client.
|
|
@@ -252,13 +327,7 @@ class WeaviateDocumentStore:
|
|
|
252
327
|
# proxies, timeout_config, trust_env are part of additional_config now
|
|
253
328
|
# startup_period has been removed
|
|
254
329
|
self._client = weaviate.WeaviateClient(
|
|
255
|
-
connection_params=(
|
|
256
|
-
weaviate.connect.base.ConnectionParams.from_url(
|
|
257
|
-
url=self._url, grpc_port=self._grpc_port, grpc_secure=self._grpc_secure
|
|
258
|
-
)
|
|
259
|
-
if self._url
|
|
260
|
-
else None
|
|
261
|
-
),
|
|
330
|
+
connection_params=self._connection_params(),
|
|
262
331
|
auth_client_secret=self._auth_client_secret.resolve_value() if self._auth_client_secret else None,
|
|
263
332
|
additional_config=self._additional_config,
|
|
264
333
|
additional_headers=self._connection_headers(),
|
|
@@ -297,13 +366,7 @@ class WeaviateDocumentStore:
|
|
|
297
366
|
# proxies, timeout_config, trust_env are part of additional_config now
|
|
298
367
|
# startup_period has been removed
|
|
299
368
|
self._async_client = weaviate.WeaviateAsyncClient(
|
|
300
|
-
connection_params=(
|
|
301
|
-
weaviate.connect.base.ConnectionParams.from_url(
|
|
302
|
-
url=self._url, grpc_port=self._grpc_port, grpc_secure=self._grpc_secure
|
|
303
|
-
)
|
|
304
|
-
if self._url
|
|
305
|
-
else None
|
|
306
|
-
),
|
|
369
|
+
connection_params=self._connection_params(),
|
|
307
370
|
auth_client_secret=self._auth_client_secret.resolve_value() if self._auth_client_secret else None,
|
|
308
371
|
additional_config=self._additional_config,
|
|
309
372
|
additional_headers=self._connection_headers(),
|
|
@@ -373,6 +436,7 @@ class WeaviateDocumentStore:
|
|
|
373
436
|
return default_to_dict(
|
|
374
437
|
self,
|
|
375
438
|
url=self._url,
|
|
439
|
+
grpc_host=self._grpc_host,
|
|
376
440
|
grpc_port=self._grpc_port,
|
|
377
441
|
grpc_secure=self._grpc_secure,
|
|
378
442
|
collection_settings=self._collection_settings,
|
|
@@ -849,6 +913,14 @@ class WeaviateDocumentStore:
|
|
|
849
913
|
id=data["_original_id"],
|
|
850
914
|
)
|
|
851
915
|
|
|
916
|
+
if data.pop("multivector_embedding", None):
|
|
917
|
+
logger.warning(
|
|
918
|
+
"Document {id} has the `multivector_embedding` field set, "
|
|
919
|
+
"but storing multivector embeddings in Weaviate is not currently supported. "
|
|
920
|
+
"The `multivector_embedding` field will be ignored.",
|
|
921
|
+
id=data["_original_id"],
|
|
922
|
+
)
|
|
923
|
+
|
|
852
924
|
return data
|
|
853
925
|
|
|
854
926
|
@staticmethod
|
|
@@ -51,6 +51,7 @@ def test_to_dict(_mock_weaviate):
|
|
|
51
51
|
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
|
|
52
52
|
"init_parameters": {
|
|
53
53
|
"url": None,
|
|
54
|
+
"grpc_host": None,
|
|
54
55
|
"grpc_port": 50051,
|
|
55
56
|
"grpc_secure": False,
|
|
56
57
|
"collection_settings": {
|
|
@@ -87,6 +88,7 @@ def test_from_dict(_mock_weaviate):
|
|
|
87
88
|
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
|
|
88
89
|
"init_parameters": {
|
|
89
90
|
"url": None,
|
|
91
|
+
"grpc_host": None,
|
|
90
92
|
"grpc_port": 50051,
|
|
91
93
|
"grpc_secure": False,
|
|
92
94
|
"collection_settings": {
|
|
@@ -126,6 +128,7 @@ def test_from_dict_no_filter_policy(_mock_weaviate):
|
|
|
126
128
|
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
|
|
127
129
|
"init_parameters": {
|
|
128
130
|
"url": None,
|
|
131
|
+
"grpc_host": None,
|
|
129
132
|
"grpc_port": 50051,
|
|
130
133
|
"grpc_secure": False,
|
|
131
134
|
"collection_settings": {
|
|
@@ -32,6 +32,7 @@ from numpy import array_equal as np_array_equal
|
|
|
32
32
|
from numpy import float32 as np_float32
|
|
33
33
|
from weaviate.collections.classes.data import DataObject
|
|
34
34
|
from weaviate.config import AdditionalConfig, ConnectionConfig, Proxies, Timeout
|
|
35
|
+
from weaviate.connect import ConnectionParams, ProtocolParams
|
|
35
36
|
from weaviate.embedded import (
|
|
36
37
|
DEFAULT_BINARY_PATH,
|
|
37
38
|
DEFAULT_GRPC_PORT,
|
|
@@ -185,6 +186,157 @@ def test_integration_header_is_not_serialized():
|
|
|
185
186
|
assert ds.to_dict()["init_parameters"]["additional_headers"] == {"X-HuggingFace-Api-Key": "k"}
|
|
186
187
|
|
|
187
188
|
|
|
189
|
+
@patch("haystack_integrations.document_stores.weaviate.document_store.weaviate.WeaviateClient")
|
|
190
|
+
def test_client_grpc_host_defaults_to_url_host(mock_weaviate_client_class):
|
|
191
|
+
"""Without `grpc_host` the connection params must stay exactly the ones `ConnectionParams.from_url`
|
|
192
|
+
builds, so existing deployments keep pointing gRPC at the host parsed from `url`."""
|
|
193
|
+
mock_client = MagicMock()
|
|
194
|
+
mock_client.collections.exists.return_value = True
|
|
195
|
+
mock_weaviate_client_class.return_value = mock_client
|
|
196
|
+
|
|
197
|
+
ds = WeaviateDocumentStore(url="https://weaviate.example.com", grpc_port=50052, grpc_secure=True)
|
|
198
|
+
assert ds.client is mock_client
|
|
199
|
+
|
|
200
|
+
_args, kwargs = mock_weaviate_client_class.call_args
|
|
201
|
+
assert kwargs["connection_params"] == ConnectionParams.from_url(
|
|
202
|
+
url="https://weaviate.example.com", grpc_port=50052, grpc_secure=True
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
@patch("haystack_integrations.document_stores.weaviate.document_store.weaviate.WeaviateClient")
|
|
207
|
+
def test_client_uses_separate_grpc_host(mock_weaviate_client_class):
|
|
208
|
+
"""A Weaviate deployment can publish REST and gRPC on different hosts, typically behind an ingress
|
|
209
|
+
that terminates TLS for both on port 443. `ConnectionParams` rejects that shape unless the gRPC host
|
|
210
|
+
differs from the REST one, so `grpc_host` is the only way to express it."""
|
|
211
|
+
mock_client = MagicMock()
|
|
212
|
+
mock_client.collections.exists.return_value = True
|
|
213
|
+
mock_weaviate_client_class.return_value = mock_client
|
|
214
|
+
|
|
215
|
+
ds = WeaviateDocumentStore(
|
|
216
|
+
url="https://weaviate.example.com",
|
|
217
|
+
grpc_host="weaviate.grpc.example.com",
|
|
218
|
+
grpc_port=443,
|
|
219
|
+
grpc_secure=True,
|
|
220
|
+
)
|
|
221
|
+
assert ds.client is mock_client
|
|
222
|
+
|
|
223
|
+
_args, kwargs = mock_weaviate_client_class.call_args
|
|
224
|
+
connection_params = kwargs["connection_params"]
|
|
225
|
+
assert connection_params.http == ProtocolParams(host="weaviate.example.com", port=443, secure=True)
|
|
226
|
+
assert connection_params.grpc == ProtocolParams(host="weaviate.grpc.example.com", port=443, secure=True)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
@pytest.mark.asyncio
|
|
230
|
+
@patch("haystack_integrations.document_stores.weaviate.document_store.weaviate.WeaviateAsyncClient")
|
|
231
|
+
async def test_async_client_grpc_host_defaults_to_url_host(mock_weaviate_async_client_class):
|
|
232
|
+
mock_client = MagicMock()
|
|
233
|
+
mock_client.connect = AsyncMock()
|
|
234
|
+
mock_client.collections.exists = AsyncMock(return_value=True)
|
|
235
|
+
mock_weaviate_async_client_class.return_value = mock_client
|
|
236
|
+
|
|
237
|
+
ds = WeaviateDocumentStore(url="https://weaviate.example.com", grpc_port=50052, grpc_secure=True)
|
|
238
|
+
assert await ds.async_client is mock_client
|
|
239
|
+
|
|
240
|
+
_args, kwargs = mock_weaviate_async_client_class.call_args
|
|
241
|
+
assert kwargs["connection_params"] == ConnectionParams.from_url(
|
|
242
|
+
url="https://weaviate.example.com", grpc_port=50052, grpc_secure=True
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
@pytest.mark.asyncio
|
|
247
|
+
@patch("haystack_integrations.document_stores.weaviate.document_store.weaviate.WeaviateAsyncClient")
|
|
248
|
+
async def test_async_client_uses_separate_grpc_host(mock_weaviate_async_client_class):
|
|
249
|
+
mock_client = MagicMock()
|
|
250
|
+
mock_client.connect = AsyncMock()
|
|
251
|
+
mock_client.collections.exists = AsyncMock(return_value=True)
|
|
252
|
+
mock_weaviate_async_client_class.return_value = mock_client
|
|
253
|
+
|
|
254
|
+
ds = WeaviateDocumentStore(
|
|
255
|
+
url="https://weaviate.example.com",
|
|
256
|
+
grpc_host="weaviate.grpc.example.com",
|
|
257
|
+
grpc_port=443,
|
|
258
|
+
grpc_secure=True,
|
|
259
|
+
)
|
|
260
|
+
assert await ds.async_client is mock_client
|
|
261
|
+
|
|
262
|
+
_args, kwargs = mock_weaviate_async_client_class.call_args
|
|
263
|
+
connection_params = kwargs["connection_params"]
|
|
264
|
+
assert connection_params.http == ProtocolParams(host="weaviate.example.com", port=443, secure=True)
|
|
265
|
+
assert connection_params.grpc == ProtocolParams(host="weaviate.grpc.example.com", port=443, secure=True)
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
@pytest.mark.parametrize("grpc_secure", [False, True])
|
|
269
|
+
@pytest.mark.parametrize(
|
|
270
|
+
"url",
|
|
271
|
+
["http://localhost:8080", "http://weaviate.example.com", "https://weaviate.example.com", "https://h.example:9443"],
|
|
272
|
+
)
|
|
273
|
+
def test_connection_params_with_grpc_host_derives_http_params_like_from_url(url, grpc_secure):
|
|
274
|
+
"""`grpc_host` cannot go through `ConnectionParams.from_url`, so the HTTP side is derived by hand.
|
|
275
|
+
That derivation must keep matching `from_url` and leave the gRPC port alone."""
|
|
276
|
+
expected = ConnectionParams.from_url(url=url, grpc_port=50051, grpc_secure=grpc_secure)
|
|
277
|
+
|
|
278
|
+
connection_params = WeaviateDocumentStore(
|
|
279
|
+
url=url,
|
|
280
|
+
grpc_host="weaviate.grpc.example.com",
|
|
281
|
+
grpc_port=50051,
|
|
282
|
+
grpc_secure=grpc_secure,
|
|
283
|
+
)._connection_params()
|
|
284
|
+
|
|
285
|
+
assert connection_params.http == expected.http
|
|
286
|
+
assert connection_params.grpc == ProtocolParams(host="weaviate.grpc.example.com", port=50051, secure=grpc_secure)
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def test_grpc_secure_is_not_inherited_from_the_url_scheme():
|
|
290
|
+
"""`from_url` upgrades the gRPC channel to TLS for an `https` url because both protocols then share
|
|
291
|
+
a host. A separate `grpc_host` is a separate endpoint that terminates TLS on its own, so there
|
|
292
|
+
`grpc_secure` is taken at face value, because otherwise an https REST ingress in front of a
|
|
293
|
+
plaintext internal gRPC service could not be configured at all."""
|
|
294
|
+
url = "https://weaviate.example.com"
|
|
295
|
+
|
|
296
|
+
inherited = WeaviateDocumentStore(url=url, grpc_secure=False)._connection_params()
|
|
297
|
+
assert inherited.grpc.secure is True
|
|
298
|
+
|
|
299
|
+
independent = WeaviateDocumentStore(url=url, grpc_host="weaviate-grpc.internal", grpc_secure=False)
|
|
300
|
+
connection_params = independent._connection_params()
|
|
301
|
+
assert connection_params.http.secure is True
|
|
302
|
+
assert connection_params.grpc == ProtocolParams(host="weaviate-grpc.internal", port=50051, secure=False)
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
def test_connection_params_ignore_grpc_host_when_it_cannot_apply():
|
|
306
|
+
"""`grpc_host` only means something next to a `url`, and an empty value means unset just as it does
|
|
307
|
+
for `url` itself. Without a `url` the client falls back to `embedded_options`, so there are no
|
|
308
|
+
connection params at all."""
|
|
309
|
+
assert WeaviateDocumentStore(grpc_host="weaviate.grpc.example.com")._connection_params() is None
|
|
310
|
+
|
|
311
|
+
expected = ConnectionParams.from_url(url="http://localhost:8080", grpc_port=50051)
|
|
312
|
+
assert WeaviateDocumentStore(url="http://localhost:8080", grpc_host="")._connection_params() == expected
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
@pytest.mark.parametrize(
|
|
316
|
+
("url", "warns"),
|
|
317
|
+
[
|
|
318
|
+
(None, True),
|
|
319
|
+
("https://rAnD0mD1g1t5.something.weaviate.cloud", True),
|
|
320
|
+
("https://my-cluster.weaviate.network", True),
|
|
321
|
+
("https://weaviate.example.com", False),
|
|
322
|
+
],
|
|
323
|
+
)
|
|
324
|
+
def test_init_warns_when_grpc_host_is_ignored(caplog, url, warns):
|
|
325
|
+
with caplog.at_level(logging.WARNING):
|
|
326
|
+
WeaviateDocumentStore(url=url, grpc_host="weaviate.grpc.example.com")
|
|
327
|
+
assert ("`grpc_host` is ignored" in caplog.text) is warns
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
@pytest.mark.parametrize(
|
|
331
|
+
("url", "error"),
|
|
332
|
+
[("weaviate.example.com", "Unsupported scheme"), ("http://", "Could not parse a host")],
|
|
333
|
+
)
|
|
334
|
+
def test_connection_params_with_grpc_host_rejects_unusable_url(url, error):
|
|
335
|
+
ds = WeaviateDocumentStore(url=url, grpc_host="weaviate.grpc.example.com")
|
|
336
|
+
with pytest.raises(ValueError, match=error):
|
|
337
|
+
ds._connection_params()
|
|
338
|
+
|
|
339
|
+
|
|
188
340
|
def test_to_data_object_with_sparse_embedding_logs_warning(caplog):
|
|
189
341
|
doc = Document(content="test doc")
|
|
190
342
|
doc_dict = doc.to_dict()
|
|
@@ -383,6 +535,7 @@ class TestWeaviateDocumentStoreSerde:
|
|
|
383
535
|
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
|
|
384
536
|
"init_parameters": {
|
|
385
537
|
"url": "http://localhost:8080",
|
|
538
|
+
"grpc_host": None,
|
|
386
539
|
"grpc_port": 50051,
|
|
387
540
|
"grpc_secure": False,
|
|
388
541
|
"collection_settings": {
|
|
@@ -429,20 +582,23 @@ class TestWeaviateDocumentStoreSerde:
|
|
|
429
582
|
|
|
430
583
|
@patch("haystack_integrations.document_stores.weaviate.document_store.weaviate")
|
|
431
584
|
def test_to_dict_and_from_dict_preserves_grpc_settings(self, _mock_weaviate):
|
|
432
|
-
"""`grpc_port`/`grpc_secure` configure the gRPC connection and must
|
|
585
|
+
"""`grpc_host`/`grpc_port`/`grpc_secure` configure the gRPC connection and must
|
|
433
586
|
survive a to_dict/from_dict round-trip; otherwise a reloaded store
|
|
434
|
-
silently falls back to the default gRPC port/security."""
|
|
587
|
+
silently falls back to the default gRPC host/port/security."""
|
|
435
588
|
document_store = WeaviateDocumentStore(
|
|
436
589
|
url="http://localhost:8080",
|
|
590
|
+
grpc_host="weaviate.grpc.example.com",
|
|
437
591
|
grpc_port=50052,
|
|
438
592
|
grpc_secure=True,
|
|
439
593
|
)
|
|
440
594
|
|
|
441
595
|
serialized = document_store.to_dict()
|
|
596
|
+
assert serialized["init_parameters"]["grpc_host"] == "weaviate.grpc.example.com"
|
|
442
597
|
assert serialized["init_parameters"]["grpc_port"] == 50052
|
|
443
598
|
assert serialized["init_parameters"]["grpc_secure"] is True
|
|
444
599
|
|
|
445
600
|
restored = WeaviateDocumentStore.from_dict(serialized)
|
|
601
|
+
assert restored._grpc_host == "weaviate.grpc.example.com"
|
|
446
602
|
assert restored._grpc_port == 50052
|
|
447
603
|
assert restored._grpc_secure is True
|
|
448
604
|
|
|
@@ -664,6 +820,21 @@ class TestWeaviateDocumentStore(
|
|
|
664
820
|
|
|
665
821
|
assert document_store.count_documents() == 0
|
|
666
822
|
|
|
823
|
+
def test_separate_grpc_host(self, request):
|
|
824
|
+
# `localhost` and `127.0.0.1` are different host strings for the same container, which is enough to
|
|
825
|
+
# exercise the `grpc_host` path; writes and filters go over gRPC, so they prove the channel works.
|
|
826
|
+
collection_settings = {"class": request.node.name, "invertedIndexConfig": {"indexNullState": True}}
|
|
827
|
+
store = WeaviateDocumentStore(
|
|
828
|
+
url="http://localhost:8080", grpc_host="127.0.0.1", collection_settings=collection_settings
|
|
829
|
+
)
|
|
830
|
+
try:
|
|
831
|
+
assert store._connection_params().grpc.host == "127.0.0.1"
|
|
832
|
+
assert store.write_documents([Document(content="hello grpc")]) == 1
|
|
833
|
+
assert [doc.content for doc in store.filter_documents()] == ["hello grpc"]
|
|
834
|
+
finally:
|
|
835
|
+
store.client.collections.delete(collection_settings["class"])
|
|
836
|
+
store.close()
|
|
837
|
+
|
|
667
838
|
def test_write_documents(self, document_store):
|
|
668
839
|
"""
|
|
669
840
|
Test write_documents() with default policy overwrites existing documents.
|
|
@@ -194,6 +194,22 @@ class TestWeaviateDocumentStoreAsync(
|
|
|
194
194
|
|
|
195
195
|
assert await document_store.count_documents_async() == 0
|
|
196
196
|
|
|
197
|
+
@pytest.mark.asyncio
|
|
198
|
+
async def test_separate_grpc_host_async(self, request):
|
|
199
|
+
# `localhost` and `127.0.0.1` are different host strings for the same container, which is enough to
|
|
200
|
+
# exercise the `grpc_host` path; writes and filters go over gRPC, so they prove the channel works.
|
|
201
|
+
collection_settings = {"class": request.node.name, "invertedIndexConfig": {"indexNullState": True}}
|
|
202
|
+
store = WeaviateDocumentStore(
|
|
203
|
+
url="http://localhost:8080", grpc_host="127.0.0.1", collection_settings=collection_settings
|
|
204
|
+
)
|
|
205
|
+
try:
|
|
206
|
+
assert store._connection_params().grpc.host == "127.0.0.1"
|
|
207
|
+
assert await store.write_documents_async([Document(content="hello grpc")]) == 1
|
|
208
|
+
assert [doc.content for doc in await store.filter_documents_async()] == ["hello grpc"]
|
|
209
|
+
finally:
|
|
210
|
+
await (await store.async_client).collections.delete(collection_settings["class"])
|
|
211
|
+
await store.close_async()
|
|
212
|
+
|
|
197
213
|
@pytest.mark.asyncio
|
|
198
214
|
async def test_filter_documents_with_blob_data_async(
|
|
199
215
|
self, document_store: WeaviateDocumentStore, test_files_path: Path
|
|
@@ -61,6 +61,7 @@ def test_to_dict(_mock_weaviate):
|
|
|
61
61
|
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
|
|
62
62
|
"init_parameters": {
|
|
63
63
|
"url": None,
|
|
64
|
+
"grpc_host": None,
|
|
64
65
|
"grpc_port": 50051,
|
|
65
66
|
"grpc_secure": False,
|
|
66
67
|
"collection_settings": {
|
|
@@ -99,6 +100,7 @@ def test_from_dict(_mock_weaviate):
|
|
|
99
100
|
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
|
|
100
101
|
"init_parameters": {
|
|
101
102
|
"url": None,
|
|
103
|
+
"grpc_host": None,
|
|
102
104
|
"grpc_port": 50051,
|
|
103
105
|
"grpc_secure": False,
|
|
104
106
|
"collection_settings": {
|
|
@@ -142,6 +144,7 @@ def test_from_dict_no_filter_policy(_mock_weaviate):
|
|
|
142
144
|
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
|
|
143
145
|
"init_parameters": {
|
|
144
146
|
"url": None,
|
|
147
|
+
"grpc_host": None,
|
|
145
148
|
"grpc_port": 50051,
|
|
146
149
|
"grpc_secure": False,
|
|
147
150
|
"collection_settings": {
|
|
@@ -74,6 +74,7 @@ def test_to_dict(_mock_weaviate):
|
|
|
74
74
|
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
|
|
75
75
|
"init_parameters": {
|
|
76
76
|
"url": None,
|
|
77
|
+
"grpc_host": None,
|
|
77
78
|
"grpc_port": 50051,
|
|
78
79
|
"grpc_secure": False,
|
|
79
80
|
"collection_settings": {
|
|
@@ -132,6 +133,7 @@ def test_from_dict(_mock_weaviate):
|
|
|
132
133
|
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
|
|
133
134
|
"init_parameters": {
|
|
134
135
|
"url": None,
|
|
136
|
+
"grpc_host": None,
|
|
135
137
|
"grpc_port": 50051,
|
|
136
138
|
"grpc_secure": False,
|
|
137
139
|
"collection_settings": {
|
|
@@ -177,6 +179,7 @@ def test_from_dict_with_parameters(_mock_weaviate):
|
|
|
177
179
|
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
|
|
178
180
|
"init_parameters": {
|
|
179
181
|
"url": None,
|
|
182
|
+
"grpc_host": None,
|
|
180
183
|
"grpc_port": 50051,
|
|
181
184
|
"grpc_secure": False,
|
|
182
185
|
"collection_settings": {
|
|
@@ -317,6 +320,7 @@ def test_from_dict_no_filter_policy(_mock_weaviate):
|
|
|
317
320
|
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
|
|
318
321
|
"init_parameters": {
|
|
319
322
|
"url": None,
|
|
323
|
+
"grpc_host": None,
|
|
320
324
|
"grpc_port": 50051,
|
|
321
325
|
"grpc_secure": False,
|
|
322
326
|
"collection_settings": {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|