High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
fix(ml): move logging config to code (#32220)
bo0tzz655bfdb34fb7
diff --git a/machine-learning/immich_ml/__main__.py b/machine-learning/immich_ml/__main__.pyindex 49e37aae94..c5aeeba183 100644--- a/machine-learning/immich_ml/__main__.py+++ b/machine-learning/immich_ml/__main__.py@@ -48,8 +48,6 @@ try:str(settings.workers),"-t",str(settings.worker_timeout),- "--log-config-json",- module_dir / "log_conf.json","--keep-alive",str(settings.http_keepalive_timeout_s),"--graceful-timeout",diff --git a/machine-learning/immich_ml/config.py b/machine-learning/immich_ml/config.pyindex b4b438605d..70e0023f41 100644--- a/machine-learning/immich_ml/config.py+++ b/machine-learning/immich_ml/config.py@@ -1,9 +1,11 @@import concurrent.futuresimport logging+import logging.configimport osimport sysfrom pathlib import Pathfrom socket import socket+from typing import Anyfrom gunicorn.arbiter import Arbiterfrom pydantic import BaseModel, Field@@ -144,6 +146,15 @@ class CustomRichHandler(RichHandler):return super().emit(record)+LOG_CONFIG: dict[str, Any] = {+ "version": 1,+ "disable_existing_loggers": False,+ "handlers": {"console": {"()": CustomRichHandler}},+ "loggers": {"gunicorn.error": {"handlers": ["console"]}},+ "root": {"handlers": ["console"]},+}+logging.config.dictConfig(LOG_CONFIG)+log = logging.getLogger("ml.log")log.setLevel(LOG_LEVEL)diff --git a/machine-learning/immich_ml/gunicorn_conf.py b/machine-learning/immich_ml/gunicorn_conf.pyindex efec3a95aa..255c6050df 100644--- a/machine-learning/immich_ml/gunicorn_conf.py+++ b/machine-learning/immich_ml/gunicorn_conf.py@@ -3,9 +3,13 @@ import osfrom gunicorn.arbiter import Arbiterfrom gunicorn.workers.base import Worker+from immich_ml.config import LOG_CONFIG+device_ids = os.environ.get("MACHINE_LEARNING_DEVICE_IDS", "0").replace(" ", "").split(",")env = os.environ+logconfig_dict = LOG_CONFIG+# Round-robin device assignment for each workerdef pre_fork(arbiter: Arbiter, _: Worker) -> None:diff --git a/machine-learning/immich_ml/log_conf.json b/machine-learning/immich_ml/log_conf.jsondeleted file mode 100644index d30b86d486..0000000000--- a/machine-learning/immich_ml/log_conf.json+++ /dev/null@@ -1,21 +0,0 @@-{- "version": 1,- "disable_existing_loggers": false,- "handlers": {- "console": {- "class": "immich_ml.config.CustomRichHandler"- }- },- "loggers": {- "gunicorn.error": {- "handlers": [- "console"- ]- }- },- "root": {- "handlers": [- "console"- ]- }-}