fix: make ML dependencies optional for graceful startup (Fixes #212)#233
fix: make ML dependencies optional for graceful startup (Fixes #212)#233CodeSparks45 wants to merge 4 commits into
Conversation
|
🎉 Thank you @CodeSparks45 for submitting a Pull Request! We're excited to review your contribution. Before Review✅ Ensure all CI checks pass ⚡ Want faster reviews and contributor support? Join our Discord community: 🔗 https://discord.gg/FcXuyw2Rs Maintainers and mentors are active there and can help resolve blockers quickly. Happy Contributing! 🚀 |
|
✅ PR template check passed! @arpit2006 this PR is ready for your review. 🚀 |
…rijan#212) Signed-off-by: CodeSpark45 <somvanshipavan2006@gmail.com>
|
@CodeSparks45 , Resolve CI and Quality Gate issue. |
|
✅ PR template check passed! @arpit2006 this PR is ready for your review. 🚀 |
Signed-off-by: CodeSpark45 <somvanshipavan2006@gmail.com>
arpit2006
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
It looks like the required GitHub Actions checks are currently failing, so I won't be able to complete the review or approve the PR just yet.
Could you please investigate and resolve the failing CI checks (particularly the Backend Python 3.10 workflow)? Once the CI is passing, I'll review the changes in detail and proceed with approval if everything looks good.
|
@arpit2006 Ok Sir! |
|
✅ PR template check passed! @arpit2006 this PR is ready for your review. 🚀 |
|
✅ PR template check passed! @arpit2006 this PR is ready for your review. 🚀 |
arpit2006
left a comment
There was a problem hiding this comment.
Quality Gate Failed. Please take a look or raise a new PR with related issue fix.
…op to fix Ruff I001 & E402
Linked issue
Closes #212
What this PR does
This PR introduces a graceful fallback mechanism for Machine Learning dependencies (
transformers,torch, etc.) during application startup. Instead of crashing with aModuleNotFoundErrorwhen the application is launched via the standardrequirements.txt, the ML components are now wrapped in a robusttry/exceptblock, allowing the core API to function seamlessly.Type of change
ML tier (if applicable)
Stack affected
Changes
Backend
backend/app/main.pyto wrapapp.mlimports in anImportErrorexception handler.logger.warningto inform developers when the application is operating with ML features disabled.Frontend
New dependencies
Database / schema changes
Testing
How did you test this?
Initialized a fresh virtual environment and installed only
backend/requirements.txt(simulating the bug environment). Started the FastAPI server and verified that theModuleNotFoundErroris suppressed, the application starts successfully, and the correct warning is printed to the console.Checklist
console.erroror unhandled Python exceptions introducedrequirements.txt/package.jsonupdated if new dependencies added.pkl,.pt, etc.) are gitignored, not committedAnything reviewers should focus on
The mock functions (
DummyPredictor,deduplicate, etc.) are intentionally designed to preserve the data contracts of the original functions to ensure downstream pipeline stability.Screenshots (if UI changed)