Skip to content

Commit 198c8f2

Browse files
Fix #10638 : makes remove return correct list when used with both --queue and -A (#10641)
* fixed a bug where using both `--queue` and `-A` would yield a "removed" list without the queued experiments * added a test to validate the fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * clearer name for test --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 368c785 commit 198c8f2

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

dvc/repo/experiments/remove.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def remove( # noqa: C901, PLR0912
7575
exp_ref_list.extend(exp_ref_dict.values())
7676
elif all_commits:
7777
exp_ref_list.extend(exp_refs(repo.scm, git_remote))
78-
removed = [ref.name for ref in exp_ref_list]
78+
removed.extend([ref.name for ref in exp_ref_list])
7979

8080
if keep:
8181
exp_ref_list = list(set(exp_refs(repo.scm, git_remote)) - set(exp_ref_list))

tests/func/experiments/test_remove.py

+20
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@ def test_remove_all_queued_experiments(tmp_dir, scm, dvc, exp_stage):
4343
assert scm.get_ref(str(ref_info)) is not None
4444

4545

46+
def test_remove_all_experiments_queued_and_completed(tmp_dir, scm, dvc, exp_stage):
47+
queue_length = 3
48+
for i in range(queue_length):
49+
dvc.experiments.run(
50+
exp_stage.addressing, params=[f"foo={i}"], name=f"exp{i}", queue=True
51+
)
52+
53+
results = dvc.experiments.run(
54+
exp_stage.addressing, params=[f"foo={queue_length}"], name=f"exp{queue_length}"
55+
)
56+
ref_info = first(exp_refs_by_rev(scm, first(results)))
57+
58+
removed = sorted(dvc.experiments.remove(all_commits=True, queue=True))
59+
60+
assert len(removed) == queue_length + 1
61+
assert removed == [f"exp{i}" for i in range(queue_length)] + [ref_info.name]
62+
assert len(dvc.experiments.stash_revs) == 0
63+
assert scm.get_ref(str(ref_info)) is None
64+
65+
4666
def test_remove_special_queued_experiments(tmp_dir, scm, dvc, exp_stage):
4767
dvc.experiments.run(
4868
exp_stage.addressing, params=["foo=1"], queue=True, name="queue1"

0 commit comments

Comments
 (0)