Skip to content

Commit

Permalink
bench: add test_plots_diff
Browse files Browse the repository at this point in the history
  • Loading branch information
pared committed Jun 1, 2022
1 parent f6f1e68 commit 7c2c48b
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/benchmarks/cli/commands/test_plots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from textwrap import dedent

import pytest


@pytest.fixture
def repo_with_plots(tmp_dir, scm, dvc):
num_points = 1000
num_files = 50

CODE = dedent(
"""
import json
import sys
num_points=int(sys.argv[1])
num_files=int(sys.argv[2])
metric = [{'m':(i/num_points)**2} for i in range(0, num_points)]
for i in range(num_files):
with open(f'metric_{i}.json', 'w') as fd:
json.dump(metric, fd)
"""
)

tmp_dir.gen("train.py", CODE)

dvc.run(
name=f"generate_plots",
deps=["train.py"],
plots=[f"metric_{i}.json" for i in range(num_files)],
cmd=f"python train.py {num_points} {num_files}",
)

scm.add(["dvc.lock", "dvc.yaml"])
scm.commit("initial run")

yield


def test_plots_diff(tmp_dir, bench_dvc, repo_with_plots):
bench_dvc("plots", "show")

assert (tmp_dir / "dvc_plots" / "index.html").is_file()

0 comments on commit 7c2c48b

Please sign in to comment.