From 260a6b61c0cfb9d5c31b1abb50cf830793ad6a89 Mon Sep 17 00:00:00 2001 From: barrierye Date: Tue, 9 Jun 2020 23:03:42 +0800 Subject: [PATCH] add default postprocess func --- python/examples/fit_a_line/test_py_server.py | 62 ++++++++------------ python/paddle_serving_server/pyserver.py | 6 +- 2 files changed, 26 insertions(+), 42 deletions(-) diff --git a/python/examples/fit_a_line/test_py_server.py b/python/examples/fit_a_line/test_py_server.py index 55e14d3b..345e66be 100644 --- a/python/examples/fit_a_line/test_py_server.py +++ b/python/examples/fit_a_line/test_py_server.py @@ -34,52 +34,40 @@ class CombineOp(Op): for op_name, channeldata in input_data.items(): logging.debug("CombineOp preprocess: {}".format(op_name)) data = channeldata.parse() - cnt += data["prediction"] + cnt += data["price"] data = {"combine_op_output": cnt} return data - def postprocess(self, output_data): - return output_data - - -class UciOp(Op): - def postprocess(self, output_data): - pred = np.array(output_data["price"][0][0], dtype='float32') - data = {"prediction": pred} - return data - read_channel = Channel(name="read_channel") combine_channel = Channel(name="combine_channel") out_channel = Channel(name="out_channel") -uci1_op = UciOp( - name="uci1", - input=read_channel, - outputs=[combine_channel], - server_model="./uci_housing_model", - server_port="9393", - device="cpu", - client_config="uci_housing_client/serving_client_conf.prototxt", - server_name="127.0.0.1:9393", - fetch_names=["price"], - concurrency=1, - timeout=0.1, - retry=2) +uci1_op = Op(name="uci1", + input=read_channel, + outputs=[combine_channel], + server_model="./uci_housing_model", + server_port="9393", + device="cpu", + client_config="uci_housing_client/serving_client_conf.prototxt", + server_name="127.0.0.1:9393", + fetch_names=["price"], + concurrency=1, + timeout=0.1, + retry=2) -uci2_op = UciOp( - name="uci2", - input=read_channel, - outputs=[combine_channel], - server_model="./uci_housing_model", - server_port="9292", - device="cpu", - client_config="uci_housing_client/serving_client_conf.prototxt", - server_name="127.0.0.1:9393", - fetch_names=["price"], - concurrency=1, - timeout=-1, - retry=1) +uci2_op = Op(name="uci2", + input=read_channel, + outputs=[combine_channel], + server_model="./uci_housing_model", + server_port="9292", + device="cpu", + client_config="uci_housing_client/serving_client_conf.prototxt", + server_name="127.0.0.1:9393", + fetch_names=["price"], + concurrency=1, + timeout=-1, + retry=1) combine_op = CombineOp( name="combine", diff --git a/python/paddle_serving_server/pyserver.py b/python/paddle_serving_server/pyserver.py index 73d9caa2..e37a5f90 100644 --- a/python/paddle_serving_server/pyserver.py +++ b/python/paddle_serving_server/pyserver.py @@ -396,11 +396,7 @@ class Op(object): return call_future def postprocess(self, output_data): - raise Exception( - self._log( - 'Please override this method to convert data to the format in channel.' \ - ' The return value format should be in {name(str): var(narray)}' - )) + return output_data def errorprocess(self, error_info, data_id): data = channel_pb2.ChannelData() -- GitLab