Skip to content

fix: check if model files exist before returning cached path#624

Merged
joein merged 1 commit intomainfrom
support-many-model-files-same-env
Apr 10, 2026
Merged

fix: check if model files exist before returning cached path#624
joein merged 1 commit intomainfrom
support-many-model-files-same-env

Conversation

@joein
Copy link
Copy Markdown
Member

@joein joein commented Apr 8, 2026

If we have several versions of a model (e.g., fp32, fp16, etc), then we could use only one of those per a cache dir, since hf check was just verifying that the model's dir exists, not model's file.

@joein joein requested a review from tbung April 8, 2026 10:18
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 468fbf93-23be-4d93-bc18-e5aef0edc464

📥 Commits

Reviewing files that changed from the base of the PR and between 21df54e and 0853c62.

📒 Files selected for processing (1)
  • fastembed/common/model_management.py

📝 Walkthrough

Walkthrough

The ModelManagement.download_model method is modified to change how it handles the HuggingFace local_files_only=True attempt. Previously, the method would immediately return the resolved download path upon success. Now it validates that the expected primary model file and all extra pattern files exist in the resolved directory before returning. If validation fails, execution continues to fallback logic instead of returning early. Exception handling for this branch remains unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a check for model file existence before returning a cached path, which directly addresses the core issue.
Description check ✅ Passed The description clearly explains the problem context (multiple model versions sharing a cache directory) and the fix (checking for actual model files, not just directory existence).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch support-many-model-files-same-env

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@joein joein merged commit 2b069d2 into main Apr 10, 2026
13 checks passed
@joein joein deleted the support-many-model-files-same-env branch April 10, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants