Skip to content

Commit f18979f

Browse files
authored
fix: migrate schemas.py from Pydantic v1 orm_mode to Pydantic v2 model_config
1 parent b538597 commit f18979f

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

backend/schemas.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from pydantic import BaseModel
1+
from pydantic import BaseModel, ConfigDict
22
from datetime import datetime
33
from typing import Optional
44

5+
56
class LogBase(BaseModel):
67
source_ip: str
78
destination_ip: str
@@ -10,19 +11,23 @@ class LogBase(BaseModel):
1011
event_type: str
1112
details: Optional[str] = None
1213

14+
1315
class LogCreate(LogBase):
1416
pass
1517

18+
1619
class LogResponse(LogBase):
1720
id: int
1821
timestamp: datetime
1922

20-
class Config:
21-
orm_mode = True
23+
# Pydantic v2: use model_config instead of inner class Config
24+
model_config = ConfigDict(from_attributes=True)
25+
2226

2327
class PredictionRequest(LogBase):
2428
pass
2529

30+
2631
class PredictionResponse(BaseModel):
2732
is_anomaly: bool
2833
anomaly_score: float

0 commit comments

Comments
 (0)