From eee34e8b6e220f596c1cc7cffe3452401f471909 Mon Sep 17 00:00:00 2001 From: Andrey Vasnetsov Date: Thu, 18 Apr 2024 17:26:46 +0200 Subject: [PATCH] deprecate recreate_collection (#601) * add deprecation warning * async client * fmt * fix: replace logging.warning with warnings.warn * refactoring: update warning --------- Co-authored-by: George Panchuk --- qdrant_client/async_qdrant_client.py | 5 +++++ qdrant_client/qdrant_client.py | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/qdrant_client/async_qdrant_client.py b/qdrant_client/async_qdrant_client.py index 4ac2b1b8..6caab749 100644 --- a/qdrant_client/async_qdrant_client.py +++ b/qdrant_client/async_qdrant_client.py @@ -1750,6 +1750,11 @@ async def recreate_collection( Operation result """ assert len(kwargs) == 0, f"Unknown arguments: {list(kwargs.keys())}" + warnings.warn( + "`recreate_collection` method is deprecated and will be removed in the future. Use `collection_exists` to check collection existence and `create_collection` instead.", + DeprecationWarning, + stacklevel=2, + ) return await self._client.recreate_collection( collection_name=collection_name, vectors_config=vectors_config, diff --git a/qdrant_client/qdrant_client.py b/qdrant_client/qdrant_client.py index e2a3d2c3..38e47ebf 100644 --- a/qdrant_client/qdrant_client.py +++ b/qdrant_client/qdrant_client.py @@ -1745,6 +1745,8 @@ def create_collection( **kwargs, ) + # WARN: This method is deprecated and will be removed in the future + # Use separate check for collection existence and `create_collection` instead def recreate_collection( self, collection_name: str, @@ -1812,6 +1814,13 @@ def recreate_collection( """ assert len(kwargs) == 0, f"Unknown arguments: {list(kwargs.keys())}" + warnings.warn( + "`recreate_collection` method is deprecated and will be removed in the future." + " Use `collection_exists` to check collection existence and `create_collection` instead.", + DeprecationWarning, + stacklevel=2, + ) + return self._client.recreate_collection( collection_name=collection_name, vectors_config=vectors_config,