fix: Avoid importing feast.feature_store at mcp_server import time#6634
Open
larrysingleton007 wants to merge 1 commit into
Open
fix: Avoid importing feast.feature_store at mcp_server import time#6634larrysingleton007 wants to merge 1 commit into
larrysingleton007 wants to merge 1 commit into
Conversation
mcp_server used a module-level `from feast.feature_store import FeatureStore` solely for a type annotation on add_mcp_support_to_app. Because the feast.infra.mcp_servers package __init__ eagerly imports mcp_server, importing the package pulled in the entire feature_store import graph. Under parallel unit-test collection (pytest -n) this intermittently raced with an in-progress feature_store import and failed collection of test_mcp_server.py with `KeyError: 'feast.infra.mcp_servers.mcp_server'`. Move the import under TYPE_CHECKING and use a forward reference, so importing mcp_server no longer triggers the feature_store graph. Public API and the annotation are unchanged. Signed-off-by: Larry Singleton <166439969+larrysingleton007@users.noreply.github.com>
7 tasks
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6634 +/- ##
==========================================
- Coverage 45.74% 45.74% -0.01%
==========================================
Files 414 414
Lines 49668 49667 -1
Branches 7078 7078
==========================================
- Hits 22723 22722 -1
Misses 25366 25366
Partials 1579 1579
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
ntkathole
approved these changes
Jul 23, 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.
What this PR does / why we need it:
feast/infra/mcp_servers/mcp_server.pyimportedfeast.feature_store.FeatureStoreat module load, but used it only for a type annotation onadd_mcp_support_to_app. Because thefeast.infra.mcp_serverspackage__init__eagerly importsmcp_server, importing the package pulled the entirefeature_storeimport graph in as a side effect.Under parallel unit-test collection (
pytest -n), that heavy import intermittently raced with an in-progressfeature_storeimport and failed collection oftests/unit/infra/feature_servers/test_mcp_server.pywithKeyError: 'feast.infra.mcp_servers.mcp_server'. The tests pass in isolation, so it shows up as a flakyunit-test-pythonfailure.Moving the import under
TYPE_CHECKINGwith a forward-reference annotation removesfeature_storefrommcp_server's module-load path, so importingmcp_serverno longer triggers that graph. Public API and the annotation are unchanged.Which issue(s) this PR fixes:
Fixes #6633
Checks
git commit -s)Testing Strategy
test_mcp_server.pypasses (23), andfeast.infra.mcp_serversstill exposesadd_mcp_support_to_appandMcpFeatureServerConfig. ruff and mypy clean.Misc
Release note: NONE.
As an outside contributor I can't apply labels, so a maintainer will need to add
kind/bugand runok-to-test.