diff --git a/pyproject.toml b/pyproject.toml index df90d6dfb..bef857727 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,8 @@ dependencies = [ "cachetools", "filelock", "markdown", + "pydantic", + "pydantic-settings", "pygments", "pymdown-extensions", "humanize", diff --git a/solara/server/settings.py b/solara/server/settings.py index 7a970df0d..fa5ab5f41 100644 --- a/solara/server/settings.py +++ b/solara/server/settings.py @@ -5,7 +5,7 @@ from pathlib import Path from typing import Optional -import pydantic +import pydantic_settings from filelock import FileLock from .. import ( # noqa # sidefx is that this module creates the ~/.solara directory @@ -25,7 +25,7 @@ class ThemeVariant(str, Enum): auto = "auto" -class ThemeSettings(pydantic.BaseSettings): +class ThemeSettings(pydantic_settings.BaseSettings): variant: ThemeVariant = ThemeVariant.light variant_user_selectable: bool = True loader: str = "solara" @@ -36,7 +36,7 @@ class Config: env_file = ".env" -class SSG(pydantic.BaseSettings): +class SSG(pydantic_settings.BaseSettings): # the first app create will initialize this if it is not set build_path: Optional[Path] = None enabled: bool = False @@ -48,11 +48,11 @@ class Config: env_file = ".env" -class Search(pydantic.BaseSettings): +class Search(pydantic_settings.BaseSettings): enabled: bool = False -class Telemetry(pydantic.BaseSettings): +class Telemetry(pydantic_settings.BaseSettings): mixpanel_token: str = "91845eb13a68e3db4e58d64ad23673b7" mixpanel_enable: bool = True server_user_id: str = "not_set" @@ -65,7 +65,7 @@ class Config: env_file = ".env" -class Assets(pydantic.BaseSettings): +class Assets(pydantic_settings.BaseSettings): cdn: str = "https://cdn.jsdelivr.net/npm/" proxy: bool = True proxy_cache_dir: Path = Path(prefix + "/share/solara/cdn/") @@ -92,7 +92,7 @@ class Config: OAUTH_TEST_CLIENT_IDs = [AUTH0_TEST_CLIENT_ID, FIEF_TEST_CLIENT_ID] -class Session(pydantic.BaseSettings): +class Session(pydantic_settings.BaseSettings): secret_key: str = SESSION_SECRET_KEY_DEFAULT https_only: Optional[bool] = None same_site: str = "lax" @@ -103,7 +103,7 @@ class Config: env_file = ".env" -class OAuth(pydantic.BaseSettings): +class OAuth(pydantic_settings.BaseSettings): private: bool = False client_id: str = AUTH0_TEST_CLIENT_ID @@ -118,7 +118,7 @@ class Config: env_file = ".env" -class MainSettings(pydantic.BaseSettings): +class MainSettings(pydantic_settings.BaseSettings): use_pdb: bool = False mode: str = "production" tracer: bool = False diff --git a/solara/settings.py b/solara/settings.py index 7bb46ae37..0d4455268 100644 --- a/solara/settings.py +++ b/solara/settings.py @@ -2,6 +2,7 @@ from typing import Optional import pydantic +import pydantic_settings from pydantic import Field from .util import get_solara_home @@ -11,7 +12,7 @@ home.mkdir(parents=True, exist_ok=True) -class Cache(pydantic.BaseSettings): +class Cache(pydantic_settings.BaseSettings): type: str = pydantic.Field("memory", env="SOLARA_CACHE", title="Type of cache, e.g. 'memory', 'disk', 'redis', or a multilevel cache, e.g. 'memory,disk'") disk_max_size: str = Field("10GB", title="Maximum size for'disk' cache , e.g. 10GB, 500MB") memory_max_size: str = Field("1GB", title="Maximum size for 'memory-size' cache, e.g. 10GB, 500MB")