From 8a1b64c2845ae965dfae88dd916c204a181704c9 Mon Sep 17 00:00:00 2001 From: Willem Melder Date: Thu, 9 Jan 2025 16:02:34 +0100 Subject: [PATCH 1/3] added time to log messages --- whisper_api.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/whisper_api.py b/whisper_api.py index 7a3faa6..be6898f 100644 --- a/whisper_api.py +++ b/whisper_api.py @@ -12,6 +12,10 @@ w_model, ) +LOG_FORMAT = "%(asctime)s|%(levelname)s|%(process)d|%(module)s|%(funcName)s|%(lineno)d|%(message)s" +logging.basicConfig( + format=LOG_FORMAT, +) logger = logging.getLogger(__name__) api = FastAPI() From 65a55186e073f3c5e3175975ca0f58fd0282751b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Drago=C8=99?= Date: Thu, 16 Jan 2025 16:10:41 +0100 Subject: [PATCH 2/3] Fix Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a211801..8e4e4c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ ENV POETRY_NO_INTERACTION=1 \ COPY ./poetry.lock ./poetry.lock COPY ./pyproject.toml ./pyproject.toml -RUN poetry self add poetry-plugin-export +RUN poetry self add poetry-plugin-export==1.8.0 RUN poetry export --format requirements.txt --output requirements.txt FROM nvidia/cuda:12.3.2-cudnn9-runtime-ubuntu22.04 From e59e34b4b705d3412d26218eadab802c79338048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Drago=C8=99?= Date: Thu, 16 Jan 2025 20:42:16 +0100 Subject: [PATCH 3/3] Actually use correct log format for API --- main.py | 5 ++++- whisper_api.py | 5 +---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 5b8af53..fca23d9 100644 --- a/main.py +++ b/main.py @@ -15,8 +15,11 @@ def run_api(port: int): from whisper_api import api import uvicorn + log_config = uvicorn.config.LOGGING_CONFIG + log_config["formatters"]["default"]["fmt"] = LOG_FORMAT + logger.info("Running Whisper as a service") - uvicorn.run(api, port=port, host="0.0.0.0") + uvicorn.run(api, port=port, host="0.0.0.0", log_config=log_config) def run_job(input_uri: str, output_uri: str): diff --git a/whisper_api.py b/whisper_api.py index be6898f..c514a2d 100644 --- a/whisper_api.py +++ b/whisper_api.py @@ -12,10 +12,7 @@ w_model, ) -LOG_FORMAT = "%(asctime)s|%(levelname)s|%(process)d|%(module)s|%(funcName)s|%(lineno)d|%(message)s" -logging.basicConfig( - format=LOG_FORMAT, -) + logger = logging.getLogger(__name__) api = FastAPI()