feat: Add embedding model lifecycle, cache, and readiness checks#425
Conversation
|
@NirmalSingh-09 is attempting to deploy a commit to the Adarsh's projects Team on Vercel. A member of the Team first needs to authorize it. |
MRIARC-08
left a comment
There was a problem hiding this comment.
@NirmalSingh-09 I can’t merge this version yet. The lifecycle idea is useful, but the current branch breaks the existing Python checks.
Local checks from services/ai:
.venv/bin/python -m pytestfails:tests/test_health.py::test_readinessexpects/health/readyto returnready, but this PR returnsdegradedby default..venv/bin/python -m ruff check .fails with 10 issues: unusedfieldimport, import ordering, and long lines inmain.py,schemas/health.py, andtests/test_model_registry.py.
Please decide the readiness contract explicitly. If degraded is the intended default until the model is loaded, update the existing health test and docs accordingly. If not, keep readiness compatible and expose model load state as an additional check without flipping the top-level status.
Also run Ruff/formatting on the Python files before pushing.
d4663bb to
61211ee
Compare
|
@MRIARC-08 Fixed both blockers: -Kept /health/ready returning ready by default — embedding_model_loaded is now an informational check only, doesn't flip the top-level status. Existing test_readiness passes unchanged. |
MRIARC-08
left a comment
There was a problem hiding this comment.
@NirmalSingh-09 Thanks for the follow-up. The readiness endpoint behavior is fixed and pytest passes now, but Ruff still blocks the PR: src/vidyasetu_ai/core/model_registry.py imports dataclasses.field without using it. Please remove that unused import and rerun Ruff.
|
@MRIARC-08 Removed the unused field import from model_registry.py — ruff check now passes clean. |
MRIARC-08
left a comment
There was a problem hiding this comment.
Looks good now. I rechecked the latest commit locally against current origin/main: it merges cleanly, pytest passes, and Ruff passes.
Closes #357
Changes
services/ai/src/vidyasetu_ai/core/model_registry.py— thread-safe singleton registry, lazy load + cache, preload at startupservices/ai/src/vidyasetu_ai/main.py— lifespan hook preloads model at startup, resets on shutdownservices/ai/src/vidyasetu_ai/schemas/health.py— addsloaded_models,load_error,degradedstatus to ReadinessResponseservices/ai/src/vidyasetu_ai/api/routes/health.py—/health/readynow reports actual model load statusservices/ai/tests/test_model_registry.py— 8 passing testsBehaviour
/health/readyreturnsdegradedwhen model not loaded,readywhen loadedTests
8/8 passing — no live model download needed, all mocked via
sys.modulespatch