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 d252cbc commit d0491fd
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/benchmarks/cli/commands/test_plots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from textwrap import dedent


def test_plots_diff(tmp_dir, bench_dvc, 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}",
)

bench_dvc("plots", "show")

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

0 comments on commit d0491fd

Please sign in to comment.