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

add interaction env_check cmd

上级 d97761f3
...@@ -31,12 +31,13 @@ inference_test_cases = ["test_fit_a_line.py::TestFitALine::test_inference"] ...@@ -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"] 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"] 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 old_stdout, old_stderr = sys.stdout, sys.stderr
real_path = os.path.dirname(os.path.realpath(__file__)) real_path = os.path.dirname(os.path.realpath(__file__))
for case in cases_list: for case in cases_list:
sys.stdout = open('/dev/null', 'w') if is_open_std is False:
sys.stderr = open('/dev/null', 'w') sys.stdout = open('/dev/null', 'w')
sys.stderr = open('/dev/null', 'w')
args_str = "--disable-warnings " + str(real_path) + "/" + case args_str = "--disable-warnings " + str(real_path) + "/" + case
args = args_str.split(" ") args = args_str.split(" ")
res = pytest.main(args) res = pytest.main(args)
...@@ -54,10 +55,19 @@ def run_test_cases(cases_list, case_type): ...@@ -54,10 +55,19 @@ def run_test_cases(cases_list, case_type):
def unset_proxy(key): def unset_proxy(key):
os.unsetenv(key) os.unsetenv(key)
def check_env(): def check_env(mode):
if 'https_proxy' in os.environ or 'http_proxy' in os.environ: if 'https_proxy' in os.environ or 'http_proxy' in os.environ:
unset_proxy("https_proxy") unset_proxy("https_proxy")
unset_proxy("http_proxy") unset_proxy("http_proxy")
run_test_cases(inference_test_cases, "PaddlePaddle") is_open_std = False
run_test_cases(cpp_test_cases, "C++") if mode is "debug":
run_test_cases(pipeline_test_cases, "Pipeline") 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 ...@@ -35,6 +35,7 @@ from paddle_serving_server.env import CONF_HOME
import signal import signal
from paddle_serving_server.util import * from paddle_serving_server.util import *
from paddle_serving_server.env_check.run import check_env from paddle_serving_server.env_check.run import check_env
import cmd
# web_service.py is still used by Pipeline. # web_service.py is still used by Pipeline.
...@@ -471,6 +472,35 @@ def stop_serving(command: str, port: int=None): ...@@ -471,6 +472,35 @@ def stop_serving(command: str, port: int=None):
os.remove(filepath) os.remove(filepath)
return True 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__": if __name__ == "__main__":
# args.device is not used at all. # args.device is not used at all.
...@@ -488,8 +518,7 @@ if __name__ == "__main__": ...@@ -488,8 +518,7 @@ if __name__ == "__main__":
else: else:
os._exit(-1) os._exit(-1)
elif args.server == "check": elif args.server == "check":
check_env() Check_Env_Shell().cmdloop()
os._exit(0)
for single_model_config in args.model: for single_model_config in args.model:
if os.path.isdir(single_model_config): if os.path.isdir(single_model_config):
pass pass
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册