Skip to content

Commit

Permalink
🐳 chore(pydantic): update to 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
SerinaNya committed Aug 1, 2023
1 parent d2de6a0 commit b525321
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
fastapi
playwright
pydantic
pydantic-settings
uvicorn[standard]
Wand
yggdrasil-mc==0.1b6
2 changes: 1 addition & 1 deletion app/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pydantic import BaseSettings
from pydantic_settings import BaseSettings


class Settings(BaseSettings):
Expand Down
12 changes: 7 additions & 5 deletions app/skinview3d/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pydantic import BaseModel, root_validator, confloat
from pydantic import model_validator, Field, BaseModel
import base64
from typing_extensions import Annotated


class BackendInfo(BaseModel):
Expand All @@ -8,8 +9,8 @@ class BackendInfo(BaseModel):


class CommonResponse(BaseModel):
front: bytes | None
back: bytes | None
front: bytes | None = None
back: bytes | None = None
both: bytes | None = None
backendInfo: BackendInfo

Expand All @@ -29,14 +30,15 @@ class All_Response_Json(BaseModel):
both_b64: str
backendInfo: BackendInfo

@root_validator(pre=True)
@model_validator(mode="before")
@classmethod
def convertToBase64(cls, values):
for i in ("front", "back", "both"):
values[f"{i}_b64"] = base64.b64encode(values[i]) if values[i] else ''
return values

class CommonOptions(BaseModel):
definition: confloat(ge=0.8, le=3.5) = 1.5
definition: Annotated[float, Field(ge=0.8, le=3.5)] = 1.5
transparent: bool = False

class CommonQuery(CommonOptions):
Expand Down

0 comments on commit b525321

Please sign in to comment.