fix: use FileLock to avoid downloading models concurrently into shared storage#395
fix: use FileLock to avoid downloading models concurrently into shared storage#395marcelklehr wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent concurrent downloads of machine learning models into shared storage by adding file locking mechanisms. The implementation wraps model download operations with FileLock to ensure only one process downloads a model at a time, avoiding conflicts in multi-instance deployments.
Changes:
- Added
lockfiledependency to project dependencies - Wrapped file-based model download logic with FileLock context manager
- Wrapped HuggingFace snapshot download with FileLock context manager
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pyproject.toml | Adds lockfile>=0.12.2 dependency to support file locking |
| nc_py_api/ex_app/integration_fastapi.py | Imports FileLock and wraps model download operations with file locks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
aad8c13 to
3e8f340
Compare
…d storage Signed-off-by: Marcel Klehr <mklehr@gmx.net>
3e8f340 to
c672479
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #395 +/- ##
==========================================
- Coverage 94.65% 94.53% -0.13%
==========================================
Files 45 45
Lines 5392 5400 +8
==========================================
+ Hits 5104 5105 +1
- Misses 288 295 +7
🚀 New features to boost your workflow:
|
|
|
|
I had concerns about whether the file system in the shared storage would support locking, that's why I chose softlocks. Also, it has this:
But not sure if that helps us with k8s. |
|
Alternative version just as idea(I did not test it in practice): |
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughAdds file-based locking to model download operations in the FastAPI integration module using the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Comment |
Summary by CodeRabbit