Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ def to_dict(self) -> dict[str, Any]:
return default_to_dict(
self,
url=self._url,
grpc_port=self._grpc_port,
grpc_secure=self._grpc_secure,
collection_settings=self._collection_settings,
auth_client_secret=self._auth_client_secret.to_dict() if self._auth_client_secret else None,
additional_headers=self._additional_headers,
Expand Down
6 changes: 6 additions & 0 deletions integrations/weaviate/tests/test_bm25_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def test_to_dict(_mock_weaviate):
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
"init_parameters": {
"url": None,
"grpc_port": 50051,
"grpc_secure": False,
"collection_settings": {
"class": "Default",
"invertedIndexConfig": {"indexNullState": True},
Expand Down Expand Up @@ -74,6 +76,8 @@ def test_from_dict(_mock_weaviate):
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
"init_parameters": {
"url": None,
"grpc_port": 50051,
"grpc_secure": False,
"collection_settings": {
"class": "Default",
"invertedIndexConfig": {"indexNullState": True},
Expand Down Expand Up @@ -111,6 +115,8 @@ def test_from_dict_no_filter_policy(_mock_weaviate):
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
"init_parameters": {
"url": None,
"grpc_port": 50051,
"grpc_secure": False,
"collection_settings": {
"class": "Default",
"invertedIndexConfig": {"indexNullState": True},
Expand Down
21 changes: 21 additions & 0 deletions integrations/weaviate/tests/test_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ def test_to_dict(self, _mock_weaviate, monkeypatch):
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
"init_parameters": {
"url": "http://localhost:8080",
"grpc_port": 50051,
"grpc_secure": False,
"collection_settings": {
"class": "Default",
"invertedIndexConfig": {"indexNullState": True},
Expand Down Expand Up @@ -397,6 +399,25 @@ def test_to_dict(self, _mock_weaviate, monkeypatch):
},
}

@patch("haystack_integrations.document_stores.weaviate.document_store.weaviate")
def test_to_dict_and_from_dict_preserves_grpc_settings(self, _mock_weaviate):
"""`grpc_port`/`grpc_secure` configure the gRPC connection and must
survive a to_dict/from_dict round-trip; otherwise a reloaded store
silently falls back to the default gRPC port/security."""
document_store = WeaviateDocumentStore(
url="http://localhost:8080",
grpc_port=50052,
grpc_secure=True,
)

serialized = document_store.to_dict()
assert serialized["init_parameters"]["grpc_port"] == 50052
assert serialized["init_parameters"]["grpc_secure"] is True

restored = WeaviateDocumentStore.from_dict(serialized)
assert restored._grpc_port == 50052
assert restored._grpc_secure is True

@patch("haystack_integrations.document_stores.weaviate.document_store.weaviate")
def test_from_dict(self, _mock_weaviate, monkeypatch):
monkeypatch.setenv("WEAVIATE_API_KEY", "my_api_key")
Expand Down
6 changes: 6 additions & 0 deletions integrations/weaviate/tests/test_embedding_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def test_to_dict(_mock_weaviate):
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
"init_parameters": {
"url": None,
"grpc_port": 50051,
"grpc_secure": False,
"collection_settings": {
"class": "Default",
"invertedIndexConfig": {"indexNullState": True},
Expand Down Expand Up @@ -86,6 +88,8 @@ def test_from_dict(_mock_weaviate):
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
"init_parameters": {
"url": None,
"grpc_port": 50051,
"grpc_secure": False,
"collection_settings": {
"class": "Default",
"invertedIndexConfig": {"indexNullState": True},
Expand Down Expand Up @@ -127,6 +131,8 @@ def test_from_dict_no_filter_policy(_mock_weaviate):
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
"init_parameters": {
"url": None,
"grpc_port": 50051,
"grpc_secure": False,
"collection_settings": {
"class": "Default",
"invertedIndexConfig": {"indexNullState": True},
Expand Down
8 changes: 8 additions & 0 deletions integrations/weaviate/tests/test_hybrid_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def test_to_dict(_mock_weaviate):
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
"init_parameters": {
"url": None,
"grpc_port": 50051,
"grpc_secure": False,
"collection_settings": {
"class": "Default",
"invertedIndexConfig": {"indexNullState": True},
Expand Down Expand Up @@ -119,6 +121,8 @@ def test_from_dict(_mock_weaviate):
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
"init_parameters": {
"url": None,
"grpc_port": 50051,
"grpc_secure": False,
"collection_settings": {
"class": "Default",
"invertedIndexConfig": {"indexNullState": True},
Expand Down Expand Up @@ -162,6 +166,8 @@ def test_from_dict_with_parameters(_mock_weaviate):
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
"init_parameters": {
"url": None,
"grpc_port": 50051,
"grpc_secure": False,
"collection_settings": {
"class": "Default",
"invertedIndexConfig": {"indexNullState": True},
Expand Down Expand Up @@ -300,6 +306,8 @@ def test_from_dict_no_filter_policy(_mock_weaviate):
"type": "haystack_integrations.document_stores.weaviate.document_store.WeaviateDocumentStore",
"init_parameters": {
"url": None,
"grpc_port": 50051,
"grpc_secure": False,
"collection_settings": {
"class": "Default",
"invertedIndexConfig": {"indexNullState": True},
Expand Down
Loading