chore(deps): migrate to pydantic v2

This commit is contained in:
Felix Spöttel
2023-07-31 18:13:10 +02:00
parent 38587a0159
commit f25dbae580
5 changed files with 20 additions and 20 deletions

View File

@@ -1,6 +1,6 @@
import sys
from pydantic import BaseSettings
from pydantic_settings import BaseSettings
class Settings(BaseSettings):

View File

@@ -1,7 +1,7 @@
from datetime import datetime
from uuid import UUID
from pydantic import AnyHttpUrl, BaseModel
from pydantic import AnyHttpUrl, BaseModel, ConfigDict
from app.shared.db.models import (
ArtifactData,
@@ -18,10 +18,8 @@ from app.shared.db.models import (
class WithDbFields(BaseModel):
id: UUID
created_at: datetime
updated_at: datetime | None
class Config:
orm_mode = True
updated_at: datetime | None = None
model_config = ConfigDict(from_attributes=True)
class Job(WithDbFields):
@@ -30,8 +28,8 @@ class Job(WithDbFields):
status: JobStatus
type: JobType
url: AnyHttpUrl
meta: JobMeta | None
config: JobConfig | None
meta: JobMeta | None = None
config: JobConfig | None = None
class Artifact(WithDbFields):

View File

@@ -129,10 +129,11 @@ def app_factory(
)
language: str | None = Field(
default=None,
description=(
"Spoken language in the media file. "
"While optional, this can improve output when set."
)
),
)
@api_router.post(
@@ -161,7 +162,7 @@ def app_factory(
# create a job with status "create" and save it to the database.
job = models.Job(
url=payload.url,
url=str(payload.url),
status=dtos.JobStatus.create,
type=payload.type,
config={"language": payload.language} if payload.language else None,

View File

@@ -17,7 +17,7 @@ class DecodingOptions(BaseModel):
This mirrors private type `whisper.DecodingOptions`.
"""
language: str | None
language: str | None = None
task: Literal["translate", "transcribe"]

View File

@@ -5,16 +5,17 @@ version = "0.1.0"
dependencies=[
"celery[redis] ==5.3.1",
"sqlalchemy[mypy] ==2.0.17",
"pydantic ==1.10.9"
"sqlalchemy[mypy] ==2.0.19",
"pydantic ==2.1.1",
"pydantic-settings ==2.0.2"
]
[project.optional-dependencies]
web=[
"alembic ==1.11.1",
"fastapi ==0.98.0",
"uvicorn[standard] ==0.22.0",
"gunicorn ==20.1.0"
"fastapi ==0.100.1",
"uvicorn[standard] ==0.23.2",
"gunicorn ==21.2.0"
]
worker=[
@@ -25,17 +26,17 @@ worker=[
tooling = [
# code formatting
"black ==23.3.0",
"black ==23.7.0",
# linting
"ruff ==0.0.275",
"ruff ==0.0.280",
# tests
"httpx",
"httpx ==0.24.1",
"sqlalchemy-utils ==0.41.1",
"python-dotenv ==1.0.0",
"pytest ==7.4.0",
# types
"mypy ==1.4.1",
"types-requests ==2.31.0.1"
"types-requests ==2.31.0.2"
]
[tool.ruff]