提交 011ea89a 编写于 作者: F felixhjh

add interaction env_check cmd

上级 d97761f3
......@@ -31,12 +31,13 @@ inference_test_cases = ["test_fit_a_line.py::TestFitALine::test_inference"]
cpp_test_cases = ["test_fit_a_line.py::TestFitALine::test_cpu", "test_fit_a_line.py::TestFitALine::test_gpu"]
pipeline_test_cases = ["test_uci_pipeline.py::TestUCIPipeline::test_cpu", "test_uci_pipeline.py::TestUCIPipeline::test_gpu"]
def run_test_cases(cases_list, case_type):
def run_test_cases(cases_list, case_type, is_open_std):
old_stdout, old_stderr = sys.stdout, sys.stderr
real_path = os.path.dirname(os.path.realpath(__file__))
for case in cases_list:
sys.stdout = open('/dev/null', 'w')
sys.stderr = open('/dev/null', 'w')
if is_open_std is False:
sys.stdout = open('/dev/null', 'w')
sys.stderr = open('/dev/null', 'w')
args_str = "--disable-warnings " + str(real_path) + "/" + case
args = args_str.split(" ")
res = pytest.main(args)
......@@ -54,10 +55,19 @@ def run_test_cases(cases_list, case_type):
def unset_proxy(key):
os.unsetenv(key)
def check_env():
def check_env(mode):
if 'https_proxy' in os.environ or 'http_proxy' in os.environ:
unset_proxy("https_proxy")
unset_proxy("http_proxy")
run_test_cases(inference_test_cases, "PaddlePaddle")
run_test_cases(cpp_test_cases, "C++")
run_test_cases(pipeline_test_cases, "Pipeline")
is_open_std = False
if mode is "debug":
is_open_std = True
if mode is "all" or mode is "inference" or mode is "debug":
run_test_cases(inference_test_cases, "PaddlePaddle", is_open_std)
if mode is "all" or mode is "cpp" or mode is "debug":
run_test_cases(cpp_test_cases, "C++", is_open_std)
if mode is "all" or mode is "pipeline" or mode is "debug":
run_test_cases(pipeline_test_cases, "Pipeline", is_open_std)
if __name__ == '__main__':
check_env("debug")
......@@ -35,6 +35,7 @@ from paddle_serving_server.env import CONF_HOME
import signal
from paddle_serving_server.util import *
from paddle_serving_server.env_check.run import check_env
import cmd
# web_service.py is still used by Pipeline.
......@@ -471,6 +472,35 @@ def stop_serving(command: str, port: int=None):
os.remove(filepath)
return True
class Check_Env_Shell(cmd.Cmd):
intro = 'Welcome to the check env shell.Type help or ? to list commands.\n'
#prompt = '(check) '
# ----- basic commands -----
def do_check_all(self, arg):
'Check Environment of Paddle Inference, Pipeline Serving, C++ Serving'
check_env("all")
def do_check_pipeline(self, arg):
'Check Environment of Pipeline Serving'
check_env("pipeline")
def do_check_cpp(self, arg):
'Check Environment of C++ Serving'
check_env("cpp")
def do_check_inference(self, arg):
'Check Environment of Paddle Inference'
check_env("inference")
def do_debug(self, arg):
'Open pytest log to debug'
check_env("debug")
def do_exit(self, arg):
'Exit Check Env Shell'
print('Check Environment Shell Exit')
os._exit(0)
return True
if __name__ == "__main__":
# args.device is not used at all.
......@@ -488,8 +518,7 @@ if __name__ == "__main__":
else:
os._exit(-1)
elif args.server == "check":
check_env()
os._exit(0)
Check_Env_Shell().cmdloop()
for single_model_config in args.model:
if os.path.isdir(single_model_config):
pass
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册