From a9981f25c5c77bea6ee6dfee348fcdae4ac8a53f Mon Sep 17 00:00:00 2001 From: Philipp Schmid Date: Tue, 2 Aug 2022 12:09:09 +0000 Subject: [PATCH 1/2] remove asci time from logging --- README.md | 8 ++++++++ src/huggingface_inference_toolkit/webservice_starlette.py | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 69c9fd6d..7b7f42cb 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,14 @@ The `HF_FRAMEWORK` environment variable defines the base deep learning framework HF_FRAMEWORK="pytorch" ``` +### `HF_ENDPOINT` + +The `HF_ENDPOINT` environment variable indicates whether the service is run inside the HF Inference endpoint service to adjust the `logging` config. + +```bash +HF_ENDPOINT="True" +``` + --- diff --git a/src/huggingface_inference_toolkit/webservice_starlette.py b/src/huggingface_inference_toolkit/webservice_starlette.py index f9e8cfc6..4e63e9f3 100644 --- a/src/huggingface_inference_toolkit/webservice_starlette.py +++ b/src/huggingface_inference_toolkit/webservice_starlette.py @@ -1,7 +1,7 @@ import logging from pathlib import Path from time import perf_counter - +import os import orjson from huggingface_inference_toolkit.const import ( HF_FRAMEWORK, @@ -21,7 +21,10 @@ logger = logging.getLogger(__name__) -logging.basicConfig(format="%(asctime)s | %(levelname)s | %(message)s", level=logging.INFO) +if os.environ.get("HF_ENDPOINT", None): + logging.basicConfig(format="| %(levelname)s | %(message)s", level=logging.INFO) +else: + logging.basicConfig(format="%(asctime)s | %(levelname)s | %(message)s", level=logging.INFO) uvicorn_error = logging.getLogger("uvicorn.error") uvicorn_error.disabled = True uvicorn_access = logging.getLogger("uvicorn.access") From 2ea302bd8ad69853e7d4f3468c094e19ce12a285 Mon Sep 17 00:00:00 2001 From: Philipp Schmid Date: Tue, 2 Aug 2022 12:12:50 +0000 Subject: [PATCH 2/2] make style --- src/huggingface_inference_toolkit/webservice_starlette.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/huggingface_inference_toolkit/webservice_starlette.py b/src/huggingface_inference_toolkit/webservice_starlette.py index 4e63e9f3..2d790cca 100644 --- a/src/huggingface_inference_toolkit/webservice_starlette.py +++ b/src/huggingface_inference_toolkit/webservice_starlette.py @@ -1,7 +1,8 @@ import logging +import os from pathlib import Path from time import perf_counter -import os + import orjson from huggingface_inference_toolkit.const import ( HF_FRAMEWORK,