I think `flytekitplugins-pydantic` is incompatible...
# ask-the-community
k
I think
flytekitplugins-pydantic
is incompatible with
pydantic 2.x
. Whenever I try to run my code I get errors like this
Copy code
File "/Users/kdubovikov/Library/Caches/pypoetry/virtualenvs/universal-model-flyte--i4p14Mq-py3.11/lib/python3.11/site-packages/flytekitplugins/pydantic/__init__.py", line 1, in <module>
    from .basemodel_transformer import BaseModelTransformer
  File "/Users/kdubovikov/Library/Caches/pypoetry/virtualenvs/universal-model-flyte--i4p14Mq-py3.11/lib/python3.11/site-packages/flytekitplugins/pydantic/basemodel_transformer.py", line 12, in <module>
    from . import deserialization, serialization
  File "/Users/kdubovikov/Library/Caches/pypoetry/virtualenvs/universal-model-flyte--i4p14Mq-py3.11/lib/python3.11/site-packages/flytekitplugins/pydantic/deserialization.py", line 14, in <module>
    PYDANTIC_VALIDATOR_METHOD_NAME = pydantic.BaseModel.__get_validators__.__name__
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kdubovikov/Library/Caches/pypoetry/virtualenvs/universal-model-flyte--i4p14Mq-py3.11/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 221, in __getattr__
    raise AttributeError(item)
AttributeError: __get_validators__
According to the docs,
__get_validators__
should be replaced with `__get_pydantic_core_schema__`: https://docs.pydantic.dev/latest/migration/#defining-custom-types
k
I thought someone was working on pydantic 2.0 support. Cc @Thomas Fan or @L godlike
k
It may be good to note that 2.x is not supported in the docs
l
Can take a look tommorow, thank you
Copy code
from flytekit import task
# from pydantic import BaseModel
from pydantic.v1 import BaseModel


class TrainConfig(BaseModel):
    lr: float = 1e-3
    batch_size: int = 32
    # files: List[FlyteFile]
    # directories: List[FlyteDirectory]

@task
def train() -> TrainConfig:
    return cfg
I just run this example with
Copy code
(dev) future@outlier ~ % pip list | grep -i pydantic
autodoc-pydantic                         1.8.0
pydantic                                 2.6.2
pydantic_core                            2.16.3
with this image
Copy code
futureoutlier/flytekit:pydantic-v3
fixed!