@@ -49,6 +49,7 @@ def test_to_dict(self, monkeypatch):
4949 wait_result_from_api = True ,
5050 use_sparse_embeddings = False ,
5151 api_key = Secret .from_env_var ("QDRANT_API_KEY" ),
52+ client_kwargs = {"check_compatibility" : False },
5253 )
5354 expected_dict = {
5455 "type" : "haystack_integrations.document_stores.qdrant.document_store.QdrantDocumentStore" ,
@@ -91,6 +92,7 @@ def test_to_dict(self, monkeypatch):
9192 "write_batch_size" : 100 ,
9293 "scroll_size" : 10000 ,
9394 "payload_fields_to_index" : None ,
95+ "client_kwargs" : {"check_compatibility" : False },
9496 },
9597 }
9698 assert doc_store .to_dict () == expected_dict
@@ -347,6 +349,30 @@ def test_prepare_client_params_does_not_mutate_metadata(self):
347349 params ["metadata" ]["added" ] = "x"
348350 assert metadata == {"key" : "value" }
349351
352+ def test_prepare_client_params_does_not_mutate_client_kwargs (self ):
353+ client_kwargs = {"grpc_options" : {"custom_option" : "value" }}
354+ document_store = QdrantDocumentStore (location = ":memory:" , client_kwargs = client_kwargs )
355+ params = document_store ._prepare_client_params ()
356+ params ["grpc_options" ]["grpc.primary_user_agent" ] = "qdrant-client"
357+
358+ assert client_kwargs == {"grpc_options" : {"custom_option" : "value" }}
359+ assert document_store .to_dict ()["init_parameters" ]["client_kwargs" ] == client_kwargs
360+
361+ @pytest .mark .parametrize ("port" , [6333 , 7333 ])
362+ def test_client_kwargs_are_forwarded_with_client_kwargs_taking_precedence (self , port ):
363+ document_store = QdrantDocumentStore (
364+ location = ":memory:" , port = port , client_kwargs = {"check_compatibility" : False , "port" : 8333 }
365+ )
366+
367+ with (
368+ patch ("haystack_integrations.document_stores.qdrant.document_store.qdrant_client.QdrantClient" ) as client ,
369+ patch .object (document_store , "_set_up_collection" ),
370+ ):
371+ document_store ._initialize_client ()
372+
373+ assert client .call_args .kwargs ["check_compatibility" ] is False
374+ assert client .call_args .kwargs ["port" ] == 8333
375+
350376 def test_get_batches_from_generator (self ):
351377 batches = list (get_batches_from_generator ([1 , 2 , 3 , 4 , 5 ], 2 ))
352378 assert batches == [(1 , 2 ), (3 , 4 ), (5 ,)]
0 commit comments