testing.benchmarks: support installing remote deps in benchmark venv

This commit is contained in:
Peter Rowlands
2023-05-03 18:19:31 +09:00
committed by Peter Rowlands (변기호)
parent 6c79f6bbfc
commit e362438f03
2 changed files with 16 additions and 2 deletions
+7 -2
View File
@@ -1,5 +1,6 @@
import os
import shutil
from pathlib import Path
from subprocess import check_output # nosec B404
import pytest
@@ -48,7 +49,7 @@ def dvc_bench_git_repo(tmp_path_factory, bench_config):
url = bench_config.dvc_bench_git_repo
if os.path.isdir(url):
return url
return Path(url)
tmp_path = tmp_path_factory.mktemp("dvc-bench-git-repo")
clone(url, os.fspath(tmp_path))
@@ -70,9 +71,13 @@ def dvc_bin(
if not venv:
venv = make_dvc_venv(dvc_rev)
venv.run("pip install -U pip")
if bench_config.dvc_install_deps:
egg = f"dvc[{bench_config.dvc_install_deps}]"
else:
egg = "dvc"
venv.run(f"pip install git+file://{dvc_git_repo}@{dvc_rev}#egg={egg}")
if dvc_rev in ["2.18.1", "2.11.0", "2.6.3"]:
venv.run("pip install fsspec==2022.11.0")
venv.run(f"pip install git+file://{dvc_git_repo}@{dvc_rev}")
dvc_venvs[dvc_rev] = venv
dvc_bin = venv.virtualenv / "bin" / "dvc"
else:
+9
View File
@@ -17,6 +17,7 @@ class DVCBenchConfig:
self.dvc_bin = DEFAULT_DVC_BIN
self.dvc_revs = None
self.dvc_git_repo = DEFAULT_DVC_GIT_REPO
self.dvc_install_deps = None
self.dvc_bench_git_repo = DEFAULT_DVC_BENCH_GIT_REPO
self.project_rev = None
self.project_git_repo = DEFAULT_PROJECT_GIT_REPO
@@ -29,6 +30,7 @@ def pytest_configure(config):
config.bench_config.dvc_bin = config.getoption("--dvc-bin")
config.bench_config.dvc_revs = config.getoption("--dvc-revs")
config.bench_config.dvc_git_repo = config.getoption("--dvc-git-repo")
config.bench_config.dvc_install_deps = config.getoption("--dvc-install-deps")
config.bench_config.dvc_bench_git_repo = config.getoption("--dvc-bench-git-repo")
config.bench_config.project_rev = config.getoption("--project-rev")
config.bench_config.project_git_repo = config.getoption("--project-git-repo")
@@ -62,6 +64,13 @@ def pytest_addoption(parser):
help="Path or url to dvc git repo",
)
parser.addoption(
"--dvc-install-deps",
type=str,
default="",
help="Comma-separated list of DVC installation packages",
)
parser.addoption(
"--dvc-bench-git-repo",
type=str,