ML-005 vorbereiten: Registry, API-Routen und kompatibler Predictor
This commit is contained in:
32
backend/app.py
Normal file
32
backend/app.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from fastapi import FastAPI
|
||||
|
||||
from backend.routes.ml import init_ml_routes
|
||||
from app.ml.registry.model_registry import ModelRegistry
|
||||
from app.ml.training import TrainingPipeline
|
||||
from app.ml.feature_store import FeatureStore
|
||||
|
||||
|
||||
def create_app() -> FastAPI:
|
||||
application = FastAPI(title="SillyHome Next ML")
|
||||
init_ml_routes(application)
|
||||
_seed_default_model(application.state if hasattr(application, "state") else application)
|
||||
return application
|
||||
|
||||
|
||||
def _seed_default_model(state) -> None: # noqa: ANN001
|
||||
registry = getattr(state, "registry", None)
|
||||
if registry is None:
|
||||
registry = ModelRegistry(".model_store")
|
||||
state.registry = registry
|
||||
|
||||
if list(registry.list_models()):
|
||||
return
|
||||
|
||||
store = FeatureStore()
|
||||
store.add("sensor.kitchen", {"temperature": 19.0})
|
||||
pipeline = TrainingPipeline(store)
|
||||
artifact = pipeline.run("default")
|
||||
registry.register(artifact)
|
||||
|
||||
|
||||
app = create_app()
|
||||
Reference in New Issue
Block a user