Spaces:
Runtime error
Runtime error
Commit
·
92cdcfc
1
Parent(s):
120ebbd
changed to uvicorn setup for HF v8
Browse files- main/main.py +3 -5
- main/routes.py +1 -1
main/main.py
CHANGED
@@ -39,6 +39,9 @@ def create_app():
|
|
39 |
# Initialize API with config
|
40 |
api = InferenceApi(config)
|
41 |
|
|
|
|
|
|
|
42 |
# Create LitServer instance
|
43 |
server = ls.LitServer(
|
44 |
api,
|
@@ -69,11 +72,6 @@ def create_app():
|
|
69 |
# Set the response queue ID for the app
|
70 |
app.response_queue_id = 0 # Since we're using a single worker
|
71 |
|
72 |
-
@app.on_event("startup")
|
73 |
-
async def startup_event():
|
74 |
-
"""Initialize router on startup"""
|
75 |
-
await init_router(api)
|
76 |
-
|
77 |
return app
|
78 |
|
79 |
# Create the app instance for uvicorn
|
|
|
39 |
# Initialize API with config
|
40 |
api = InferenceApi(config)
|
41 |
|
42 |
+
# Initialize router with API instance
|
43 |
+
init_router(api)
|
44 |
+
|
45 |
# Create LitServer instance
|
46 |
server = ls.LitServer(
|
47 |
api,
|
|
|
72 |
# Set the response queue ID for the app
|
73 |
app.response_queue_id = 0 # Since we're using a single worker
|
74 |
|
|
|
|
|
|
|
|
|
|
|
75 |
return app
|
76 |
|
77 |
# Create the app instance for uvicorn
|
main/routes.py
CHANGED
@@ -19,7 +19,7 @@ router = APIRouter()
|
|
19 |
logger = logging.getLogger(__name__)
|
20 |
api = None
|
21 |
|
22 |
-
|
23 |
"""Initialize router with an already setup API instance"""
|
24 |
global api
|
25 |
api = inference_api
|
|
|
19 |
logger = logging.getLogger(__name__)
|
20 |
api = None
|
21 |
|
22 |
+
def init_router(inference_api: InferenceApi):
|
23 |
"""Initialize router with an already setup API instance"""
|
24 |
global api
|
25 |
api = inference_api
|