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

Fix #10638 : makes remove return correct list when used with both --queue and -A #10641

Merged
merged 4 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dvc/repo/experiments/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def remove( # noqa: C901, PLR0912
exp_ref_list.extend(exp_ref_dict.values())
elif all_commits:
exp_ref_list.extend(exp_refs(repo.scm, git_remote))
removed = [ref.name for ref in exp_ref_list]
removed.extend([ref.name for ref in exp_ref_list])

if keep:
exp_ref_list = list(set(exp_refs(repo.scm, git_remote)) - set(exp_ref_list))
Expand Down
20 changes: 20 additions & 0 deletions tests/func/experiments/test_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ def test_remove_all_queued_experiments(tmp_dir, scm, dvc, exp_stage):
assert scm.get_ref(str(ref_info)) is not None


def test_remove_all_experiments_queued_and_completed(tmp_dir, scm, dvc, exp_stage):
queue_length = 3
for i in range(queue_length):
dvc.experiments.run(
exp_stage.addressing, params=[f"foo={i}"], name=f"exp{i}", queue=True
)

results = dvc.experiments.run(
exp_stage.addressing, params=[f"foo={queue_length}"], name=f"exp{queue_length}"
)
ref_info = first(exp_refs_by_rev(scm, first(results)))

removed = sorted(dvc.experiments.remove(all_commits=True, queue=True))

assert len(removed) == queue_length + 1
assert removed == [f"exp{i}" for i in range(queue_length)] + [ref_info.name]
assert len(dvc.experiments.stash_revs) == 0
assert scm.get_ref(str(ref_info)) is None


def test_remove_special_queued_experiments(tmp_dir, scm, dvc, exp_stage):
dvc.experiments.run(
exp_stage.addressing, params=["foo=1"], queue=True, name="queue1"
Expand Down
Loading