-
-
Notifications
You must be signed in to change notification settings - Fork 23
Enable pruning downloaded models #71
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @ashtonmeuser, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new capability to efficiently manage downloaded language models by allowing applications to prune (delete) models that are no longer needed. This is achieved through a new static method that can remove all models in a given directory except for a specified set, ensuring that only desired models are retained and storage is optimized. This feature directly addresses the need for better storage management for downloaded models. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces a useful feature for pruning downloaded models to manage storage. The implementation is mostly solid, with a new pruneModels static method on LLMSession.DownloadModel and a helper removeEmptyFolders extension on URL.
My review includes a few suggestions to improve performance, correctness, and error handling:
- Using a
Setfor excluded models to speed up lookups. - Ensuring all model types with a path are handled correctly during pruning.
- Improving error propagation by avoiding
try?where it can mask issues.
These changes will make the pruning feature more robust and efficient.
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.
@ashtonmeuser Thank you for this PR!
After reviewing it, I think the interface looks good 😄
Once the review points are addressed, I’d like to go ahead and merge it.
If possible, it would also be great to add some tests.
| let excludingURLsNormalized: Set<URL> = Set(excludingURLs.map { $0.resolvingSymlinksInPath().standardizedFileURL | ||
| }) |
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.
URL normalization done in FileManager.removeAllItems. Could be done outside instead.
| } | ||
| } | ||
|
|
||
| if removingEmptyDirectories { try removeEmptyDirectories(in: url) } |
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.
Added argument to optionally skip pruning empty directories.
| switch model { | ||
| case let model as LLMSession.DownloadModel: model.modelPath | ||
| case let model as LLMSession.LocalModel: model.modelPath | ||
| default: nil | ||
| } |
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.
It might make sense for these models (DownloadModel and LocalModel) to share a protocol to avoid weird cases like this. Especially given that they share so much in common it's a bit odd for them to be siblings with redefined properties e.g. modelPath.
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.
You’re absolutely right. I’d like to refactor this in the future.
Comments addressed. I'm having some troubles running the tests locally but will continue trying in order to add tests. |
|
APIs and logic look good to me. Thank you so much for addressing the review comments! 😄 |
This adds a static
pruneModels(in:excluding:)method to DownloadModel.Addresses #63.
This allows for maintaining a single canonical model in an app via: