FIX: Keep cold target catalog responsive - #2360
Open
Roman Lutz (romanlutz) wants to merge 3 commits into
Open
Conversation
Defer Hugging Face inference imports, coordinate registry metadata discovery, offload cold catalog work, and keep fallback target choices interactive while metadata loads. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Adrian Gavrila (adrian-gavrila)
left a comment
Contributor
There was a problem hiding this comment.
Overall looks great! I left 4 comments all related to very similar timing issues with locks that I believe are held longer than necessary. I could be wrong though and we actually need to hold.
Narrow registry lock scope, coordinate singleton construction per registry class, keep Hugging Face model loading off the event loop, and eliminate frontend act warnings. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 130110b1-e9bb-4dc5-9f71-c2405871b1e4
Adrian Gavrila (adrian-gavrila)
approved these changes
Aug 13, 2026
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.
Description
A fresh
GET /api/targets/catalogsynchronously materialized the lazy Hugging Face target export, importing heavyweight inference dependencies on the FastAPI event loop. This delayed both the catalog and unrelated requests such as/api/health.This change:
transformersand Hugging Face download imports until target validation or model-loading execution pathsFresh-process route checks measured 81-103 ms for the cold catalog, 65-87 ms for concurrent health, and 3.3-4.5 ms for warm catalog requests. All 20 target types remain present, including
HuggingFaceChatTarget, without catalog discovery importingtransformers,torch, orhuggingface_hub.Tests and Documentation
Added deterministic coverage for import isolation, cold/warm equivalence, concurrent single-flight discovery, runtime class invalidation, instance-cache lifetime, event-loop schedulability, and frontend fallback selection/enrichment.
Validation completed: