Activate OV environment from cond comp test_infer (#4244)

This commit is contained in:
Andrey Somsikov authored and GitHub committed 2021-02-11 09:59:37 +03:00
1 parent b7212b9f34
commit 8da7f22f1d
4 files changed
+48 -7

No files matched your search

@@ -38,19 +38,16 @@ def pytest_addoption(parser):
)
parser.addoption(
"--sea_runtool",
required=True,
type=Path,
help="Path to sea_runtool.py"
)
parser.addoption(
"--benchmark_app",
required=True,
type=Path,
help="Path to the benchmark_app tool",
)
parser.addoption(
"--collector_dir",
required=True,
type=Path,
help="Path to a directory with a collector binary",
)
+8 -3
View File
@@ -4,14 +4,19 @@
""" Test inference with conditional compiled binaries.
"""
import sys
from proc_utils import cmd_exec # pylint: disable=import-error
from install_pkg import get_openvino_environment # pylint: disable=import-error
def test_infer(model, benchmark_app):
def test_infer(test_id, model, artifacts):
""" Test inference with conditional compiled binaries
"""
install_prefix = artifacts / test_id / "install_pkg"
exe_suffix = ".exe" if sys.platform == "win32" else ""
benchmark_app = install_prefix / "bin" / f"benchmark_app{exe_suffix}"
returncode, _ = cmd_exec(
[str(benchmark_app), "-d=CPU", f"-m={model}", "-niter=1", "-nireq=1"]
[str(benchmark_app), "-d=CPU", f"-m={model}", "-niter=1", "-nireq=1"],
env=get_openvino_environment(install_prefix),
)
assert returncode == 0, f"Command exited with non-zero status {returncode}"
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env python3
# Copyright (C) 2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
""" Common utilities for OpenVINO install package.
"""
import sys
from pathlib import Path
from proc_utils import get_env_from # pylint: disable=import-error
def get_openvino_environment(install_prefix: Path):
""" Get OpenVINO environment variables
"""
script = "setupvars.bat" if sys.platform == "win32" else "setupvars.sh"
return get_env_from(install_prefix / "bin" / script)
+24 -1
View File
@@ -5,11 +5,33 @@
""" Common utilities for working with processes.
"""
import errno
import os
import logging
import subprocess
import sys
def cmd_exec(args, log=None, verbose=True):
def get_env_from(script):
""" Get environment set by a shell script
"""
if not os.path.exists(str(script)):
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), str(script))
env = {}
if sys.platform == "win32":
cmd = f'"{script}" && set'
else:
cmd = f'source "{script}" && env'
dump = subprocess.check_output(cmd, shell=True, universal_newlines=True).strip()
for line in dump.split("\n"):
# split by first '='
pair = [str(val).strip() for val in line.split("=", 1)]
if len(pair) > 1 and pair[0]: # ignore invalid entries
env[pair[0]] = pair[1]
return env
def cmd_exec(args, env=None, log=None, verbose=True):
""" Run cmd using subprocess with logging and other improvements
"""
if log is None:
@@ -22,6 +44,7 @@ def cmd_exec(args, log=None, verbose=True):
proc = subprocess.Popen(
args,
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
encoding="utf-8",