From 07a38d78891d0c1a9c576558b44f023eaf60d734 Mon Sep 17 00:00:00 2001 From: wangjiawei04 Date: Mon, 10 Aug 2020 22:45:16 +0800 Subject: [PATCH] add debugger to webservice --- python/paddle_serving_server/web_service.py | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/python/paddle_serving_server/web_service.py b/python/paddle_serving_server/web_service.py index b0c1b79b..22b16034 100755 --- a/python/paddle_serving_server/web_service.py +++ b/python/paddle_serving_server/web_service.py @@ -91,6 +91,8 @@ class WebService(object): request.json["fetch"]) if isinstance(feed, dict) and "fetch" in feed: del feed["fetch"] + if len(feed) == 0: + raise ValueError("empty input") fetch_map = self.client.predict(feed=feed, fetch=fetch) result = self.postprocess( feed=request.json["feed"], fetch=fetch, fetch_map=fetch_map) @@ -122,6 +124,32 @@ class WebService(object): self.app_instance = app_instance + def run_debugger_service(self): + import socket + localIP = socket.gethostbyname(socket.gethostname()) + print("web service address:") + print("http://{}:{}/{}/prediction".format(localIP, self.port, + self.name)) + app_instance = Flask(__name__) + + @app_instance.before_first_request + def init(): + self._launch_local_predictor() + + service_name = "/" + self.name + "/prediction" + + @app_instance.route(service_name, methods=["POST"]) + def run(): + return self.get_prediction(request) + + self.app_instance = app_instance + + def _launch_local_predictor(self): + from paddle_serving_app.local_predict import Debugger + self.client = Debugger() + self.client.load_model_config( + "{}".format(self.model_config), gpu=False, profile=False) + def run_web_service(self): self.app_instance.run(host="0.0.0.0", port=self.port, -- GitLab