MCPcopy Index your code
hub / github.com/feast-dev/feast / load_static_artifacts

Function load_static_artifacts

sdk/python/feast/feature_server.py:257–300  ·  view source on GitHub ↗

Load static artifacts (models, lookup tables, etc.) into app.state. This function can be extended to load various types of static artifacts: - Small ML models (scikit-learn, small neural networks) - Lookup tables and reference data - Configuration parameters - Pre-computed

(app: FastAPI, store)

Source from the content-addressed store, hash-verified

255
256
257async def load_static_artifacts(app: FastAPI, store):
258 """
259 Load static artifacts (models, lookup tables, etc.) into app.state.
260
261 This function can be extended to load various types of static artifacts:
262 - Small ML models (scikit-learn, small neural networks)
263 - Lookup tables and reference data
264 - Configuration parameters
265 - Pre-computed embeddings
266
267 Note: Not recommended for large language models - use dedicated
268 model serving solutions (vLLM, TGI, etc.) for those.
269 """
270 try:
271 # Import here to avoid loading heavy dependencies unless needed
272 import importlib.util
273 import inspect
274 from pathlib import Path
275
276 # Look for static artifacts loading in the feature repository
277 # This allows templates and users to define their own artifact loading
278 repo_path = Path(store.repo_path) if store.repo_path else Path.cwd()
279 artifacts_file = repo_path / "static_artifacts.py"
280
281 if artifacts_file.exists():
282 # Load and execute custom static artifacts loading
283 spec = importlib.util.spec_from_file_location(
284 "static_artifacts", artifacts_file
285 )
286 if spec and spec.loader:
287 artifacts_module = importlib.util.module_from_spec(spec)
288 spec.loader.exec_module(artifacts_module)
289
290 # Look for load_artifacts function
291 if hasattr(artifacts_module, "load_artifacts"):
292 load_func = artifacts_module.load_artifacts
293 if inspect.iscoroutinefunction(load_func):
294 await load_func(app)
295 else:
296 load_func(app)
297 logger.info("Loaded static artifacts from static_artifacts.py")
298 except Exception as e:
299 # Non-fatal error - feature server should still start
300 logger.warning(f"Failed to load static artifacts: {e}")
301
302
303def get_app(

Calls

no outgoing calls