From 0b09eed62ad2baa58ae31fc27667a6a3940b7b89 Mon Sep 17 00:00:00 2001 From: barrierye Date: Thu, 18 Jun 2020 16:56:34 +0800 Subject: [PATCH] fix bug --- .../proto/multi_lang_general_model_service.proto | 1 + python/paddle_serving_client/__init__.py | 4 ++-- python/paddle_serving_server/__init__.py | 13 +++++++------ python/paddle_serving_server_gpu/__init__.py | 13 +++++++------ 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/core/configure/proto/multi_lang_general_model_service.proto b/core/configure/proto/multi_lang_general_model_service.proto index 6e1764b2..2fae73e5 100644 --- a/core/configure/proto/multi_lang_general_model_service.proto +++ b/core/configure/proto/multi_lang_general_model_service.proto @@ -38,6 +38,7 @@ message Request { message Response { repeated ModelOutput outputs = 1; optional string tag = 2; + optional bool brpc_predict_error = 3; }; message ModelOutput { diff --git a/python/paddle_serving_client/__init__.py b/python/paddle_serving_client/__init__.py index 2ba0e6e6..79f60ad1 100644 --- a/python/paddle_serving_client/__init__.py +++ b/python/paddle_serving_client/__init__.py @@ -500,9 +500,9 @@ class MultiLangClient(object): return req def _unpack_resp(self, resp, fetch, is_python, need_variant_tag): - tag = resp.tag if resp.brpc_predict_error: - return None if not need_variant_tag else [None, tag] + return None + tag = resp.tag multi_result_map = {} for model_result in resp.outputs: inst = model_result.insts[0] diff --git a/python/paddle_serving_server/__init__.py b/python/paddle_serving_server/__init__.py index 81c89087..963de560 100644 --- a/python/paddle_serving_server/__init__.py +++ b/python/paddle_serving_server/__init__.py @@ -517,12 +517,13 @@ class MultiLangServerService( feed_batch.append(feed_dict) return feed_batch, fetch_names, is_python - def _pack_resp_package(self, results, fetch_names, is_python, tag): + def _pack_resp_package(self, ret, fetch_names, is_python): resp = multi_lang_general_model_service_pb2.Response() - resp.tag = tag - if results is None: + if ret is None: resp.brpc_predict_error = True - return + return resp + results, tag = ret + resp.tag = tag resp.brpc_predict_error = False if not self.is_multi_model_: results = {'general_infer_0': results} @@ -555,9 +556,9 @@ class MultiLangServerService( def inference(self, request, context): feed_dict, fetch_names, is_python = self._unpack_request(request) - data, tag = self.bclient_.predict( + ret = self.bclient_.predict( feed=feed_dict, fetch=fetch_names, need_variant_tag=True) - return self._pack_resp_package(data, fetch_names, is_python, tag) + return self._pack_resp_package(ret, fetch_names, is_python) class MultiLangServer(object): diff --git a/python/paddle_serving_server_gpu/__init__.py b/python/paddle_serving_server_gpu/__init__.py index 9da5f796..43279d91 100644 --- a/python/paddle_serving_server_gpu/__init__.py +++ b/python/paddle_serving_server_gpu/__init__.py @@ -566,12 +566,13 @@ class MultiLangServerService( feed_batch.append(feed_dict) return feed_batch, fetch_names, is_python - def _pack_resp_package(self, results, fetch_names, is_python, tag): + def _pack_resp_package(self, ret, fetch_names, is_python): resp = multi_lang_general_model_service_pb2.Response() - resp.tag = tag - if results is None: + if ret is None: resp.brpc_predict_error = True - return + return resp + results, tag = ret + resp.tag = tag resp.brpc_predict_error = False if not self.is_multi_model_: results = {'general_infer_0': results} @@ -604,9 +605,9 @@ class MultiLangServerService( def inference(self, request, context): feed_dict, fetch_names, is_python = self._unpack_request(request) - data, tag = self.bclient_.predict( + ret = self.bclient_.predict( feed=feed_dict, fetch=fetch_names, need_variant_tag=True) - return self._pack_resp_package(data, fetch_names, is_python, tag) + return self._pack_resp_package(ret, fetch_names, is_python) class MultiLangServer(object): -- GitLab