-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Remove a special queued experiments #6393
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4dca420
Remove a special queued experiments
karajan1001 25fe483
Extract tests and add revision support
karajan1001 443e17b
Accept shortened revisions
karajan1001 ad59b4b
Split removing committed and queued exp functions
karajan1001 d56aae8
Api name change
karajan1001 e2b3cba
Return to the old API name
karajan1001 afb596d
shorten some functions
karajan1001 870a04c
Error message change
karajan1001 da7849f
Better test cases, more corner case
karajan1001 8af4038
Still raise exception in a mixed case
karajan1001 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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
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,74 @@ | ||
import pytest | ||
from funcy import first | ||
|
||
from dvc.exceptions import InvalidArgumentError | ||
from dvc.repo.experiments.utils import exp_refs_by_rev | ||
|
||
|
||
def test_remove_experiments_by_ref(tmp_dir, scm, dvc, exp_stage, caplog): | ||
queue_length = 3 | ||
ref_list = [] | ||
|
||
dberenbaum marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for i in range(queue_length): | ||
results = dvc.experiments.run( | ||
exp_stage.addressing, params=[f"foo={i}"] | ||
) | ||
ref_info = first(exp_refs_by_rev(scm, first(results))) | ||
ref_list.append(str(ref_info)) | ||
|
||
with pytest.raises(InvalidArgumentError): | ||
assert dvc.experiments.remove(ref_list[:2] + ["non-exist"]) | ||
dberenbaum marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert scm.get_ref(str(ref_list[0])) is None | ||
assert scm.get_ref(str(ref_list[1])) is None | ||
assert scm.get_ref(str(ref_list[2])) is not None | ||
|
||
|
||
def test_remove_all_queued_experiments(tmp_dir, scm, dvc, exp_stage): | ||
dberenbaum marked this conversation as resolved.
Show resolved
Hide resolved
|
||
queue_length = 3 | ||
|
||
for i in range(queue_length): | ||
dvc.experiments.run( | ||
exp_stage.addressing, params=[f"foo={i}"], queue=True | ||
) | ||
|
||
results = dvc.experiments.run( | ||
exp_stage.addressing, params=[f"foo={queue_length}"] | ||
) | ||
ref_info = first(exp_refs_by_rev(scm, first(results))) | ||
|
||
assert len(dvc.experiments.stash) == queue_length | ||
assert dvc.experiments.remove(queue=True) == queue_length | ||
assert len(dvc.experiments.stash) == 0 | ||
assert scm.get_ref(str(ref_info)) is not None | ||
|
||
|
||
def test_remove_special_queued_experiments(tmp_dir, scm, dvc, exp_stage): | ||
dberenbaum marked this conversation as resolved.
Show resolved
Hide resolved
|
||
results = dvc.experiments.run( | ||
exp_stage.addressing, params=["foo=1"], queue=True, name="queue1" | ||
) | ||
rev1 = first(results) | ||
results = dvc.experiments.run( | ||
exp_stage.addressing, params=["foo=2"], queue=True, name="queue2" | ||
) | ||
rev2 = first(results) | ||
results = dvc.experiments.run( | ||
exp_stage.addressing, params=["foo=3"], queue=True, name="queue3" | ||
) | ||
rev3 = first(results) | ||
results = dvc.experiments.run(exp_stage.addressing, params=["foo=4"]) | ||
ref_info1 = first(exp_refs_by_rev(scm, first(results))) | ||
results = dvc.experiments.run(exp_stage.addressing, params=["foo=5"]) | ||
ref_info2 = first(exp_refs_by_rev(scm, first(results))) | ||
|
||
assert rev1 in dvc.experiments.stash_revs | ||
assert rev2 in dvc.experiments.stash_revs | ||
assert rev3 in dvc.experiments.stash_revs | ||
assert scm.get_ref(str(ref_info1)) is not None | ||
assert scm.get_ref(str(ref_info2)) is not None | ||
|
||
assert dvc.experiments.remove(["queue1", rev2[:5], str(ref_info1)]) == 3 | ||
assert rev1 not in dvc.experiments.stash_revs | ||
assert rev2 not in dvc.experiments.stash_revs | ||
assert rev3 in dvc.experiments.stash_revs | ||
assert scm.get_ref(str(ref_info1)) is None | ||
assert scm.get_ref(str(ref_info2)) is not None |
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.
A behavior change here, because we had already removed all of the matched experiments, raise an exception here is needless.