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

gc: add dry option and return num removed #441

Merged
merged 3 commits into from
Sep 25, 2023
Merged

gc: add dry option and return num removed #441

merged 3 commits into from
Sep 25, 2023

Conversation

dberenbaum
Copy link

Prerequisites to make gc more user friendly by exposing a dry option and returning the number of files removed.

@dberenbaum
Copy link
Author

Can we add meaningful unit tests for this? I couldn't easily figure out a way to do it. Let me see what we can cover in the corresponding dvc PR.

odb.fs.remove(paths)
removed += len(paths)
if not dry:
odb.fs.remove(paths)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could put some logging here in debug mode (or even info if you passed dry?
Or is the list of things to be removed logged elsewhere?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't track down where, but it looks like it is already logged:

$ dvc gc -v --all-commits --all-branches --all-tags
2023-09-15 10:54:20,087 DEBUG: v3.19.1.dev20+gbf2af8639.d20230915, CPython 3.11.5 on macOS-13.5-arm64-arm-64bit
2023-09-15 10:54:20,087 DEBUG: command: /Users/dave/micromamba/envs/dvc-test/bin/dvc gc -v --all-commits --all-branches --all-tags
2023-09-15 10:54:20,288 WARNING: This will remove all cache except items used in the workspace and all git commits of the current repo.
Are you sure you want to proceed? [y/n]: y
2023-09-15 10:54:22,624 DEBUG: Estimated remote size: 256 files
2023-09-15 10:54:22,625 DEBUG: Removing '/Users/dave/repo/.dvc/cache/files/md5/91/52ab3f172b3e23fd6b1a3ab0e1d150'
Removed 1 objects from repo cache.
2023-09-15 10:54:22,625 DEBUG: Estimated remote size: 256 files
No unused 'local' cache to remove.
2023-09-15 10:54:22,625 DEBUG: Estimated remote size: 256 files
2023-09-15 10:54:22,625 DEBUG: '/Users/dave/repo/.dvc/cache/files/md5/5f/b7ba7e8447a836e774b66155f5776a' doesn't look like a cache file, skipping
No unused 'legacy' cache to remove.

@codecov-commenter
Copy link

Codecov Report

Patch has no changes to coverable lines.

Files Changed Coverage
src/dvc_data/hashfile/gc.py 0.00%

📢 Thoughts on this report? Let us know!.

@dberenbaum
Copy link
Author

ping @efiop @daavoo

@dberenbaum dberenbaum merged commit 7a015de into main Sep 25, 2023
14 checks passed
@dberenbaum
Copy link
Author

@efiop Any thoughts on tests?

@efiop efiop deleted the gc-ui branch December 21, 2023 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants