From f7fef26e9165bab8964fc83c6733362b0a104964 Mon Sep 17 00:00:00 2001 From: George Panchuk Date: Sun, 5 Jan 2025 11:07:49 +0100 Subject: [PATCH 1/3] fix: add missing strict mode config usage and conversion --- qdrant_client/async_qdrant_client.py | 1 + qdrant_client/conversions/conversion.py | 8 +++++++ qdrant_client/qdrant_client.py | 1 + tests/conversions/fixtures.py | 32 ++++++++++++------------- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/qdrant_client/async_qdrant_client.py b/qdrant_client/async_qdrant_client.py index 3855cf28..78af434d 100644 --- a/qdrant_client/async_qdrant_client.py +++ b/qdrant_client/async_qdrant_client.py @@ -2242,6 +2242,7 @@ async def create_collection( init_from=init_from, timeout=timeout, sparse_vectors_config=sparse_vectors_config, + strict_mode_config=strict_mode_config, **kwargs, ) diff --git a/qdrant_client/conversions/conversion.py b/qdrant_client/conversions/conversion.py index dfe9d8a0..4e2fec5d 100644 --- a/qdrant_client/conversions/conversion.py +++ b/qdrant_client/conversions/conversion.py @@ -244,6 +244,9 @@ def convert_collection_config(cls, model: grpc.CollectionConfig) -> rest.Collect if model.HasField("quantization_config") else None ), + strict_mode_config=cls.convert_strict_mode_config(model.strict_mode_config) + if model.HasField("strict_mode_config") + else None, ) @classmethod @@ -2412,6 +2415,11 @@ def convert_collection_config(cls, model: rest.CollectionConfig) -> grpc.Collect if model.quantization_config is not None else None ), + strict_mode_config=( + cls.convert_strict_mode_config(model.strict_mode_config) + if model.strict_mode_config is not None + else None + ), ) @classmethod diff --git a/qdrant_client/qdrant_client.py b/qdrant_client/qdrant_client.py index 57de3929..e6f2ad2c 100644 --- a/qdrant_client/qdrant_client.py +++ b/qdrant_client/qdrant_client.py @@ -2321,6 +2321,7 @@ def create_collection( init_from=init_from, timeout=timeout, sparse_vectors_config=sparse_vectors_config, + strict_mode_config=strict_mode_config, **kwargs, ) diff --git a/tests/conversions/fixtures.py b/tests/conversions/fixtures.py index 8d8aa826..74ace3dd 100644 --- a/tests/conversions/fixtures.py +++ b/tests/conversions/fixtures.py @@ -268,12 +268,28 @@ ) wal_config = grpc.WalConfigDiff(wal_capacity_mb=32, wal_segments_ahead=2) +strict_mode_config = grpc.StrictModeConfig( + enabled=True, + max_query_limit=100, + max_timeout=10, + unindexed_filtering_retrieve=False, + unindexed_filtering_update=False, + search_max_hnsw_ef=256, + search_allow_exact=False, + search_max_oversampling=10, + upsert_max_batchsize=64, + max_collection_vector_size_bytes=1024 * 1024 * 1024, + # read_rate_limit=model.read_rate_limit, test empty field + write_rate_limit=2000, + max_collection_payload_size_bytes=10 * 1024 * 1024 * 1024, +) collection_config = grpc.CollectionConfig( params=collection_params, hnsw_config=hnsw_config, optimizer_config=optimizer_config, wal_config=wal_config, + strict_mode_config=strict_mode_config, ) payload_value = { @@ -1362,22 +1378,6 @@ ids=[point_id_1, point_id_2], ) -strict_mode_config = grpc.StrictModeConfig( - enabled=True, - max_query_limit=100, - max_timeout=10, - unindexed_filtering_retrieve=False, - unindexed_filtering_update=False, - search_max_hnsw_ef=256, - search_allow_exact=False, - search_max_oversampling=10, - upsert_max_batchsize=64, - max_collection_vector_size_bytes=1024 * 1024 * 1024, - # read_rate_limit=model.read_rate_limit, test empty field - write_rate_limit=2000, - max_collection_payload_size_bytes=10 * 1024 * 1024 * 1024, -) - fixtures = { "CollectionParams": [collection_params, collection_params_2], From 08a282f0695fbb432ef0e91652e24aeaff939e20 Mon Sep 17 00:00:00 2001 From: George Panchuk Date: Sun, 5 Jan 2025 11:35:42 +0100 Subject: [PATCH 2/3] fix: pass strict mode config in update collection --- qdrant_client/async_qdrant_remote.py | 1 + qdrant_client/qdrant_remote.py | 1 + 2 files changed, 2 insertions(+) diff --git a/qdrant_client/async_qdrant_remote.py b/qdrant_client/async_qdrant_remote.py index a6149dff..66ae79a1 100644 --- a/qdrant_client/async_qdrant_remote.py +++ b/qdrant_client/async_qdrant_remote.py @@ -2391,6 +2391,7 @@ async def update_collection( hnsw_config=hnsw_config, quantization_config=quantization_config, sparse_vectors=sparse_vectors_config, + strict_mode_config=strict_mode_config, ), timeout=timeout, ) diff --git a/qdrant_client/qdrant_remote.py b/qdrant_client/qdrant_remote.py index 86592b4e..54147c71 100644 --- a/qdrant_client/qdrant_remote.py +++ b/qdrant_client/qdrant_remote.py @@ -2646,6 +2646,7 @@ def update_collection( hnsw_config=hnsw_config, quantization_config=quantization_config, sparse_vectors=sparse_vectors_config, + strict_mode_config=strict_mode_config, ), timeout=timeout, ).result From 2875d818ea6e8471b9df57cf8b5988e742035650 Mon Sep 17 00:00:00 2001 From: George Panchuk Date: Sun, 5 Jan 2025 11:37:12 +0100 Subject: [PATCH 3/3] fix: add strict mode config to recreate collection --- qdrant_client/async_qdrant_remote.py | 2 ++ qdrant_client/qdrant_remote.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/qdrant_client/async_qdrant_remote.py b/qdrant_client/async_qdrant_remote.py index 66ae79a1..062036a7 100644 --- a/qdrant_client/async_qdrant_remote.py +++ b/qdrant_client/async_qdrant_remote.py @@ -2528,6 +2528,7 @@ async def recreate_collection( timeout: Optional[int] = None, sparse_vectors_config: Optional[Mapping[str, types.SparseVectorParams]] = None, sharding_method: Optional[types.ShardingMethod] = None, + strict_mode_config: Optional[types.StrictModeConfig] = None, **kwargs: Any, ) -> bool: await self.delete_collection(collection_name, timeout=timeout) @@ -2546,6 +2547,7 @@ async def recreate_collection( timeout=timeout, sparse_vectors_config=sparse_vectors_config, sharding_method=sharding_method, + strict_mode_config=strict_mode_config, ) @property diff --git a/qdrant_client/qdrant_remote.py b/qdrant_client/qdrant_remote.py index 54147c71..a7de1888 100644 --- a/qdrant_client/qdrant_remote.py +++ b/qdrant_client/qdrant_remote.py @@ -2798,6 +2798,7 @@ def recreate_collection( timeout: Optional[int] = None, sparse_vectors_config: Optional[Mapping[str, types.SparseVectorParams]] = None, sharding_method: Optional[types.ShardingMethod] = None, + strict_mode_config: Optional[types.StrictModeConfig] = None, **kwargs: Any, ) -> bool: self.delete_collection(collection_name, timeout=timeout) @@ -2817,6 +2818,7 @@ def recreate_collection( timeout=timeout, sparse_vectors_config=sparse_vectors_config, sharding_method=sharding_method, + strict_mode_config=strict_mode_config, ) @property