From 8926c670c0f85e1dca14cd22e66d04be5eb60dc8 Mon Sep 17 00:00:00 2001 From: Jiquan Long Date: Tue, 30 May 2023 19:21:24 +0800 Subject: [PATCH] Remind users when unimplemented feature was called (#1486) Signed-off-by: longjiquan --- pymilvus/client/grpc_handler.py | 4 ++-- pymilvus/decorators.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pymilvus/client/grpc_handler.py b/pymilvus/client/grpc_handler.py index f6576528a..3a8f35fe6 100644 --- a/pymilvus/client/grpc_handler.py +++ b/pymilvus/client/grpc_handler.py @@ -61,7 +61,7 @@ AmbiguousIndexName, ) -from ..decorators import retry_on_rpc_failure, ignore_unimplemented +from ..decorators import retry_on_rpc_failure, upgrade_reminder from . import entity_helper @@ -1408,7 +1408,7 @@ def _check(): _check() @retry_on_rpc_failure() - @ignore_unimplemented(0) + @upgrade_reminder def __internal_register(self, user, host) -> int: req = Prepare.register_request(user, host) response = self._stub.Connect(request=req) diff --git a/pymilvus/decorators.py b/pymilvus/decorators.py index f57dd3d2c..1571020a9 100644 --- a/pymilvus/decorators.py +++ b/pymilvus/decorators.py @@ -154,3 +154,19 @@ def handler(*args, **kwargs): raise e return handler return wrapper + + +def upgrade_reminder(func): + @functools.wraps(func) + def handler(*args, **kwargs): + try: + return func(*args, **kwargs) + except grpc.RpcError as e: + if e.code() == grpc.StatusCode.UNIMPLEMENTED: + msg = "this version of sdk is incompatible with server, please downgrade your sdk or upgrade your " \ + "server " + raise MilvusException(message=msg) from e + raise e + except Exception as e: + raise e + return handler