[Backend] Lazy Model Initialization & Fault-Tolerant Startup (#302)#323
Open
j4b3-21 wants to merge 6 commits intojenkinsci:mainfrom
Open
[Backend] Lazy Model Initialization & Fault-Tolerant Startup (#302)#323j4b3-21 wants to merge 6 commits intojenkinsci:mainfrom
j4b3-21 wants to merge 6 commits intojenkinsci:mainfrom
Conversation
Author
|
To fix the linting issue , edit- |
Contributor
Yes |
Author
yes i did that and updated the pr |
| """Backward compatibility wrapper.""" | ||
| model = get_embedding_model() | ||
| if model is None: | ||
| raise RuntimeError( |
Contributor
There was a problem hiding this comment.
I don't think we should raise Error
| except Exception: # pylint: disable=broad-except | ||
| pass | ||
|
|
||
| # pylint: disable=import-outside-toplevel |
Contributor
There was a problem hiding this comment.
Why you ignore this pylint?
| Check logs for error details. | ||
| """ | ||
| return _get_cached_model( | ||
| "embedding", |
Contributor
There was a problem hiding this comment.
Define this on top of the file as a var.
| """ | ||
|
|
||
| return _get_cached_model( | ||
| "llm", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements lazy, thread-safe initialization for embedding and LLM models to improve API startup reliability and reduce cold-start latency.
Previously, models were loaded during import, causing slow startup and failures when models were unavailable.
Now, models initialize only on first use and fallback gracefully on failure.A minor fix was done to footer.jelly to match the root name with main.tsx
Changes
Testing Done
Files Modified
New file:
• runtime_models.py
##Related Issue
Closes #302
Submitter checklist