From ae86933f3a217a8b811bd945e33efcc274133477 Mon Sep 17 00:00:00 2001 From: hh-space-invader Date: Mon, 16 Dec 2024 11:33:26 +0200 Subject: [PATCH 01/16] refactor: Refactored the way of warnings --- qdrant_client/async_qdrant_client.py | 1 + qdrant_client/async_qdrant_fastembed.py | 8 ++--- qdrant_client/async_qdrant_remote.py | 30 +++++++++++++---- qdrant_client/common/client_warnings.py | 11 +++--- qdrant_client/local/async_qdrant_local.py | 24 ++++++++----- qdrant_client/local/local_collection.py | 1 + qdrant_client/local/qdrant_local.py | 25 +++++++++----- qdrant_client/qdrant_client.py | 1 + qdrant_client/qdrant_fastembed.py | 7 ++-- qdrant_client/qdrant_remote.py | 41 +++++++++++++++++------ qdrant_client/uploader/grpc_uploader.py | 7 +++- qdrant_client/uploader/rest_uploader.py | 7 +++- 12 files changed, 117 insertions(+), 46 deletions(-) diff --git a/qdrant_client/async_qdrant_client.py b/qdrant_client/async_qdrant_client.py index ef6673ff..caf7902b 100644 --- a/qdrant_client/async_qdrant_client.py +++ b/qdrant_client/async_qdrant_client.py @@ -1502,6 +1502,7 @@ async def upsert( message="\n Usage of `grpc.PointStruct` is deprecated. Please use `models.PointStruct` instead.\n ", category=DeprecationWarning, idx="grpc-input", + stacklevel=4, ) requires_inference = self._inference_inspector.inspect(points) if requires_inference and (not self.cloud_inference): diff --git a/qdrant_client/async_qdrant_fastembed.py b/qdrant_client/async_qdrant_fastembed.py index 31ee96bd..8a2654c1 100644 --- a/qdrant_client/async_qdrant_fastembed.py +++ b/qdrant_client/async_qdrant_fastembed.py @@ -10,7 +10,6 @@ # ****** WARNING: THIS FILE IS AUTOGENERATED ****** import uuid -import warnings from itertools import tee from typing import Any, Iterable, Optional, Sequence, Union, get_args from copy import deepcopy @@ -29,6 +28,7 @@ from qdrant_client.http import models from qdrant_client.hybrid.fusion import reciprocal_rank_fusion from qdrant_client import grpc +from qdrant_client.common.client_warnings import show_warning try: from fastembed import ( @@ -151,9 +151,9 @@ def set_model( None """ if max_length is not None: - warnings.warn( - "max_length parameter is deprecated and will be removed in the future. It's not used by fastembed models.", - DeprecationWarning, + show_warning( + message="max_length parameter is deprecated and will be removed in the future. It's not used by fastembed models.", + category=DeprecationWarning, stacklevel=2, ) self._get_or_init_model( diff --git a/qdrant_client/async_qdrant_remote.py b/qdrant_client/async_qdrant_remote.py index 7686d335..d3e932b9 100644 --- a/qdrant_client/async_qdrant_remote.py +++ b/qdrant_client/async_qdrant_remote.py @@ -13,7 +13,6 @@ import logging import math import platform -import warnings from multiprocessing import get_all_start_methods from typing import ( Any, @@ -31,6 +30,7 @@ import numpy as np from grpc import Compression from urllib3.util import Url, parse_url +from qdrant_client.common.client_warnings import show_warning from qdrant_client import grpc as grpc from qdrant_client._pydantic_compat import construct from qdrant_client.auth import BearerAuth @@ -117,7 +117,11 @@ def __init__( self._rest_headers = kwargs.pop("metadata", {}) if api_key is not None: if self._scheme == "http": - warnings.warn("Api key is used with an insecure connection.") + show_warning( + message="Api key is used with an insecure connection.", + category=RuntimeWarning, + stacklevel=2, + ) self._rest_headers["api-key"] = api_key self._grpc_headers.append(("api-key", api_key)) client_version = importlib.metadata.version("qdrant-client") @@ -147,7 +151,11 @@ def __init__( self._timeout = self.DEFAULT_GRPC_TIMEOUT if self._auth_token_provider is not None: if self._scheme == "http": - warnings.warn("Auth token provider is used with an insecure connection.") + show_warning( + message="Auth token provider is used with an insecure connection.", + category=RuntimeWarning, + stacklevel=2, + ) bearer_auth = BearerAuth(self._auth_token_provider) self._rest_args["auth"] = bearer_auth self.openapi_client: AsyncApis[AsyncApiClient] = AsyncApis( @@ -367,8 +375,10 @@ async def search( **kwargs: Any, ) -> list[types.ScoredPoint]: if not append_payload: - logging.warning( - "Usage of `append_payload` is deprecated. Please consider using `with_payload` instead" + show_warning( + message="Usage of `append_payload` is deprecated. Please consider using `with_payload` instead", + category=DeprecationWarning, + stacklevel=2, ) with_payload = append_payload if isinstance(query_vector, np.ndarray): @@ -2429,7 +2439,9 @@ async def create_collection( **kwargs: Any, ) -> bool: if init_from is not None: - logging.warning("init_from is deprecated") + show_warning( + message="init_from is deprecated", category=DeprecationWarning, stacklevel=2 + ) if self._prefer_grpc: if isinstance(vectors_config, (models.VectorParams, dict)): vectors_config = RestToGrpc.convert_vectors_config(vectors_config) @@ -2685,7 +2697,11 @@ async def create_payload_index( **kwargs: Any, ) -> types.UpdateResult: if field_type is not None: - warnings.warn("field_type is deprecated, use field_schema instead", DeprecationWarning) + show_warning( + message="field_type is deprecated, use field_schema instead", + category=DeprecationWarning, + stacklevel=2, + ) field_schema = field_type if self._prefer_grpc: field_index_params = None diff --git a/qdrant_client/common/client_warnings.py b/qdrant_client/common/client_warnings.py index 16fb7340..e55b32c5 100644 --- a/qdrant_client/common/client_warnings.py +++ b/qdrant_client/common/client_warnings.py @@ -4,12 +4,15 @@ SEEN_MESSAGES = set() -def show_warning(message: str, category: type[Warning] = UserWarning) -> None: - warnings.warn(message, category, stacklevel=4) +def show_warning(message: str, category: type[Warning] = UserWarning, stacklevel: int = 1) -> None: + warnings.warn(message, category, stacklevel=stacklevel) def show_warning_once( - message: str, category: type[Warning] = UserWarning, idx: Optional[str] = None + message: str, + category: type[Warning] = UserWarning, + idx: Optional[str] = None, + stacklevel: int = 1, ) -> None: """ Show a warning of the specified category only once per program run. @@ -18,4 +21,4 @@ def show_warning_once( if key not in SEEN_MESSAGES: SEEN_MESSAGES.add(key) - show_warning(message, category) + show_warning(message, category, stacklevel) diff --git a/qdrant_client/local/async_qdrant_local.py b/qdrant_client/local/async_qdrant_local.py index 7a4aaa2f..594debb1 100644 --- a/qdrant_client/local/async_qdrant_local.py +++ b/qdrant_client/local/async_qdrant_local.py @@ -12,7 +12,6 @@ import importlib.metadata import itertools import json -import logging import os import shutil from copy import deepcopy @@ -21,7 +20,7 @@ from uuid import uuid4 import numpy as np import portalocker -from qdrant_client.common.client_warnings import show_warning_once +from qdrant_client.common.client_warnings import show_warning, show_warning_once from qdrant_client._pydantic_compat import to_dict from qdrant_client.async_client_base import AsyncQdrantBase from qdrant_client.conversions import common_types as types @@ -77,8 +76,10 @@ async def close(self, **kwargs: Any) -> None: if collection is not None: collection.close() else: - logging.warning( - f"Collection appears to be None before closing. The existing collections are: {list(self.collections.keys())}" + show_warning( + message=f"Collection appears to be None before closing. The existing collections are: {list(self.collections.keys())}", + category=UserWarning, + stacklevel=1, ) try: if self._flock_file is not None and (not self._flock_file.closed): @@ -112,6 +113,7 @@ def _load(self) -> None: f"Local mode is not recommended for collections with more than {self.LARGE_DATA_THRESHOLD:,} points. Collection <{collection_name}> contains {len(collection.ids)} points. Consider using Qdrant in Docker or Qdrant Cloud for better performance with large datasets.", category=UserWarning, idx="large-local-collection", + stacklevel=4, ) self.aliases = meta["aliases"] lock_file_path = os.path.join(self.location, ".lock") @@ -1044,16 +1046,22 @@ async def create_payload_index( field_type: Optional[types.PayloadSchemaType] = None, **kwargs: Any, ) -> types.UpdateResult: - logging.warning( - "Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes." + show_warning_once( + message="Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes.", + category=UserWarning, + idx="server-payload-indexes", + stacklevel=1, ) return self._default_update_result() async def delete_payload_index( self, collection_name: str, field_name: str, **kwargs: Any ) -> types.UpdateResult: - logging.warning( - "Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes." + show_warning_once( + message="Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes.", + category=UserWarning, + idx="server-payload-indexes", + stacklevel=1, ) return self._default_update_result() diff --git a/qdrant_client/local/local_collection.py b/qdrant_client/local/local_collection.py index ab679ad1..314763a1 100644 --- a/qdrant_client/local/local_collection.py +++ b/qdrant_client/local/local_collection.py @@ -2195,6 +2195,7 @@ def upsert(self, points: Union[Sequence[models.PointStruct], models.Batch]) -> N "Consider using Qdrant in Docker or Qdrant Cloud for better performance with large datasets.", category=UserWarning, idx="large-local-collection", + stacklevel=4, ) def _update_named_vectors( diff --git a/qdrant_client/local/qdrant_local.py b/qdrant_client/local/qdrant_local.py index 15f69ca0..d020f505 100644 --- a/qdrant_client/local/qdrant_local.py +++ b/qdrant_client/local/qdrant_local.py @@ -21,7 +21,7 @@ import numpy as np import portalocker -from qdrant_client.common.client_warnings import show_warning_once +from qdrant_client.common.client_warnings import show_warning, show_warning_once from qdrant_client._pydantic_compat import to_dict from qdrant_client.client_base import QdrantBase from qdrant_client.conversions import common_types as types @@ -77,9 +77,11 @@ def close(self, **kwargs: Any) -> None: if collection is not None: collection.close() else: - logging.warning( - f"Collection appears to be None before closing. The existing collections are: " - f"{list(self.collections.keys())}" + show_warning( + message=f"Collection appears to be None before closing. The existing collections are: " + f"{list(self.collections.keys())}", + category=UserWarning, + stacklevel=1, ) try: @@ -119,6 +121,7 @@ def _load(self) -> None: "with large datasets.", category=UserWarning, idx="large-local-collection", + stacklevel=4, ) self.aliases = meta["aliases"] @@ -1133,16 +1136,22 @@ def create_payload_index( field_type: Optional[types.PayloadSchemaType] = None, **kwargs: Any, ) -> types.UpdateResult: - logging.warning( - "Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes." + show_warning_once( + message="Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes.", + category=UserWarning, + idx="server-payload-indexes", + stacklevel=1, ) return self._default_update_result() def delete_payload_index( self, collection_name: str, field_name: str, **kwargs: Any ) -> types.UpdateResult: - logging.warning( - "Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes." + show_warning_once( + message="Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes.", + category=UserWarning, + idx="server-payload-indexes", + stacklevel=1, ) return self._default_update_result() diff --git a/qdrant_client/qdrant_client.py b/qdrant_client/qdrant_client.py index 7ea64764..102b26f8 100644 --- a/qdrant_client/qdrant_client.py +++ b/qdrant_client/qdrant_client.py @@ -1553,6 +1553,7 @@ def upsert( """, category=DeprecationWarning, idx="grpc-input", + stacklevel=4, ) requires_inference = self._inference_inspector.inspect(points) diff --git a/qdrant_client/qdrant_fastembed.py b/qdrant_client/qdrant_fastembed.py index c29904c8..e0583b01 100644 --- a/qdrant_client/qdrant_fastembed.py +++ b/qdrant_client/qdrant_fastembed.py @@ -21,6 +21,7 @@ from qdrant_client.http import models from qdrant_client.hybrid.fusion import reciprocal_rank_fusion from qdrant_client import grpc +from qdrant_client.common.client_warnings import show_warning try: from fastembed import ( @@ -153,10 +154,10 @@ def set_model( """ if max_length is not None: - warnings.warn( - "max_length parameter is deprecated and will be removed in the future. " + show_warning( + message="max_length parameter is deprecated and will be removed in the future. " "It's not used by fastembed models.", - DeprecationWarning, + category=DeprecationWarning, stacklevel=2, ) diff --git a/qdrant_client/qdrant_remote.py b/qdrant_client/qdrant_remote.py index 3c3c151a..b0be45f8 100644 --- a/qdrant_client/qdrant_remote.py +++ b/qdrant_client/qdrant_remote.py @@ -22,6 +22,7 @@ from grpc import Compression from urllib3.util import Url, parse_url +from qdrant_client.common.client_warnings import show_warning from qdrant_client import grpc as grpc from qdrant_client._pydantic_compat import construct from qdrant_client.auth import BearerAuth @@ -129,7 +130,11 @@ def __init__( self._rest_headers = kwargs.pop("metadata", {}) if api_key is not None: if self._scheme == "http": - warnings.warn("Api key is used with an insecure connection.") + show_warning( + message="Api key is used with an insecure connection.", + category=RuntimeWarning, + stacklevel=2, + ) # http2 = True @@ -171,7 +176,11 @@ def __init__( if self._auth_token_provider is not None: if self._scheme == "http": - warnings.warn("Auth token provider is used with an insecure connection.") + show_warning( + message="Auth token provider is used with an insecure connection.", + category=RuntimeWarning, + stacklevel=2, + ) bearer_auth = BearerAuth(self._auth_token_provider) self._rest_args["auth"] = bearer_auth @@ -217,15 +226,19 @@ def close(self, grpc_grace: Optional[float] = None, **kwargs: Any) -> None: try: self._grpc_channel.close() except AttributeError: - logging.warning( - "Unable to close grpc_channel. Connection was interrupted on the server side" + show_warning( + message="Unable to close grpc_channel. Connection was interrupted on the server side", + category=RuntimeWarning, + stacklevel=2, ) try: self.openapi_client.close() except Exception: - logging.warning( - "Unable to close http connection. Connection was interrupted on the server side" + show_warning( + message="Unable to close http connection. Connection was interrupted on the server side", + category=RuntimeWarning, + stacklevel=2, ) self._closed = True @@ -411,8 +424,10 @@ def search( **kwargs: Any, ) -> list[types.ScoredPoint]: if not append_payload: - logging.warning( - "Usage of `append_payload` is deprecated. Please consider using `with_payload` instead" + show_warning( + message="Usage of `append_payload` is deprecated. Please consider using `with_payload` instead", + category=DeprecationWarning, + stacklevel=2, ) with_payload = append_payload @@ -2682,7 +2697,9 @@ def create_collection( **kwargs: Any, ) -> bool: if init_from is not None: - logging.warning("init_from is deprecated") + show_warning( + message="init_from is deprecated", category=DeprecationWarning, stacklevel=2 + ) if self._prefer_grpc: if isinstance(vectors_config, (models.VectorParams, dict)): @@ -2962,7 +2979,11 @@ def create_payload_index( **kwargs: Any, ) -> types.UpdateResult: if field_type is not None: - warnings.warn("field_type is deprecated, use field_schema instead", DeprecationWarning) + show_warning( + message="field_type is deprecated, use field_schema instead", + category=DeprecationWarning, + stacklevel=2, + ) field_schema = field_type if self._prefer_grpc: diff --git a/qdrant_client/uploader/grpc_uploader.py b/qdrant_client/uploader/grpc_uploader.py index 99103c40..4ad65dd5 100644 --- a/qdrant_client/uploader/grpc_uploader.py +++ b/qdrant_client/uploader/grpc_uploader.py @@ -9,6 +9,7 @@ from qdrant_client.grpc import PointId, PointsStub, PointStruct from qdrant_client.http.models import Batch, ShardKeySelector from qdrant_client.uploader.uploader import BaseUploader +from qdrant_client.common.client_warnings import show_warning def upload_batch_grpc( @@ -49,7 +50,11 @@ def upload_batch_grpc( ) break except Exception as e: - logging.warning(f"Batch upload failed {attempt + 1} times. Retrying...") + show_warning( + message=f"Batch upload failed {attempt + 1} times. Retrying...", + category=UserWarning, + stacklevel=1, + ) if attempt == max_retries - 1: raise e diff --git a/qdrant_client/uploader/rest_uploader.py b/qdrant_client/uploader/rest_uploader.py index 8d62be64..cc3f6407 100644 --- a/qdrant_client/uploader/rest_uploader.py +++ b/qdrant_client/uploader/rest_uploader.py @@ -8,6 +8,7 @@ from qdrant_client.http import SyncApis from qdrant_client.http.models import Batch, PointsList, PointStruct, ShardKeySelector from qdrant_client.uploader.uploader import BaseUploader +from qdrant_client.common.client_warnings import show_warning def upload_batch( @@ -41,7 +42,11 @@ def upload_batch( ) break except Exception as e: - logging.warning(f"Batch upload failed {attempt + 1} times. Retrying...") + show_warning( + message=f"Batch upload failed {attempt + 1} times. Retrying...", + category=UserWarning, + stacklevel=1, + ) if attempt == max_retries - 1: raise e From 4fa752b47154f381f46cf1809e50206420b5dba2 Mon Sep 17 00:00:00 2001 From: hh-space-invader Date: Mon, 16 Dec 2024 12:58:13 +0200 Subject: [PATCH 02/16] remove unused imports --- qdrant_client/qdrant_fastembed.py | 1 - qdrant_client/qdrant_remote.py | 1 - 2 files changed, 2 deletions(-) diff --git a/qdrant_client/qdrant_fastembed.py b/qdrant_client/qdrant_fastembed.py index e0583b01..006d4afa 100644 --- a/qdrant_client/qdrant_fastembed.py +++ b/qdrant_client/qdrant_fastembed.py @@ -1,5 +1,4 @@ import uuid -import warnings from itertools import tee from typing import Any, Iterable, Optional, Sequence, Union, get_args from copy import deepcopy diff --git a/qdrant_client/qdrant_remote.py b/qdrant_client/qdrant_remote.py index b0be45f8..ee83beef 100644 --- a/qdrant_client/qdrant_remote.py +++ b/qdrant_client/qdrant_remote.py @@ -2,7 +2,6 @@ import logging import math import platform -import warnings from multiprocessing import get_all_start_methods from typing import ( Any, From 7e68715476b8f99509444ad36bd15e222522335d Mon Sep 17 00:00:00 2001 From: hh-space-invader Date: Wed, 18 Dec 2024 06:41:06 +0200 Subject: [PATCH 03/16] fix: Fix stacklevel in warnings --- qdrant_client/local/local_collection.py | 2 +- qdrant_client/local/qdrant_local.py | 8 ++++---- qdrant_client/qdrant_remote.py | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/qdrant_client/local/local_collection.py b/qdrant_client/local/local_collection.py index 314763a1..dedd6a12 100644 --- a/qdrant_client/local/local_collection.py +++ b/qdrant_client/local/local_collection.py @@ -2195,7 +2195,7 @@ def upsert(self, points: Union[Sequence[models.PointStruct], models.Batch]) -> N "Consider using Qdrant in Docker or Qdrant Cloud for better performance with large datasets.", category=UserWarning, idx="large-local-collection", - stacklevel=4, + stacklevel=6, ) def _update_named_vectors( diff --git a/qdrant_client/local/qdrant_local.py b/qdrant_client/local/qdrant_local.py index d020f505..9dae08c0 100644 --- a/qdrant_client/local/qdrant_local.py +++ b/qdrant_client/local/qdrant_local.py @@ -81,7 +81,7 @@ def close(self, **kwargs: Any) -> None: message=f"Collection appears to be None before closing. The existing collections are: " f"{list(self.collections.keys())}", category=UserWarning, - stacklevel=1, + stacklevel=5, ) try: @@ -121,7 +121,7 @@ def _load(self) -> None: "with large datasets.", category=UserWarning, idx="large-local-collection", - stacklevel=4, + stacklevel=6, ) self.aliases = meta["aliases"] @@ -1140,7 +1140,7 @@ def create_payload_index( message="Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes.", category=UserWarning, idx="server-payload-indexes", - stacklevel=1, + stacklevel=5, ) return self._default_update_result() @@ -1151,7 +1151,7 @@ def delete_payload_index( message="Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes.", category=UserWarning, idx="server-payload-indexes", - stacklevel=1, + stacklevel=5, ) return self._default_update_result() diff --git a/qdrant_client/qdrant_remote.py b/qdrant_client/qdrant_remote.py index ee83beef..2171a23c 100644 --- a/qdrant_client/qdrant_remote.py +++ b/qdrant_client/qdrant_remote.py @@ -132,7 +132,7 @@ def __init__( show_warning( message="Api key is used with an insecure connection.", category=RuntimeWarning, - stacklevel=2, + stacklevel=4, ) # http2 = True @@ -178,7 +178,7 @@ def __init__( show_warning( message="Auth token provider is used with an insecure connection.", category=RuntimeWarning, - stacklevel=2, + stacklevel=4, ) bearer_auth = BearerAuth(self._auth_token_provider) @@ -228,7 +228,7 @@ def close(self, grpc_grace: Optional[float] = None, **kwargs: Any) -> None: show_warning( message="Unable to close grpc_channel. Connection was interrupted on the server side", category=RuntimeWarning, - stacklevel=2, + stacklevel=4, ) try: @@ -237,7 +237,7 @@ def close(self, grpc_grace: Optional[float] = None, **kwargs: Any) -> None: show_warning( message="Unable to close http connection. Connection was interrupted on the server side", category=RuntimeWarning, - stacklevel=2, + stacklevel=4, ) self._closed = True @@ -2697,7 +2697,7 @@ def create_collection( ) -> bool: if init_from is not None: show_warning( - message="init_from is deprecated", category=DeprecationWarning, stacklevel=2 + message="init_from is deprecated", category=DeprecationWarning, stacklevel=4 ) if self._prefer_grpc: @@ -2981,7 +2981,7 @@ def create_payload_index( show_warning( message="field_type is deprecated, use field_schema instead", category=DeprecationWarning, - stacklevel=2, + stacklevel=4, ) field_schema = field_type From 44fdf661118a202dedd21823c930e61f7a133049 Mon Sep 17 00:00:00 2001 From: hh-space-invader Date: Wed, 18 Dec 2024 06:48:14 +0200 Subject: [PATCH 04/16] regenerated async --- qdrant_client/async_qdrant_remote.py | 8 ++++---- qdrant_client/local/async_qdrant_local.py | 8 ++++---- qdrant_client/qdrant_remote.py | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/qdrant_client/async_qdrant_remote.py b/qdrant_client/async_qdrant_remote.py index d3e932b9..58ab9188 100644 --- a/qdrant_client/async_qdrant_remote.py +++ b/qdrant_client/async_qdrant_remote.py @@ -120,7 +120,7 @@ def __init__( show_warning( message="Api key is used with an insecure connection.", category=RuntimeWarning, - stacklevel=2, + stacklevel=4, ) self._rest_headers["api-key"] = api_key self._grpc_headers.append(("api-key", api_key)) @@ -154,7 +154,7 @@ def __init__( show_warning( message="Auth token provider is used with an insecure connection.", category=RuntimeWarning, - stacklevel=2, + stacklevel=4, ) bearer_auth = BearerAuth(self._auth_token_provider) self._rest_args["auth"] = bearer_auth @@ -2440,7 +2440,7 @@ async def create_collection( ) -> bool: if init_from is not None: show_warning( - message="init_from is deprecated", category=DeprecationWarning, stacklevel=2 + message="init_from is deprecated", category=DeprecationWarning, stacklevel=4 ) if self._prefer_grpc: if isinstance(vectors_config, (models.VectorParams, dict)): @@ -2700,7 +2700,7 @@ async def create_payload_index( show_warning( message="field_type is deprecated, use field_schema instead", category=DeprecationWarning, - stacklevel=2, + stacklevel=4, ) field_schema = field_type if self._prefer_grpc: diff --git a/qdrant_client/local/async_qdrant_local.py b/qdrant_client/local/async_qdrant_local.py index 594debb1..41644c2a 100644 --- a/qdrant_client/local/async_qdrant_local.py +++ b/qdrant_client/local/async_qdrant_local.py @@ -79,7 +79,7 @@ async def close(self, **kwargs: Any) -> None: show_warning( message=f"Collection appears to be None before closing. The existing collections are: {list(self.collections.keys())}", category=UserWarning, - stacklevel=1, + stacklevel=5, ) try: if self._flock_file is not None and (not self._flock_file.closed): @@ -113,7 +113,7 @@ def _load(self) -> None: f"Local mode is not recommended for collections with more than {self.LARGE_DATA_THRESHOLD:,} points. Collection <{collection_name}> contains {len(collection.ids)} points. Consider using Qdrant in Docker or Qdrant Cloud for better performance with large datasets.", category=UserWarning, idx="large-local-collection", - stacklevel=4, + stacklevel=6, ) self.aliases = meta["aliases"] lock_file_path = os.path.join(self.location, ".lock") @@ -1050,7 +1050,7 @@ async def create_payload_index( message="Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes.", category=UserWarning, idx="server-payload-indexes", - stacklevel=1, + stacklevel=5, ) return self._default_update_result() @@ -1061,7 +1061,7 @@ async def delete_payload_index( message="Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes.", category=UserWarning, idx="server-payload-indexes", - stacklevel=1, + stacklevel=5, ) return self._default_update_result() diff --git a/qdrant_client/qdrant_remote.py b/qdrant_client/qdrant_remote.py index 2171a23c..bb83ac41 100644 --- a/qdrant_client/qdrant_remote.py +++ b/qdrant_client/qdrant_remote.py @@ -2,6 +2,7 @@ import logging import math import platform +import warnings from multiprocessing import get_all_start_methods from typing import ( Any, From d3f9f805e2eab31af02a189f13db580409577392 Mon Sep 17 00:00:00 2001 From: hh-space-invader Date: Wed, 18 Dec 2024 07:17:24 +0200 Subject: [PATCH 05/16] nit --- qdrant_client/async_qdrant_remote.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qdrant_client/async_qdrant_remote.py b/qdrant_client/async_qdrant_remote.py index 58ab9188..8aa5bbfd 100644 --- a/qdrant_client/async_qdrant_remote.py +++ b/qdrant_client/async_qdrant_remote.py @@ -13,6 +13,7 @@ import logging import math import platform +import warnings from multiprocessing import get_all_start_methods from typing import ( Any, From 482cc16c15ba0de327da7f7103385ba6bb2dfa44 Mon Sep 17 00:00:00 2001 From: hh-space-invader Date: Thu, 19 Dec 2024 09:06:52 +0200 Subject: [PATCH 06/16] Updated some warnings with show once --- qdrant_client/async_qdrant_remote.py | 15 ++++++++++----- qdrant_client/common/client_warnings.py | 2 +- qdrant_client/local/async_qdrant_local.py | 4 ++-- qdrant_client/local/qdrant_local.py | 4 ++-- qdrant_client/qdrant_remote.py | 15 ++++++++++----- qdrant_client/uploader/grpc_uploader.py | 2 +- qdrant_client/uploader/rest_uploader.py | 2 +- 7 files changed, 27 insertions(+), 17 deletions(-) diff --git a/qdrant_client/async_qdrant_remote.py b/qdrant_client/async_qdrant_remote.py index 8aa5bbfd..4c751191 100644 --- a/qdrant_client/async_qdrant_remote.py +++ b/qdrant_client/async_qdrant_remote.py @@ -31,7 +31,7 @@ import numpy as np from grpc import Compression from urllib3.util import Url, parse_url -from qdrant_client.common.client_warnings import show_warning +from qdrant_client.common.client_warnings import show_warning, show_warning_once from qdrant_client import grpc as grpc from qdrant_client._pydantic_compat import construct from qdrant_client.auth import BearerAuth @@ -376,10 +376,11 @@ async def search( **kwargs: Any, ) -> list[types.ScoredPoint]: if not append_payload: - show_warning( + show_warning_once( message="Usage of `append_payload` is deprecated. Please consider using `with_payload` instead", category=DeprecationWarning, stacklevel=2, + idx="search-append-payload", ) with_payload = append_payload if isinstance(query_vector, np.ndarray): @@ -2440,8 +2441,11 @@ async def create_collection( **kwargs: Any, ) -> bool: if init_from is not None: - show_warning( - message="init_from is deprecated", category=DeprecationWarning, stacklevel=4 + show_warning_once( + message="init_from is deprecated", + category=DeprecationWarning, + stacklevel=4, + idx="create-collection-inint-from", ) if self._prefer_grpc: if isinstance(vectors_config, (models.VectorParams, dict)): @@ -2698,10 +2702,11 @@ async def create_payload_index( **kwargs: Any, ) -> types.UpdateResult: if field_type is not None: - show_warning( + show_warning_once( message="field_type is deprecated, use field_schema instead", category=DeprecationWarning, stacklevel=4, + idx="payload-index-field-type", ) field_schema = field_type if self._prefer_grpc: diff --git a/qdrant_client/common/client_warnings.py b/qdrant_client/common/client_warnings.py index e55b32c5..319cc7b6 100644 --- a/qdrant_client/common/client_warnings.py +++ b/qdrant_client/common/client_warnings.py @@ -4,7 +4,7 @@ SEEN_MESSAGES = set() -def show_warning(message: str, category: type[Warning] = UserWarning, stacklevel: int = 1) -> None: +def show_warning(message: str, category: type[Warning] = UserWarning, stacklevel: int = 2) -> None: warnings.warn(message, category, stacklevel=stacklevel) diff --git a/qdrant_client/local/async_qdrant_local.py b/qdrant_client/local/async_qdrant_local.py index 41644c2a..d1a0725f 100644 --- a/qdrant_client/local/async_qdrant_local.py +++ b/qdrant_client/local/async_qdrant_local.py @@ -1049,7 +1049,7 @@ async def create_payload_index( show_warning_once( message="Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes.", category=UserWarning, - idx="server-payload-indexes", + idx="create-local-payload-indexes", stacklevel=5, ) return self._default_update_result() @@ -1060,7 +1060,7 @@ async def delete_payload_index( show_warning_once( message="Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes.", category=UserWarning, - idx="server-payload-indexes", + idx="delete-local-payload-indexes", stacklevel=5, ) return self._default_update_result() diff --git a/qdrant_client/local/qdrant_local.py b/qdrant_client/local/qdrant_local.py index 9dae08c0..3b62baa8 100644 --- a/qdrant_client/local/qdrant_local.py +++ b/qdrant_client/local/qdrant_local.py @@ -1139,7 +1139,7 @@ def create_payload_index( show_warning_once( message="Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes.", category=UserWarning, - idx="server-payload-indexes", + idx="create-local-payload-indexes", stacklevel=5, ) return self._default_update_result() @@ -1150,7 +1150,7 @@ def delete_payload_index( show_warning_once( message="Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes.", category=UserWarning, - idx="server-payload-indexes", + idx="delete-local-payload-indexes", stacklevel=5, ) return self._default_update_result() diff --git a/qdrant_client/qdrant_remote.py b/qdrant_client/qdrant_remote.py index bb83ac41..dd4aecd3 100644 --- a/qdrant_client/qdrant_remote.py +++ b/qdrant_client/qdrant_remote.py @@ -22,7 +22,7 @@ from grpc import Compression from urllib3.util import Url, parse_url -from qdrant_client.common.client_warnings import show_warning +from qdrant_client.common.client_warnings import show_warning, show_warning_once from qdrant_client import grpc as grpc from qdrant_client._pydantic_compat import construct from qdrant_client.auth import BearerAuth @@ -424,10 +424,11 @@ def search( **kwargs: Any, ) -> list[types.ScoredPoint]: if not append_payload: - show_warning( + show_warning_once( message="Usage of `append_payload` is deprecated. Please consider using `with_payload` instead", category=DeprecationWarning, stacklevel=2, + idx="search-append-payload", ) with_payload = append_payload @@ -2697,8 +2698,11 @@ def create_collection( **kwargs: Any, ) -> bool: if init_from is not None: - show_warning( - message="init_from is deprecated", category=DeprecationWarning, stacklevel=4 + show_warning_once( + message="init_from is deprecated", + category=DeprecationWarning, + stacklevel=4, + idx="create-collection-inint-from", ) if self._prefer_grpc: @@ -2979,10 +2983,11 @@ def create_payload_index( **kwargs: Any, ) -> types.UpdateResult: if field_type is not None: - show_warning( + show_warning_once( message="field_type is deprecated, use field_schema instead", category=DeprecationWarning, stacklevel=4, + idx="payload-index-field-type", ) field_schema = field_type diff --git a/qdrant_client/uploader/grpc_uploader.py b/qdrant_client/uploader/grpc_uploader.py index 4ad65dd5..b47676d2 100644 --- a/qdrant_client/uploader/grpc_uploader.py +++ b/qdrant_client/uploader/grpc_uploader.py @@ -53,7 +53,7 @@ def upload_batch_grpc( show_warning( message=f"Batch upload failed {attempt + 1} times. Retrying...", category=UserWarning, - stacklevel=1, + stacklevel=8, ) if attempt == max_retries - 1: diff --git a/qdrant_client/uploader/rest_uploader.py b/qdrant_client/uploader/rest_uploader.py index cc3f6407..ac2868c1 100644 --- a/qdrant_client/uploader/rest_uploader.py +++ b/qdrant_client/uploader/rest_uploader.py @@ -45,7 +45,7 @@ def upload_batch( show_warning( message=f"Batch upload failed {attempt + 1} times. Retrying...", category=UserWarning, - stacklevel=1, + stacklevel=7, ) if attempt == max_retries - 1: From 22685eb3fe3ca8dd17b8c87a2cddd4d2c6ce7239 Mon Sep 17 00:00:00 2001 From: hh-space-invader Date: Mon, 30 Dec 2024 13:13:43 +0200 Subject: [PATCH 07/16] fix: Fix stack levels --- qdrant_client/qdrant_fastembed.py | 2 +- qdrant_client/qdrant_remote.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/qdrant_client/qdrant_fastembed.py b/qdrant_client/qdrant_fastembed.py index 006d4afa..03c665fd 100644 --- a/qdrant_client/qdrant_fastembed.py +++ b/qdrant_client/qdrant_fastembed.py @@ -157,7 +157,7 @@ def set_model( message="max_length parameter is deprecated and will be removed in the future. " "It's not used by fastembed models.", category=DeprecationWarning, - stacklevel=2, + stacklevel=3, ) self._get_or_init_model( diff --git a/qdrant_client/qdrant_remote.py b/qdrant_client/qdrant_remote.py index dd4aecd3..586fb3de 100644 --- a/qdrant_client/qdrant_remote.py +++ b/qdrant_client/qdrant_remote.py @@ -423,11 +423,11 @@ def search( timeout: Optional[int] = None, **kwargs: Any, ) -> list[types.ScoredPoint]: - if not append_payload: + if append_payload is not None: show_warning_once( message="Usage of `append_payload` is deprecated. Please consider using `with_payload` instead", category=DeprecationWarning, - stacklevel=2, + stacklevel=5, idx="search-append-payload", ) with_payload = append_payload @@ -2701,7 +2701,7 @@ def create_collection( show_warning_once( message="init_from is deprecated", category=DeprecationWarning, - stacklevel=4, + stacklevel=5, idx="create-collection-inint-from", ) @@ -2986,7 +2986,7 @@ def create_payload_index( show_warning_once( message="field_type is deprecated, use field_schema instead", category=DeprecationWarning, - stacklevel=4, + stacklevel=5, idx="payload-index-field-type", ) field_schema = field_type From 4c93c0fedff4f04af19e707ccc416231fb20fe38 Mon Sep 17 00:00:00 2001 From: hh-space-invader Date: Mon, 30 Dec 2024 13:15:33 +0200 Subject: [PATCH 08/16] Updated async --- qdrant_client/async_qdrant_fastembed.py | 2 +- qdrant_client/async_qdrant_remote.py | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/qdrant_client/async_qdrant_fastembed.py b/qdrant_client/async_qdrant_fastembed.py index 8a2654c1..eedbe7e0 100644 --- a/qdrant_client/async_qdrant_fastembed.py +++ b/qdrant_client/async_qdrant_fastembed.py @@ -154,7 +154,7 @@ def set_model( show_warning( message="max_length parameter is deprecated and will be removed in the future. It's not used by fastembed models.", category=DeprecationWarning, - stacklevel=2, + stacklevel=3, ) self._get_or_init_model( model_name=embedding_model_name, diff --git a/qdrant_client/async_qdrant_remote.py b/qdrant_client/async_qdrant_remote.py index 4c751191..89d826a4 100644 --- a/qdrant_client/async_qdrant_remote.py +++ b/qdrant_client/async_qdrant_remote.py @@ -13,7 +13,6 @@ import logging import math import platform -import warnings from multiprocessing import get_all_start_methods from typing import ( Any, @@ -375,11 +374,11 @@ async def search( timeout: Optional[int] = None, **kwargs: Any, ) -> list[types.ScoredPoint]: - if not append_payload: + if append_payload is not None: show_warning_once( message="Usage of `append_payload` is deprecated. Please consider using `with_payload` instead", category=DeprecationWarning, - stacklevel=2, + stacklevel=5, idx="search-append-payload", ) with_payload = append_payload @@ -2444,7 +2443,7 @@ async def create_collection( show_warning_once( message="init_from is deprecated", category=DeprecationWarning, - stacklevel=4, + stacklevel=5, idx="create-collection-inint-from", ) if self._prefer_grpc: @@ -2705,7 +2704,7 @@ async def create_payload_index( show_warning_once( message="field_type is deprecated, use field_schema instead", category=DeprecationWarning, - stacklevel=4, + stacklevel=5, idx="payload-index-field-type", ) field_schema = field_type From f27859656bde2d2ddddae153afb7a2444dcd816b Mon Sep 17 00:00:00 2001 From: Hossam Hagag <90828745+hh-space-invader@users.noreply.github.com> Date: Fri, 3 Jan 2025 10:48:13 +0200 Subject: [PATCH 09/16] Update qdrant_client/qdrant_remote.py Co-authored-by: George --- qdrant_client/qdrant_remote.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qdrant_client/qdrant_remote.py b/qdrant_client/qdrant_remote.py index 586fb3de..0329739e 100644 --- a/qdrant_client/qdrant_remote.py +++ b/qdrant_client/qdrant_remote.py @@ -2702,7 +2702,7 @@ def create_collection( message="init_from is deprecated", category=DeprecationWarning, stacklevel=5, - idx="create-collection-inint-from", + idx="create-collection-init-from", ) if self._prefer_grpc: From a4dde82f976cbaa309d0c598a10a3bc06549029f Mon Sep 17 00:00:00 2001 From: hh-space-invader Date: Fri, 3 Jan 2025 10:49:26 +0200 Subject: [PATCH 10/16] Update async client --- qdrant_client/async_qdrant_remote.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qdrant_client/async_qdrant_remote.py b/qdrant_client/async_qdrant_remote.py index 89d826a4..99ae8044 100644 --- a/qdrant_client/async_qdrant_remote.py +++ b/qdrant_client/async_qdrant_remote.py @@ -2444,7 +2444,7 @@ async def create_collection( message="init_from is deprecated", category=DeprecationWarning, stacklevel=5, - idx="create-collection-inint-from", + idx="create-collection-init-from", ) if self._prefer_grpc: if isinstance(vectors_config, (models.VectorParams, dict)): From 4bf910e9dee2df4173e1cda3b2698f7d670f32b4 Mon Sep 17 00:00:00 2001 From: hh-space-invader Date: Sun, 5 Jan 2025 23:06:14 +0200 Subject: [PATCH 11/16] Updated warnings --- qdrant_client/async_qdrant_remote.py | 17 ++++++++++------- qdrant_client/local/async_qdrant_local.py | 4 ++-- qdrant_client/local/qdrant_local.py | 4 ++-- qdrant_client/qdrant_remote.py | 4 ++-- .../remote/function_def_transformer.py | 12 ++++++++---- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/qdrant_client/async_qdrant_remote.py b/qdrant_client/async_qdrant_remote.py index 99ae8044..f0f87b3b 100644 --- a/qdrant_client/async_qdrant_remote.py +++ b/qdrant_client/async_qdrant_remote.py @@ -10,7 +10,6 @@ # ****** WARNING: THIS FILE IS AUTOGENERATED ****** import importlib.metadata -import logging import math import platform from multiprocessing import get_all_start_methods @@ -119,7 +118,7 @@ def __init__( if self._scheme == "http": show_warning( message="Api key is used with an insecure connection.", - category=RuntimeWarning, + category=UserWarning, stacklevel=4, ) self._rest_headers["api-key"] = api_key @@ -153,7 +152,7 @@ def __init__( if self._scheme == "http": show_warning( message="Auth token provider is used with an insecure connection.", - category=RuntimeWarning, + category=UserWarning, stacklevel=4, ) bearer_auth = BearerAuth(self._auth_token_provider) @@ -190,16 +189,20 @@ async def close(self, grpc_grace: Optional[float] = None, **kwargs: Any) -> None try: await self._grpc_channel.close(grace=grpc_grace) except AttributeError: - logging.warning( - "Unable to close grpc_channel. Connection was interrupted on the server side" + show_warning( + message="Unable to close grpc_channel. Connection was interrupted on the server side", + category=UserWarning, + stacklevel=5, ) except RuntimeError: pass try: await self.http.aclose() except Exception: - logging.warning( - "Unable to close http connection. Connection was interrupted on the server side" + show_warning( + message="Unable to close http connection. Connection was interrupted on the server side", + category=UserWarning, + stacklevel=5, ) self._closed = True diff --git a/qdrant_client/local/async_qdrant_local.py b/qdrant_client/local/async_qdrant_local.py index d1a0725f..df98e0d2 100644 --- a/qdrant_client/local/async_qdrant_local.py +++ b/qdrant_client/local/async_qdrant_local.py @@ -79,7 +79,7 @@ async def close(self, **kwargs: Any) -> None: show_warning( message=f"Collection appears to be None before closing. The existing collections are: {list(self.collections.keys())}", category=UserWarning, - stacklevel=5, + stacklevel=4, ) try: if self._flock_file is not None and (not self._flock_file.closed): @@ -109,7 +109,7 @@ def _load(self) -> None: ) self.collections[collection_name] = collection if len(collection.ids) > self.LARGE_DATA_THRESHOLD: - show_warning_once( + show_warning( f"Local mode is not recommended for collections with more than {self.LARGE_DATA_THRESHOLD:,} points. Collection <{collection_name}> contains {len(collection.ids)} points. Consider using Qdrant in Docker or Qdrant Cloud for better performance with large datasets.", category=UserWarning, idx="large-local-collection", diff --git a/qdrant_client/local/qdrant_local.py b/qdrant_client/local/qdrant_local.py index 3b62baa8..b1c94e49 100644 --- a/qdrant_client/local/qdrant_local.py +++ b/qdrant_client/local/qdrant_local.py @@ -81,7 +81,7 @@ def close(self, **kwargs: Any) -> None: message=f"Collection appears to be None before closing. The existing collections are: " f"{list(self.collections.keys())}", category=UserWarning, - stacklevel=5, + stacklevel=4, ) try: @@ -113,7 +113,7 @@ def _load(self) -> None: ) self.collections[collection_name] = collection if len(collection.ids) > self.LARGE_DATA_THRESHOLD: - show_warning_once( + show_warning( f"Local mode is not recommended for collections with more than " f"{self.LARGE_DATA_THRESHOLD:,} points. " f"Collection <{collection_name}> contains {len(collection.ids)} points. " diff --git a/qdrant_client/qdrant_remote.py b/qdrant_client/qdrant_remote.py index 0329739e..0af09622 100644 --- a/qdrant_client/qdrant_remote.py +++ b/qdrant_client/qdrant_remote.py @@ -132,7 +132,7 @@ def __init__( if self._scheme == "http": show_warning( message="Api key is used with an insecure connection.", - category=RuntimeWarning, + category=UserWarning, stacklevel=4, ) @@ -178,7 +178,7 @@ def __init__( if self._scheme == "http": show_warning( message="Auth token provider is used with an insecure connection.", - category=RuntimeWarning, + category=UserWarning, stacklevel=4, ) diff --git a/tools/async_client_generator/transformers/remote/function_def_transformer.py b/tools/async_client_generator/transformers/remote/function_def_transformer.py index 99039b57..c601e985 100644 --- a/tools/async_client_generator/transformers/remote/function_def_transformer.py +++ b/tools/async_client_generator/transformers/remote/function_def_transformer.py @@ -42,8 +42,10 @@ async def close(self, grpc_grace: Optional[float] = None, **kwargs: Any) -> None try: await self._grpc_channel.close(grace=grpc_grace) except AttributeError: - logging.warning( - "Unable to close grpc_channel. Connection was interrupted on the server side" + show_warning( + message="Unable to close grpc_channel. Connection was interrupted on the server side", + category=UserWarning, + stacklevel=5, ) except RuntimeError: pass @@ -51,8 +53,10 @@ async def close(self, grpc_grace: Optional[float] = None, **kwargs: Any) -> None try: await self.http.aclose() except Exception: - logging.warning( - "Unable to close http connection. Connection was interrupted on the server side" + show_warning( + message="Unable to close http connection. Connection was interrupted on the server side", + category=UserWarning, + stacklevel=5, ) self._closed = True From 27ebde6999ca05e0d562f95ea5cfca1d842d8ce4 Mon Sep 17 00:00:00 2001 From: hh-space-invader Date: Sun, 5 Jan 2025 23:22:41 +0200 Subject: [PATCH 12/16] Updated warnings --- qdrant_client/async_qdrant_remote.py | 12 ++++++++---- qdrant_client/qdrant_remote.py | 13 ++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/qdrant_client/async_qdrant_remote.py b/qdrant_client/async_qdrant_remote.py index f0f87b3b..a0f7570f 100644 --- a/qdrant_client/async_qdrant_remote.py +++ b/qdrant_client/async_qdrant_remote.py @@ -172,12 +172,16 @@ def __init__( self.rest_uri, self._rest_headers, self._rest_args.get("auth") ) if not server_version: - warnings.warn( - f"Failed to obtain server version. Unable to check client-server compatibility. Set check_version=False to skip version check." + show_warning( + message=f"Failed to obtain server version. Unable to check client-server compatibility. Set check_version=False to skip version check.", + category=UserWarning, + stacklevel=4, ) elif not is_compatible(client_version, server_version): - warnings.warn( - f"Qdrant client version {client_version} is incompatible with server version {server_version}. Major versions should match and minor version difference must not exceed 1. Set check_version=False to skip version check." + show_warning( + message=f"Qdrant client version {client_version} is incompatible with server version {server_version}. Major versions should match and minor version difference must not exceed 1. Set check_version=False to skip version check.", + category=UserWarning, + stacklevel=4, ) @property diff --git a/qdrant_client/qdrant_remote.py b/qdrant_client/qdrant_remote.py index 0af09622..1b2288e1 100644 --- a/qdrant_client/qdrant_remote.py +++ b/qdrant_client/qdrant_remote.py @@ -209,12 +209,16 @@ def __init__( self.rest_uri, self._rest_headers, self._rest_args.get("auth") ) if not server_version: - warnings.warn( - f"Failed to obtain server version. Unable to check client-server compatibility. Set check_version=False to skip version check." + show_warning( + message=f"Failed to obtain server version. Unable to check client-server compatibility. Set check_version=False to skip version check.", + category=UserWarning, + stacklevel=4, ) elif not is_compatible(client_version, server_version): - warnings.warn( - f"Qdrant client version {client_version} is incompatible with server version {server_version}. Major versions should match and minor version difference must not exceed 1. Set check_version=False to skip version check." + show_warning( + message=f"Qdrant client version {client_version} is incompatible with server version {server_version}. Major versions should match and minor version difference must not exceed 1. Set check_version=False to skip version check.", + category=UserWarning, + stacklevel=4, ) @property @@ -287,7 +291,6 @@ def _init_grpc_root_client(self) -> None: self._init_grpc_channel() self._grpc_root_client = grpc.QdrantStub(self._grpc_channel) - @property def grpc_collections(self) -> grpc.CollectionsStub: """gRPC client for collections methods From c6151f01ba1948b8df1b24e503d9bf3f4ac5d371 Mon Sep 17 00:00:00 2001 From: hh-space-invader Date: Mon, 6 Jan 2025 13:05:38 +0200 Subject: [PATCH 13/16] Updated warnings --- qdrant_client/local/async_qdrant_local.py | 1 - qdrant_client/local/qdrant_local.py | 1 - 2 files changed, 2 deletions(-) diff --git a/qdrant_client/local/async_qdrant_local.py b/qdrant_client/local/async_qdrant_local.py index df98e0d2..6ddf4fee 100644 --- a/qdrant_client/local/async_qdrant_local.py +++ b/qdrant_client/local/async_qdrant_local.py @@ -112,7 +112,6 @@ def _load(self) -> None: show_warning( f"Local mode is not recommended for collections with more than {self.LARGE_DATA_THRESHOLD:,} points. Collection <{collection_name}> contains {len(collection.ids)} points. Consider using Qdrant in Docker or Qdrant Cloud for better performance with large datasets.", category=UserWarning, - idx="large-local-collection", stacklevel=6, ) self.aliases = meta["aliases"] diff --git a/qdrant_client/local/qdrant_local.py b/qdrant_client/local/qdrant_local.py index b1c94e49..93b20761 100644 --- a/qdrant_client/local/qdrant_local.py +++ b/qdrant_client/local/qdrant_local.py @@ -120,7 +120,6 @@ def _load(self) -> None: "Consider using Qdrant in Docker or Qdrant Cloud for better performance " "with large datasets.", category=UserWarning, - idx="large-local-collection", stacklevel=6, ) self.aliases = meta["aliases"] From 976f7ea0bb2e5859320cf818247a27cf2190bcdc Mon Sep 17 00:00:00 2001 From: George Panchuk Date: Mon, 6 Jan 2025 14:14:59 +0100 Subject: [PATCH 14/16] fix: fix warning level --- qdrant_client/local/async_qdrant_local.py | 2 +- qdrant_client/local/qdrant_local.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qdrant_client/local/async_qdrant_local.py b/qdrant_client/local/async_qdrant_local.py index 6ddf4fee..ae88e63b 100644 --- a/qdrant_client/local/async_qdrant_local.py +++ b/qdrant_client/local/async_qdrant_local.py @@ -112,7 +112,7 @@ def _load(self) -> None: show_warning( f"Local mode is not recommended for collections with more than {self.LARGE_DATA_THRESHOLD:,} points. Collection <{collection_name}> contains {len(collection.ids)} points. Consider using Qdrant in Docker or Qdrant Cloud for better performance with large datasets.", category=UserWarning, - stacklevel=6, + stacklevel=5, ) self.aliases = meta["aliases"] lock_file_path = os.path.join(self.location, ".lock") diff --git a/qdrant_client/local/qdrant_local.py b/qdrant_client/local/qdrant_local.py index 93b20761..f6c02c0f 100644 --- a/qdrant_client/local/qdrant_local.py +++ b/qdrant_client/local/qdrant_local.py @@ -120,7 +120,7 @@ def _load(self) -> None: "Consider using Qdrant in Docker or Qdrant Cloud for better performance " "with large datasets.", category=UserWarning, - stacklevel=6, + stacklevel=5, ) self.aliases = meta["aliases"] From a2e3efdc46585d4e130eef646d6907e465bc6591 Mon Sep 17 00:00:00 2001 From: George Panchuk Date: Mon, 6 Jan 2025 14:28:30 +0100 Subject: [PATCH 15/16] fix: fix warning level in async --- qdrant_client/async_qdrant_remote.py | 4 ++-- .../transformers/remote/function_def_transformer.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qdrant_client/async_qdrant_remote.py b/qdrant_client/async_qdrant_remote.py index a0f7570f..3f3948e3 100644 --- a/qdrant_client/async_qdrant_remote.py +++ b/qdrant_client/async_qdrant_remote.py @@ -196,7 +196,7 @@ async def close(self, grpc_grace: Optional[float] = None, **kwargs: Any) -> None show_warning( message="Unable to close grpc_channel. Connection was interrupted on the server side", category=UserWarning, - stacklevel=5, + stacklevel=4, ) except RuntimeError: pass @@ -206,7 +206,7 @@ async def close(self, grpc_grace: Optional[float] = None, **kwargs: Any) -> None show_warning( message="Unable to close http connection. Connection was interrupted on the server side", category=UserWarning, - stacklevel=5, + stacklevel=4, ) self._closed = True diff --git a/tools/async_client_generator/transformers/remote/function_def_transformer.py b/tools/async_client_generator/transformers/remote/function_def_transformer.py index c601e985..b8764f42 100644 --- a/tools/async_client_generator/transformers/remote/function_def_transformer.py +++ b/tools/async_client_generator/transformers/remote/function_def_transformer.py @@ -45,7 +45,7 @@ async def close(self, grpc_grace: Optional[float] = None, **kwargs: Any) -> None show_warning( message="Unable to close grpc_channel. Connection was interrupted on the server side", category=UserWarning, - stacklevel=5, + stacklevel=4, ) except RuntimeError: pass @@ -56,7 +56,7 @@ async def close(self, grpc_grace: Optional[float] = None, **kwargs: Any) -> None show_warning( message="Unable to close http connection. Connection was interrupted on the server side", category=UserWarning, - stacklevel=5, + stacklevel=4, ) self._closed = True From 88237868b877a2d495379f023023209d6dcb5c2e Mon Sep 17 00:00:00 2001 From: George Panchuk Date: Mon, 6 Jan 2025 16:18:32 +0100 Subject: [PATCH 16/16] fix: revert append payload condition --- qdrant_client/async_qdrant_remote.py | 2 +- qdrant_client/qdrant_remote.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qdrant_client/async_qdrant_remote.py b/qdrant_client/async_qdrant_remote.py index 3f3948e3..dbab97be 100644 --- a/qdrant_client/async_qdrant_remote.py +++ b/qdrant_client/async_qdrant_remote.py @@ -381,7 +381,7 @@ async def search( timeout: Optional[int] = None, **kwargs: Any, ) -> list[types.ScoredPoint]: - if append_payload is not None: + if not append_payload: show_warning_once( message="Usage of `append_payload` is deprecated. Please consider using `with_payload` instead", category=DeprecationWarning, diff --git a/qdrant_client/qdrant_remote.py b/qdrant_client/qdrant_remote.py index 1b2288e1..47797ff3 100644 --- a/qdrant_client/qdrant_remote.py +++ b/qdrant_client/qdrant_remote.py @@ -426,7 +426,7 @@ def search( timeout: Optional[int] = None, **kwargs: Any, ) -> list[types.ScoredPoint]: - if append_payload is not None: + if not append_payload: show_warning_once( message="Usage of `append_payload` is deprecated. Please consider using `with_payload` instead", category=DeprecationWarning,