Skip to content

Commit

Permalink
ci (bench): skip benchmark for test_import on versions >=3.53,<3.54.1
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry committed Aug 20, 2024
1 parent 2dcaea8 commit f60c225
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
4 changes: 0 additions & 4 deletions dvc/testing/benchmarks/cli/commands/test_data_status.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
from shutil import rmtree

import pytest

pytestmark = pytest.mark.requires(minversion=(2, 15, 0), reason="new command")


def test_data_status(bench_dvc, tmp_dir, scm, dvc, make_dataset):
args = ("data", "status")
Expand Down
4 changes: 0 additions & 4 deletions dvc/testing/benchmarks/cli/commands/test_exp_show.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import pytest


@pytest.mark.requires(minversion=(2, 28, 0))
def test_exp_show(make_project, monkeypatch, bench_dvc, dvc_bin):
url = "https://github.com/iterative/example-get-started"
rev = "main"
Expand Down
6 changes: 6 additions & 0 deletions dvc/testing/benchmarks/cli/commands/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@


@pytest.mark.flaky(reruns=3)
@pytest.mark.requires(
"!=3.53.*,!=3.54.0",
reason="Takes 10 mins to run. Regression in 3.53.0, fixed in 3.54.1",
)
# Introduced in https://github.com/iterative/dvc/pull/10388.
# Fixed in https://github.com/iterative/dvc/pull/10531.
def test_import(bench_dvc, tmp_dir, scm, dvc, make_dataset, remote):
dataset = make_dataset(
cache=False, files=False, dvcfile=True, commit=True, remote=True
Expand Down
3 changes: 0 additions & 3 deletions dvc/testing/benchmarks/cli/commands/test_plots.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import pytest

from dvc.repo import Repo
from dvc.testing.benchmarks.fixtures import _pull


@pytest.mark.requires(minversion=(2, 34, 0), reason="top-level plots not supported")
def test_plots(project, bench_dvc):
with Repo() as dvc:
_pull(dvc)
Expand Down
24 changes: 13 additions & 11 deletions dvc/testing/benchmarks/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,19 @@ def parse_tuple(version_string):
@pytest.fixture
def dvc_bin(request, make_dvc_bin):
if marker := request.node.get_closest_marker("requires"):
minversion = marker.kwargs.get("minversion") or first(marker.args)
assert minversion, (
"'minversion' needs to be specified as"
" a positional or a keyword argument"
)
reason = marker.kwargs.get("reason", "")
if isinstance(minversion, str):
minversion = parse_tuple(minversion)
if make_dvc_bin.version < minversion:
version_repr = ".".join(map(str, minversion))
pytest.skip(f"requires dvc>={version_repr}: {reason}")
from packaging.specifiers import SpecifierSet
from packaging.version import Version

spec = first(marker.args)
assert spec is not None
spec = SpecifierSet(spec) if isinstance(spec, str) else spec
reason = marker.kwargs["reason"]
dvc_version = ".".join(map(str, make_dvc_bin.version))
if Version(dvc_version) not in spec:
pytest.skip(
f"Version {dvc_version} "
f"does not satisfy requirement {spec!r}: {reason}"
)
return make_dvc_bin


Expand Down
3 changes: 2 additions & 1 deletion dvc/testing/benchmarks/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def __init__(self):

def pytest_configure(config):
config.addinivalue_line(
"markers", "requires(minversion): mark a test as requiring minimum DVC version"
"markers",
"requires(spec): mark a test to run only on versions that satisfy the spec",
)

config.bench_config = DVCBenchConfig()
Expand Down

0 comments on commit f60c225

Please sign in to comment.