Closed nsheff closed 8 months ago
How much effort will it take to update pipestat to support pydantic2.0? I want to create a script, that will be making zip file with all geo peps, but unfortunately pepdbagent supports pydantic>2, and pephubclient pydantic<2. I can't update pephubclient, because if I update it, looper will be broken.
How fast can update it? @donaldcampbelljr do you have any ideas about his update?
I'll begin looking at this this afternoon or tomorrow and let you know if I'm running into any issues.
Some notes:
-we are technically already using sqlmodel 0.014 in pipestat (but it supports backwards compatibility with pydantic 1)
-installing pydantic 2.5.3 (newest version) causes pytest errors: sqlalchemy.exc.IntegrityError: (psycopg.errors.NotNullViolation)
-pydantic has a tool to do migration https://docs.pydantic.dev/latest/migration/
(venv) drc@databio:~/GITHUB/pipestat/pipestat$ bump-pydantic --diff ./pipestat/
Results:
[15:26:13] Start bump-pydantic. main.py:61
Found 21 files to process. main.py:78
--- pipestat/backends/db_backend/db_parsed_schema.py
+++ pipestat/backends/db_backend/db_parsed_schema.py
@@ -5,7 +5,7 @@
import logging
from pathlib import Path
from typing import Any, Dict, List, Mapping, Optional
-from pydantic import create_model
+from pydantic import ConfigDict, create_model
from sqlalchemy import Column, null
from sqlalchemy.dialects.postgresql import JSONB
@@ -54,9 +54,7 @@
def get_base_model():
class BaseModel(SQLModel):
__table_args__ = {"extend_existing": True}
-
- class Config:
- arbitrary_types_allowed = True
+ model_config = ConfigDict(arbitrary_types_allowed=True)
# return SQLModel
return BaseModel
[15:26:27] Found 1 errors. Please check the log.txt file.
1 Error is related to https://github.com/pydantic/bump-pydantic/issues/124 and only affects the filebackend (which does not use sqlmodel, so it can be ignored).
After conversion, only db_parsed_schema.py
modified, still getting sqlalchemy.exc.IntegrityError: (psycopg.errors.NotNullViolation)
, but it is the only errror at the moment.
This morning, sqlmodel with support for pydantic v2 was released. Not sure if we need to update anything, but we should adapt the pydantic 2 models.