Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] bench: add test_plots_diff #352

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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}",
)
Comment on lines +8 to +28
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to generate it each time? If I'm running this benchmark locally, trying to optimize plots show, I will be wasting a lot of time re-generating this over and over and over again. Could you just save plots files somewhere so that we can also use them later in other tests? Also, do you really need to create a stage? Can we just plots show target or something, or would that not test the same thing in this scenario?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it also illustrates the point that we have more and more non-data benchmarks these days, and similar to a standard dataset (mnist), we need some kind of standard repository with experiments, params, etc. Thinking how to formalize this in a nice way longterm...

Copy link
Member

@efiop efiop Jun 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a similar pain with exp show, so created a simple helper in #359 Please take a look.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, do you really need to create a stage? Can we just plots show target or something, or would that not test the same thing in this scenario?

In any case we need to go through stages to check if some plot matches the targets, so I think that would still test the same thing, even if we were to just provide the targets.

we need some kind of standard repository with experiments, params, etc.

It won't work in this particular case - some generic problems will not have enough metrics/plots to observe the root problem of plots slow performance. Maybe we should create a standard repository that would have different edge cases as branches? Like for this issue: plots_show_test branch could have an additional stage copying the plots multiple times. That way we could have a generic project (main) but some more artificial cases could be kept separate and not occlude whats going on in the repo. Also, we would not have to reproduce it upon runs, put just do git checkout && dvc checkout when testing.


bench_dvc("plots", "show")

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