Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions tests/cross_fw/examples/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,41 @@ def test_examples(
tmp_path = (PROJECT_ROOT / example_params["requirements"]).parent
venv_path = create_venv_with_nncf(tmp_path, "pip_e_local", "venv", {})
pip_with_venv = get_pip_executable_with_venv(venv_path)
install_wwb = False
if "requirements" in example_params:
requirements = PROJECT_ROOT / example_params["requirements"]

# Install whowhatbench later only if
# explicitly required by the example
with open(requirements, encoding="utf-8") as f:
requirements_content = f.read()
if "whowhatbench" in requirements_content:
install_wwb = True

run_cmd_line = f"{pip_with_venv} install -r {requirements}"
print(f"Installing requirements: {run_cmd_line}")
subprocess.run(run_cmd_line, check=True, shell=True)

if ov_version_override is not None:
ov_version_cmd_line = f"{pip_with_venv} install {ov_version_override}"
uninstall_cmd_line = f"{pip_with_venv} uninstall --yes openvino-genai openvino_tokenizers"
extra_index_url = "https://storage.openvinotoolkit.org/simple/wheels/nightly"
wwb_module_string = "whowhatbench@git+https://github.com/openvinotoolkit/openvino.genai.git#subdirectory=tools/who_what_benchmark"
wwb_override_cmd_line = f"{pip_with_venv} install --pre --extra-index-url {extra_index_url} {wwb_module_string}"
print(f"Installing OpenVINO version override: {ov_version_cmd_line}")
subprocess.run(ov_version_cmd_line, check=True, shell=True)
subprocess.run(uninstall_cmd_line, check=True, shell=True)
subprocess.run(wwb_override_cmd_line, check=True, shell=True)

subprocess.run(f"{pip_with_venv} list", check=True, shell=True)
if install_wwb:
wwb_module_string = "whowhatbench@git+https://github.com/openvinotoolkit/openvino.genai.git#subdirectory=tools/who_what_benchmark"
wwb_override_cmd_line = (
f"{pip_with_venv} install --pre --extra-index-url {extra_index_url} {wwb_module_string}"
)
print(f"Uninstalling OpenVINO packages: {uninstall_cmd_line}")
subprocess.run(uninstall_cmd_line, check=True, shell=True)
print(f"Installing WWB module: {wwb_override_cmd_line}")
subprocess.run(wwb_override_cmd_line, check=True, shell=True)

cmd_list_packages = f"{pip_with_venv} list"
print(f"Listing installed packages: {cmd_list_packages}")
subprocess.run(cmd_list_packages, check=True, shell=True)

env = os.environ.copy()
example_dir = Path(example_params["requirements"]).parent
Expand Down
27 changes: 21 additions & 6 deletions tests/cross_fw/shared/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,26 @@ def create_venv_with_nncf(tmp_path: Path, package_type: str, venv_type: str, bac

if venv_type == "virtualenv":
virtualenv = Path(sys.executable).parent / "virtualenv"
subprocess.check_call(f"{virtualenv} -ppython{version_string} {venv_path}", shell=True)
cmd_create_venv = f"{virtualenv} -ppython{version_string} {venv_path}"
print(f"Creating virtualenv: {cmd_create_venv}")
subprocess.check_call(cmd_create_venv, shell=True)
elif venv_type == "venv":
subprocess.check_call(f"{sys.executable} -m venv {venv_path}", shell=True)
cmd_create_venv = f"{sys.executable} -m venv {venv_path}"
print(f"Creating venv: {cmd_create_venv}")
subprocess.check_call(cmd_create_venv, shell=True)

subprocess.check_call(f"{pip_with_venv} install --upgrade pip", shell=True)
subprocess.check_call(f"{pip_with_venv} install --upgrade wheel setuptools", shell=True)
cmd_upgrade_pip = f"{pip_with_venv} install --upgrade pip"
print(f"Upgrading pip: {cmd_upgrade_pip}")
subprocess.check_call(cmd_upgrade_pip, shell=True)

cmd_upgrade_tools = f"{pip_with_venv} install --upgrade wheel setuptools"
print(f"Upgrading wheel and setuptools: {cmd_upgrade_tools}")
subprocess.check_call(cmd_upgrade_tools, shell=True)

if package_type in ["build_s", "build_w"]:
subprocess.check_call(f"{pip_with_venv} install build", shell=True)
cmd_install_build = f"{pip_with_venv} install build"
print(f"Installing build: {cmd_install_build}")
subprocess.check_call(cmd_install_build, shell=True)

run_path = tmp_path / "run"
run_path.mkdir(exist_ok=True)
Expand All @@ -99,19 +110,23 @@ def create_venv_with_nncf(tmp_path: Path, package_type: str, venv_type: str, bac
msg = f"Invalid package type: {package_type}"
raise ValueError(msg)

print(f"Running package command: {run_cmd_line}")
subprocess.run(run_cmd_line, check=True, shell=True, cwd=PROJECT_ROOT)

if package_type in ["build_s", "build_w"]:
package_path = find_file_by_extension(dist_path, ".tar.gz" if package_type == "build_s" else ".whl")
cmd_install_package = f"{pip_with_venv} install {package_path}"
print(f"Installing package: {cmd_install_package}")
subprocess.run(cmd_install_package, check=True, shell=True)

if backends:
# Install backend specific packages with according version from constraints.txt
packages = [item for b in backends for item in MAP_BACKEND_PACKAGES[b]]
extra_reqs = " ".join(packages)
cmd_install_backends = f"{pip_with_venv} install {extra_reqs} -c {PROJECT_ROOT}/constraints.txt"
print(f"Installing backend packages: {cmd_install_backends}")
subprocess.run(
f"{pip_with_venv} install {extra_reqs} -c {PROJECT_ROOT}/constraints.txt",
cmd_install_backends,
check=True,
shell=True,
cwd=PROJECT_ROOT,
Expand Down