Skip to content

fix: make ML dependencies optional for graceful startup (Fixes #212)#233

Open
CodeSparks45 wants to merge 4 commits into
ionfwsrijan:mainfrom
CodeSparks45:fix/missing-ml-deps
Open

fix: make ML dependencies optional for graceful startup (Fixes #212)#233
CodeSparks45 wants to merge 4 commits into
ionfwsrijan:mainfrom
CodeSparks45:fix/missing-ml-deps

Conversation

@CodeSparks45

@CodeSparks45 CodeSparks45 commented Jun 28, 2026

Copy link
Copy Markdown

Before opening: make sure there is an issue tracking this work, and link it below. PRs without a linked issue may be closed without review.

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 a ModuleNotFoundError when the application is launched via the standard requirements.txt, the ML components are now wrapped in a robust try/except block, allowing the core API to function seamlessly.

Type of change

  • Bug fix
  • New feature
  • ML model / training pipeline
  • Refactor (no behaviour change)
  • Documentation
  • Tests only

ML tier (if applicable)

  • Tier 1 — Triage
  • Tier 2 — Predictive
  • Tier 3 — Autonomous
  • Not ML-related

Stack affected

  • Backend
  • Frontend
  • Both

Changes

Backend

  • Modified backend/app/main.py to wrap app.ml imports in an ImportError exception handler.
  • Implemented dummy mock functions to intercept downstream ML calls and safely return unmodified data when running in lightweight mode.
  • Added a logger.warning to 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 the ModuleNotFoundError is suppressed, the application starts successfully, and the correct warning is printed to the console.

Checklist

  • Tested locally end-to-end (upload ZIP or GitHub URL → scan → findings returned correctly)
  • New ML model falls back gracefully when model file is absent
  • No new console.error or unhandled Python exceptions introduced
  • Added or updated tests where applicable
  • requirements.txt / package.json updated if new dependencies added
  • New model files (.pkl, .pt, etc.) are gitignored, not committed

Anything 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)

@github-actions

Copy link
Copy Markdown

🎉 Thank you @CodeSparks45 for submitting a Pull Request!

We're excited to review your contribution.

Before Review

✅ Ensure all CI checks pass
✅ Complete the PR template
✅ Link the related issue

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! 🚀

@github-actions github-actions Bot added SSoC26 needs-work Work needed backend Backend issues bug Something isn't working and removed needs-work Work needed labels Jun 28, 2026
@github-actions github-actions Bot requested a review from arpit2006 June 28, 2026 02:02
@github-actions

Copy link
Copy Markdown

PR template check passed!

@arpit2006 this PR is ready for your review. 🚀

…rijan#212)

Signed-off-by: CodeSpark45 <somvanshipavan2006@gmail.com>
@arpit2006

Copy link
Copy Markdown
Collaborator

@CodeSparks45 , Resolve CI and Quality Gate issue.

@github-actions

Copy link
Copy Markdown

PR template check passed!

@arpit2006 this PR is ready for your review. 🚀

Signed-off-by: CodeSpark45 <somvanshipavan2006@gmail.com>

@arpit2006 arpit2006 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CodeSparks45 !

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.

@CodeSparks45

Copy link
Copy Markdown
Author

@arpit2006 Ok Sir!

@github-actions github-actions Bot requested a review from arpit2006 June 29, 2026 09:38
@github-actions

Copy link
Copy Markdown

PR template check passed!

@arpit2006 this PR is ready for your review. 🚀

@github-actions

Copy link
Copy Markdown

PR template check passed!

@arpit2006 this PR is ready for your review. 🚀

@arpit2006 arpit2006 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quality Gate Failed. Please take a look or raise a new PR with related issue fix.

@arpit2006 arpit2006 added the help wanted Extra attention is needed label Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Missing Core ML Dependencies in requirements.txt Prevent Application Startup

2 participants