Skip to content

Commit

Permalink
testing migrate to pydantic 2.0
Browse files Browse the repository at this point in the history
where pydantic_settings is seperate package
  • Loading branch information
lp9052 committed Jun 30, 2023
1 parent 6934ee5 commit e2414db
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ dependencies = [
"cachetools",
"filelock",
"markdown",
"pydantic",
"pydantic-settings",
"pygments",
"pymdown-extensions",
"humanize",
Expand Down
18 changes: 9 additions & 9 deletions solara/server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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/")
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion solara/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Optional

import pydantic
import pydantic_settings
from pydantic import Field

from .util import get_solara_home
Expand All @@ -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")
Expand Down

0 comments on commit e2414db

Please sign in to comment.