[Memory tests] Add timeout to proc_exec (#7942)

* add timeout to proc_exec

* add framework field for db

* upd db fields name
This commit is contained in:
Victor Kuznetsov
2021-10-13 14:25:44 +03:00
committed by GitHub
parent b746c734f8
commit 9e79f997e4
4 changed files with 13 additions and 12 deletions

View File

@@ -75,7 +75,7 @@ def run_memorytest(args: dict, log=None):
stats = {}
for run_iter in range(args["niter"]):
tmp_stats_path = tempfile.NamedTemporaryFile().name
retcode, msg = cmd_exec(cmd_common + ["-s", str(tmp_stats_path)], log=log)
retcode, msg = cmd_exec(cmd_common + ["-s", str(tmp_stats_path)], timeout=60, log=log)
if retcode != 0:
log.error("Run of executable '{}' failed with return code '{}'. Error: {}\n"
"Statistics aggregation is skipped.".format(args["executable"], retcode, msg))

View File

@@ -214,9 +214,9 @@ def omz_models_conversion(instance, request):
logging.error(f"Please specify precision for the model "
f"{model_name} from the list: {model_info['precisions']}")
model_out_path = Path(omz_models_out_dir / model_info["subdirectory"]) / model_precision / (
model_name + ".xml")
model_full_path = omz_irs_out_dir / model_info["subdirectory"] / model_precision / (model_name + ".xml")
sub_model_path = str(Path(model_info["subdirectory"]) / model_precision / (model_name + ".xml"))
model_out_path = omz_models_out_dir / sub_model_path
model_irs_out_path = omz_irs_out_dir / sub_model_path
# prepare models and convert models to IRs
cmd = [f'{sys.executable}', f'{downloader_path}', '--name', f'{model_name}',
@@ -233,9 +233,11 @@ def omz_models_conversion(instance, request):
return_code, _ = cmd_exec(cmd, log=logging)
assert return_code == 0, "Converting OMZ models has failed!"
instance["instance"]["model"]["framework"] = model_info["framework"]
instance["instance"]["model"]["path"] = model_out_path
instance["instance"]["model"]["full_path"] = model_full_path
instance["orig_instance"]["model"]["framework"] = model_info["framework"]
instance["orig_instance"]["model"]["path"] = sub_model_path
instance["instance"]["model"]["cache_path"] = model_out_path
instance["instance"]["model"]["irs_out_path"] = model_irs_out_path
@pytest.fixture(scope="function")
@@ -340,7 +342,6 @@ def prepare_db_info(request, instance, executable, niter, manifest_metadata):
"model": {
"type": "object",
"properties": {
"path": {"type": "string"},
"name": {"type": "string"},
"precision": {"type": "string"},
"framework": {"type": "string"}

View File

@@ -42,8 +42,8 @@ def test(instance, executable, niter, temp_dir, omz_models_conversion, validate_
"""
# Prepare model to get model_path
model_path = ''
cache_model_path = instance["instance"]["model"].get("path")
irs_model_path = instance["instance"]["model"].get("full_path")
cache_model_path = instance["instance"]["model"].get("cache_path")
irs_model_path = instance["instance"]["model"].get("irs_out_path")
if os.path.isfile(irs_model_path):
model_path = irs_model_path

View File

@@ -10,7 +10,7 @@ import logging
import subprocess
def cmd_exec(args, env=None, log=None, verbose=True, shell=False):
def cmd_exec(args, timeout=None, env=None, log=None, verbose=True, shell=False):
""" Run cmd using subprocess with logging and other improvements
"""
if log is None:
@@ -37,7 +37,7 @@ def cmd_exec(args, env=None, log=None, verbose=True, shell=False):
if line or proc.poll() is None:
continue
break
outs = proc.communicate()[0]
outs = proc.communicate(timeout=timeout)[0]
if outs:
log_out(outs.strip("\n"))