-
Notifications
You must be signed in to change notification settings - Fork 0
adjusted cache location to be more sensible #420
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
Updated conditions for claude-review job and modified comments.
…pidataAI/rapidata-python-sdk into feat/RAPID-6453-adjust-cache-location
…pidataAI/rapidata-python-sdk into feat/RAPID-6453-adjust-cache-location
This ensures the workflow files are byte-for-byte identical between main and 2.x branches, which is required for GitHub OIDC token validation to pass on PRs targeting 2.x. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Code Review - PR #420: Adjusted cache location to be more sensibleSummaryThis PR makes a sensible improvement to the cache location and includes some workflow updates. Overall, the changes are good with a few minor considerations. ✅ Code Quality & Best PracticesPython Code Changes:
GitHub Workflow Changes:
🐛 Potential Issues
⚡ Performance Considerations
🔒 Security ConcernsNo significant security issues identified.
Minor Note: The default 🧪 Test CoverageConcern: No tests were added or modified for these changes. Recommendations:
Note: The workflow changes are harder to test automatically, but manual testing is recommended. 📋 Additional Suggestions
✨ SummaryApproval Status: ✅ Approve with minor suggestions This is a solid improvement that brings the SDK in line with standard conventions. The main consideration is the breaking change to the cache location, which should be handled gracefully (either through migration or clear communication to users). The code quality is good, no bugs or security issues were identified, and the workflow improvements are sensible. The only gap is test coverage, but given the simplicity of the changes, this is a minor concern. Recommended Actions Before Merge:
|
…which seems good for our usecase
Code Review - PR #420: Adjusted cache location to be more sensibleOverviewThis PR migrates the upload cache from ✅ Positives
🔍 Code Quality & Best PracticesCritical Issues
Minor Issues
🐛 Potential Bugs
⚡ Performance Considerations
🔒 Security Concerns
🧪 Test Coverage
📝 Additional Recommendations
SummaryOverall Assessment: This is a good improvement that follows better conventions, but needs some refinements around migration reliability and test coverage. Priority Fixes:
Suggested Before Merge:
Nice to Have:
Great work on improving the SDK! Let me know if you'd like me to elaborate on any of these points. |
Code ReviewThank you for this PR! I've reviewed the changes and have the following feedback: SummaryThis PR migrates the upload cache location from Positive Aspects✅ Good adherence to standards: Moving to ✅ Backward compatibility: The ✅ Consistent updates: The removal of ✅ Clean up: Removed unused import in Issues and Concerns1. Migration Timing Issue (src/rapidata/rapidata_client/config/upload_config.py:55)🔴 Critical Bug: The migration is called in def __init__(self, **kwargs):
super().__init__(**kwargs) # Sets fields from kwargs
self._notify_handlers()
self._migrate_cache() # ← This always checks default locationProblem: If a user provides a custom Suggested fix: def _migrate_cache(self) -> None:
"""Migrate the cache from the old location to the new location."""
old_cache = Path.home() / ".rapidata" / "upload_cache"
# Only migrate if using the default cache location
default_cache = Path.home() / ".cache" / "rapidata" / "upload_cache"
if self.cacheLocation != default_cache:
return # User has custom location, skip migration
if old_cache.exists() and not self.cacheLocation.exists():
logger.info(f"Migrating cache from {old_cache} to {self.cacheLocation}")
self.cacheLocation.parent.mkdir(parents=True, exist_ok=True)
shutil.move(str(old_cache), str(self.cacheLocation))
# Clean up old directory if empty
if old_cache.parent.exists() and not any(old_cache.parent.iterdir()):
old_cache.parent.rmdir()2. Migration Runs on Every Attribute Change (src/rapidata/rapidata_client/config/upload_config.py:57-59)
def __setattr__(self, name: str, value) -> None:
super().__setattr__(name, value)
self._notify_handlers() # Called on EVERY attribute changeWhile the migration checks if files exist (so it won't actually migrate multiple times), it still performs filesystem operations unnecessarily. Suggested fix: Only run migration once during initialization, not on every attribute change. Remove the 3. Error Handling (src/rapidata/rapidata_client/config/upload_config.py:69-80)
Suggested improvements: def _migrate_cache(self) -> None:
"""Migrate the cache from the old location to the new location."""
old_cache = Path.home() / ".rapidata" / "upload_cache"
default_cache = Path.home() / ".cache" / "rapidata" / "upload_cache"
if self.cacheLocation != default_cache:
return
if old_cache.exists() and not self.cacheLocation.exists():
try:
logger.info(f"Migrating cache from {old_cache} to {self.cacheLocation}")
self.cacheLocation.parent.mkdir(parents=True, exist_ok=True)
shutil.move(str(old_cache), str(self.cacheLocation))
# Clean up old directory if empty
if old_cache.parent.exists() and not any(old_cache.parent.iterdir()):
old_cache.parent.rmdir()
logger.info("Cache migration completed successfully")
except Exception as e:
logger.error(f"Failed to migrate cache from {old_cache} to {self.cacheLocation}: {e}")
logger.error("The old cache will remain at the original location")4. Missing Test Coverage❌ No Tests: This PR doesn't include tests for the migration logic. Given that this involves filesystem operations and could affect existing users, tests are important. Suggested tests:
5. Documentation (src/rapidata/rapidata_client/config/upload_config.py:26-32)📝 Minor Issue: The docstring for
6. Removal of cacheSizeLimit Without Explanation❓ Question: Why was If the size limit functionality is no longer provided by diskcache or was never working, this should be:
GitHub Workflow Changes.github/workflows/claude-code-review.yml✅ Good additions:
.github/workflows/claude.yml✅ Improvements:
Performance Considerations
Security Concerns
RecommendationsMust Fix:
Should Fix: Nice to Have: Overall, this is a valuable improvement to follow platform conventions, but the migration logic needs some fixes before merging to prevent potential issues for users with custom configurations. |
| except Exception as e: | ||
| logger.warning(f"Warning: UploadConfig handler failed: {e}") | ||
|
|
||
| def _migrate_cache(self) -> None: |
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.
I wouldn't have bothered migrating the cache. like the cache should be deletable no problem. Now you'll need to remember to remove this again in like a month or whenever most people have updated the sdk
No description provided.