|
5 | 5 | import gc
|
6 | 6 | import importlib
|
7 | 7 | import inspect
|
| 8 | +import json |
8 | 9 | import multiprocessing
|
9 | 10 | import os
|
10 | 11 | import signal
|
|
16 | 17 | from contextlib import asynccontextmanager
|
17 | 18 | from functools import partial
|
18 | 19 | from http import HTTPStatus
|
19 |
| -from json import JSONDecodeError |
20 | 20 | from typing import Annotated, Any, Optional
|
21 | 21 |
|
22 | 22 | import prometheus_client
|
@@ -930,7 +930,7 @@ async def invocations(raw_request: Request):
|
930 | 930 | """
|
931 | 931 | try:
|
932 | 932 | body = await raw_request.json()
|
933 |
| - except JSONDecodeError as e: |
| 933 | + except json.JSONDecodeError as e: |
934 | 934 | raise HTTPException(status_code=HTTPStatus.BAD_REQUEST.value,
|
935 | 935 | detail=f"JSON decode error: {e}") from e
|
936 | 936 |
|
@@ -1003,6 +1003,18 @@ async def unload_lora_adapter(request: UnloadLoRAAdapterRequest,
|
1003 | 1003 | return Response(status_code=200, content=response)
|
1004 | 1004 |
|
1005 | 1005 |
|
| 1006 | +def load_log_config(log_config_file: Optional[str]) -> Optional[dict]: |
| 1007 | + if not log_config_file: |
| 1008 | + return None |
| 1009 | + try: |
| 1010 | + with open(log_config_file) as f: |
| 1011 | + return json.load(f) |
| 1012 | + except Exception as e: |
| 1013 | + logger.warning("Failed to load log config from file %s: error %s", |
| 1014 | + log_config_file, e) |
| 1015 | + return None |
| 1016 | + |
| 1017 | + |
1006 | 1018 | def build_app(args: Namespace) -> FastAPI:
|
1007 | 1019 | if args.disable_fastapi_docs:
|
1008 | 1020 | app = FastAPI(openapi_url=None,
|
@@ -1324,6 +1336,11 @@ async def run_server_worker(listen_address,
|
1324 | 1336 |
|
1325 | 1337 | server_index = client_config.get("client_index", 0) if client_config else 0
|
1326 | 1338 |
|
| 1339 | + # Load logging config for uvicorn if specified |
| 1340 | + log_config = load_log_config(args.log_config_file) |
| 1341 | + if log_config is not None: |
| 1342 | + uvicorn_kwargs['log_config'] = log_config |
| 1343 | + |
1327 | 1344 | async with build_async_engine_client(args, client_config) as engine_client:
|
1328 | 1345 | app = build_app(args)
|
1329 | 1346 |
|
|
0 commit comments