diff --git a/package.json b/package.json index d26000e..e66450e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tdp_publicdb", "description": "", - "version": "14.0.0", + "version": "14.0.1", "author": { "name": "The Caleydo Team", "email": "contact@caleydo.org", @@ -62,7 +62,7 @@ "react-select-async-paginate": "^0.5.3", "react-select-event": "^5.5.1", "react-virtualized": "^9.22.3", - "tdp_core": "^20.1.0", + "tdp_core": "^20.1.1", "visyn_scripts": "^4.1.0" }, "resolutions": { diff --git a/tdp_publicdb/settings.py b/tdp_publicdb/settings.py index a1f0083..26a2f39 100644 --- a/tdp_publicdb/settings.py +++ b/tdp_publicdb/settings.py @@ -1,4 +1,7 @@ -from pydantic import BaseModel +import contextlib +import json + +from pydantic import BaseModel, validator from visyn_core import manager @@ -6,7 +9,17 @@ class TDPPublicDBSettings(BaseModel): dburl: str = "postgresql://publicdb:publicdb@publicdb:5432/publicdb" statement_timeout: str = "'5min'" statement_timeout_query: str = "set statement_timeout to {}" - engine: dict = {"pool_pre_ping": True} + engine: dict[str, str] | None = {"pool_pre_ping": True} + poolclass: str | None = "QueuePool" # "NullPool" | "QueuePool" | "StaticPool" + + @validator("engine", pre=True) + def json_decode_headers(cls, v): # NOQA N805 + # Manually parse JSON strings if they are coming from the env via `VISYN_CORE__...='{"...": ...}'`. + # See https://github.com/pydantic/pydantic/issues/831 for details. + if isinstance(v, str): + with contextlib.suppress(ValueError): + return json.loads(v) + return v def get_settings() -> TDPPublicDBSettings: