Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 24, 2024
1 parent c258194 commit 8280009
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
12 changes: 9 additions & 3 deletions dvc/repo/experiments/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,22 @@ def remove( # noqa: C901, PLR0912
if keep:
all_exp_refs = exp_refs(repo.scm, git_remote) # Get all experiments
selected_exp_names = {ref.name for ref in exp_ref_list} # Current selection
exp_ref_list = [ref for ref in all_exp_refs if ref.name not in selected_exp_names]
exp_ref_list = [
ref for ref in all_exp_refs if ref.name not in selected_exp_names
]

# Handle queued experiments
all_queue_entries = list(celery_queue.iter_queued())
selected_queue_entries = {entry.name for entry in queue_entry_list}
queue_entry_list = [
entry for entry in all_queue_entries if entry.name not in selected_queue_entries
entry
for entry in all_queue_entries
if entry.name not in selected_queue_entries
]

removed = [ref.name for ref in exp_ref_list] + [entry.name for entry in queue_entry_list]
removed = [ref.name for ref in exp_ref_list] + [
entry.name for entry in queue_entry_list
]

if exp_ref_list:
_remove_commited_exps(repo.scm, exp_ref_list, git_remote)
Expand Down
5 changes: 1 addition & 4 deletions tests/func/experiments/test_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,7 @@ def test_keep_selected_all_by_name(tmp_dir, scm, dvc, exp_stage):
assert scm.get_ref(str(exp3_ref)) is not None

# Keep "exp1" and "exp2" and remove "exp3"
removed = dvc.experiments.remove(
exp_names=["exp1", "exp2", "exp3"], keep=True
)
removed = dvc.experiments.remove(exp_names=["exp1", "exp2", "exp3"], keep=True)
assert removed == []

# Check remaining experiments
Expand Down Expand Up @@ -281,7 +279,6 @@ def test_keep_selected_by_nonexistent_name(tmp_dir, scm, dvc, exp_stage):
with pytest.raises(UnresolvedExpNamesError):
dvc.experiments.remove(exp_names=["nonexistent"], keep=True)


# Check nothing has been deleted
assert scm.get_ref(str(exp1_ref)) is not None
assert scm.get_ref(str(exp2_ref)) is not None
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/command/test_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def test_experiments_remove_flag(dvc, scm, mocker, capsys, caplog):
num=2,
queue=False,
git_remote="myremote",
keep_selected=False
keep_selected=False,
)


Expand All @@ -411,7 +411,7 @@ def test_experiments_remove_special(dvc, scm, mocker, capsys, caplog):
num=1,
queue=False,
git_remote="myremote",
keep_selected=False
keep_selected=False,
)


Expand Down

0 comments on commit 8280009

Please sign in to comment.