fix: cache handling in SmashConfig due to invalid path exception#598
Merged
davidberenstein1957 merged 3 commits intoPrunaAI:mainfrom Apr 2, 2026
Merged
Conversation
src/pruna/config/smash_config.py
Outdated
Comment on lines
+221
to
+227
| if ( | ||
| hasattr(self, "cache_dir") | ||
| and self.cache_dir is not None | ||
| and isinstance(self.cache_dir, Path) | ||
| and self.cache_dir.exists() | ||
| ): | ||
| shutil.rmtree(self.cache_dir, ignore_errors=True) |
Member
There was a problem hiding this comment.
What if self.cache_dir is not a path? Can we first also see if we can convert it to a Path?
Contributor
Author
There was a problem hiding this comment.
We could update the handling of self.cache dir to first try converting to a Path and raise an error if the conversion is not correct.
Member
There was a problem hiding this comment.
Yes, I feel that this might make sense if gor some reason someone passes a str or something?
Up to standards ✅🟢 Issues
|
davidberenstein1957
approved these changes
Apr 2, 2026
Member
|
Thanks. @ParagEkbote |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
As described in the issue, if path becomes None or invalid in self.cache_dir, the following exception is raised:
To fix this issue, I made
cleanup_cache_dirmore robust by adding runtime safety guards and corrected cache directory initialization to consistently useself.cache_dir_prefixwithinSmashConfig. Could you please review?cc: @davidberenstein1957
Related Issue
Fixes #408
Type of Change
How Has This Been Tested?
Checklist
Additional Notes