Spaces:
Runtime error
Runtime error
Commit
·
3be0c5b
1
Parent(s):
92cdcfc
changed to uvicorn setup for HF v9
Browse files- main/main.py +14 -0
main/main.py
CHANGED
@@ -5,8 +5,10 @@ import litserve as ls
|
|
5 |
import yaml
|
6 |
import logging
|
7 |
import multiprocessing as mp
|
|
|
8 |
from pathlib import Path
|
9 |
from fastapi.middleware.cors import CORSMiddleware
|
|
|
10 |
from .routes import router, init_router
|
11 |
from .api import InferenceApi
|
12 |
|
@@ -33,6 +35,18 @@ def create_app():
|
|
33 |
global _WORKER_PROCESSES, _MANAGER
|
34 |
|
35 |
logger = setup_logging()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
config = load_config()
|
37 |
server_config = config.get('server', {})
|
38 |
|
|
|
5 |
import yaml
|
6 |
import logging
|
7 |
import multiprocessing as mp
|
8 |
+
import os
|
9 |
from pathlib import Path
|
10 |
from fastapi.middleware.cors import CORSMiddleware
|
11 |
+
from huggingface_hub import login
|
12 |
from .routes import router, init_router
|
13 |
from .api import InferenceApi
|
14 |
|
|
|
35 |
global _WORKER_PROCESSES, _MANAGER
|
36 |
|
37 |
logger = setup_logging()
|
38 |
+
|
39 |
+
# Log into Hugging Face Hub
|
40 |
+
access_token = os.environ.get("InferenceAPI")
|
41 |
+
if access_token:
|
42 |
+
try:
|
43 |
+
login(token=access_token)
|
44 |
+
logger.info("Successfully logged into Hugging Face Hub")
|
45 |
+
except Exception as e:
|
46 |
+
logger.error(f"Failed to login to Hugging Face Hub: {str(e)}")
|
47 |
+
else:
|
48 |
+
logger.warning("No Hugging Face access token found")
|
49 |
+
|
50 |
config = load_config()
|
51 |
server_config = config.get('server', {})
|
52 |
|