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

output.remove: Pass explicit recursive flag #8825

Merged
merged 2 commits into from
Jan 18, 2023
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/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ def checkout(
return added, False if added else modified

def remove(self, ignore_remove=False):
self.fs.remove(self.fs_path)
self.fs.remove(self.fs_path, recursive=True)
if self.protocol != Schemes.LOCAL:
return

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ dependencies = [
"dvc-render==0.0.17",
"dvc-task==0.1.11",
"dvclive>=1.2.2",
"dvc-data==0.32.0",
"dvc-data==0.33.0",
"dvc-http",
"hydra-core>=1.1.0",
"iterative-telemetry==0.0.6",
Expand Down
19 changes: 14 additions & 5 deletions tests/func/test_gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,21 @@ def test_gc_cloud_remove_order(tmp_dir, scm, dvc, tmp_path_factory, mocker):
LocalFileSystem, "remove", autospec=True
)
dvc.gc(workspace=True, cloud=True)
assert len(mocked_remove.mock_calls) == 8
# dir (and unpacked dir) should be first 4 checksums removed from
# the remote
for args in mocked_remove.call_args_list[:4]:
assert len(mocked_remove.mock_calls) == 4
# Unpacked dir should be the first removed
for args in mocked_remove.call_args_list[:2]:
checksum = str(args[0][1])
assert checksum.endswith(".dir") or checksum.endswith(".dir.unpacked")
assert checksum.endswith(".dir.unpacked")
# Then, bulk remove should be applied

# First to `.dir`
checksums = mocked_remove.call_args_list[2][0][1]
assert isinstance(checksums, list)
assert all(x.endswith(".dir") for x in checksums)
# And later to individual files
checksums = mocked_remove.call_args_list[3][0][1]
assert isinstance(checksums, list)
assert not any(x.endswith(".dir") for x in checksums)


def test_gc_not_collect_pipeline_tracked_files(tmp_dir, dvc, run_copy):
Expand Down