- 
                Notifications
    You must be signed in to change notification settings 
- Fork 79
feat: add cli support to clear default cache #627
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
Conversation
| @robmarkcole can you try this pr, and let me know if it helps in clearing cache. Next I can focus on profiling. One thing to note is: it can only list/delete default cache and not your specified cache directory for SD. | 
| Codecov ReportAttention: Patch coverage is  
 Additional details and impacted files@@         Coverage Diff         @@
##           main   #627   +/-   ##
===================================
  Coverage    83%    83%           
===================================
  Files        43     49    +6     
  Lines      6699   6750   +51     
===================================
+ Hits       5556   5604   +48     
- Misses     1143   1146    +3     🚀 New features to boost your workflow:
 | 
| Checked with  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds CLI support to manage the cache by introducing commands to show the cache path and clear the default cache.
- Adds tests for CLI commands (help, cache path, and clear cache) in tests/test_cli.py
- Implements the CLI commands in src/litdata/cli.py
- Registers a console script entry point in setup.py
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description | 
|---|---|
| tests/test_cli.py | New tests for verifying CLI help message and cache commands. | 
| src/litdata/cli.py | CLI implementation with subcommands for cache management. | 
| setup.py | Entry point added for invoking the CLI. | 
Comments suppressed due to low confidence (1)
tests/test_cli.py:21
- Consider using monkeypatch to override get_default_cache_dir to return tmp_path in test_cache_clear_command. This will ensure that the test does not inadvertently remove a production or important cache directory.
def test_cache_clear_command(tmp_path, monkeypatch):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we do CLI let's have consistent experience also with litServe: https://github.com/Lightning-AI/LitServe/blob/main/src/litserve/cli.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, a CLI might not be necessary here just to clear the cache—unless there are additional plans for it that I'm missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds command-line interface support for cache management (path display and clearing) and registers a console script entry point.
- Implements argument parsing and subcommand registration for cacheandoptimize.
- Provides clear_cacheandshow_cache_pathactions that call intoget_default_cache_dir.
- Adds CLI tests and configures litdataas a console script insetup.py.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description | 
|---|---|
| tests/test_cli.py | Add tests for CLI help, cache path, and cache clear commands | 
| src/litdata/cli/parser.py | Set up the main litdataargument parser with a customLitFormatter | 
| src/litdata/cli/commands.py | Register cacheandoptimizesubcommands and bind handlers | 
| src/litdata/cli/actions/cache.py | Implement clear_cacheandshow_cache_pathlogic | 
| src/litdata/main.py | Define app()entry point to dispatch commands | 
| setup.py | Add litdata = litdata.__main__:apptoconsole_scripts | 
Comments suppressed due to low confidence (1)
src/litdata/cli/commands.py:52
- The new optimizesubcommand is not covered by any CLI tests. Consider adding a test that runslitdata optimize --dataset <path>and asserts the expected output.
def register_optimize_subcommand(subparser: _SubParsersAction) -> None:
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| @Borda I've updated the CLI and removed the  
 Other than that, the CLI structure and style are now consistent across both projects. | 
| lets psl update the PR description with examples :) | 
Before submitting
What does this PR do?
Fixes #626
# commands supported for now litdata --help litdata cache path litdata clear cachePR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in GitHub issues there's a high chance it will not be merged.
Did you have fun?
Make sure you had fun coding 🙃