-
Notifications
You must be signed in to change notification settings - Fork 10
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
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 justplots show target
or something, or would that not test the same thing in this scenario?There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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 dogit checkout && dvc checkout
when testing.