Przeglądaj źródła

add a startup event for loading q learning model

chenhaiyang 4 lat temu
rodzic
commit
bbca349d37
1 zmienionych plików z 14 dodań i 0 usunięć
  1. 14 0
      app/core/events.py

+ 14 - 0
app/core/events.py

@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+
+from typing import Callable, Optional
+
+from fastapi import FastAPI
+
+from app.controllers.events import load_q_learning_model
+
+
+def create_start_app_handler(app: Optional[FastAPI] = None) -> Callable:
+    async def start_app() -> None:
+        await load_q_learning_model()
+
+    return start_app