提交 9781fbe1 编写于 作者: B bjjwwang

fix paddle-serving-server

上级 f8d72c68
......@@ -28,5 +28,6 @@ from paddle_serving_server import (
from .dag import *
from .server import *
from .util import *
__version__ = version.version_tag
......@@ -131,3 +131,53 @@ def load_pid_file(filepath: str):
os.remove(filepath)
print("ProcessInfo.json file is empty, All processes of PaddleServing has been stopped.")
return False
import yaml
from argparse import ArgumentParser,RawDescriptionHelpFormatter
class ArgsParser(ArgumentParser):
def __init__(self):
super(ArgsParser, self).__init__(
formatter_class=RawDescriptionHelpFormatter)
self.add_argument("-c", "--config", help="configuration file to use")
self.add_argument(
"-o", "--opt", nargs='+', help="set configuration options")
def parse_args(self, argv=None):
args = super(ArgsParser, self).parse_args(argv)
assert args.config is not None, \
"Please specify --config=configure_file_path."
args.conf_dict = self._parse_opt(args.opt, args.config)
return args
def _parse_helper(self, v):
if v.isnumeric():
if "." in v:
v = float(v)
else:
v = int(v)
elif v == "True" or v == "False":
v = (v == "True")
return v
def _parse_opt(self, opts, conf_path):
f = open(conf_path)
config = yaml.load(f, Loader=yaml.Loader)
if not opts:
return config
for s in opts:
s = s.strip()
k, v = s.split('=')
v = self._parse_helper(v)
cur = config
parent = cur
for kk in k.split("."):
if kk not in cur:
cur[kk] = {}
parent = cur
cur = cur[kk]
else:
parent = cur
cur = cur[kk]
parent[k.split(".")[-1]] = v
return config
......@@ -53,7 +53,7 @@ class WebService(object):
def get_pipeline_response(self, read_op):
return None
def prepare_pipeline_config(self, yaml_file):
def prepare_pipeline_config(self, yml_file=None, yml_dict=None):
# build dag
read_op = pipeline.RequestOp()
last_op = self.get_pipeline_response(read_op)
......@@ -63,7 +63,7 @@ class WebService(object):
"`get_pipeline_response`.")
response_op = pipeline.ResponseOp(input_ops=[last_op])
self._server.set_response_op(response_op)
self._server.prepare_server(yaml_file)
self._server.prepare_server(yml_file=yml_file, yml_dict=yml_dict)
def run_service(self):
self._server.run_server()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册