microsoft / satclip

PyTorch implementation of SatCLIP
MIT License
243 stars 24 forks source link

Compatibility issue with Pydantic version #9

Open veeralakrishna opened 7 months ago

veeralakrishna commented 7 months ago

I've been encountering an error while using Pydantic, even after trying both Pydantic==1.10.11 and Pydantic==2.0.3 versions. It seems there is a compatibility issue with both of these versions.

Error Message:

ImportError                               Traceback (most recent call last)
/tmp/ipykernel_488/4215400009.py in <module>
----> 1 from satclip.load import get_satclip

/mnt/satclip/satclip/__init__.py in <module>
      1 __all__ = ["configs", "datamodules", "positional_encoding"]
      2 
----> 3 from . import *
      4 from .main import *
      5 from .model import *

/mnt/satclip/satclip/datamodules/__init__.py in <module>
      1 from .transforms import *
----> 2 from .s2geo_dataset import *

/mnt/satclip/satclip/datamodules/s2geo_dataset.py in <module>
     10 import torch
     11 
---> 12 import lightning.pytorch as pl
     13 from torch.utils.data import DataLoader
     14 

/opt/conda/lib/python3.8/site-packages/lightning/__init__.py in <module>
     30 from lightning.__about__ import *  # noqa: E402, F401, F403
     31 from lightning.__version__ import version as __version__  # noqa: E402, F401
---> 32 from lightning.app import storage  # noqa: E402
     33 from lightning.app.core.app import LightningApp  # noqa: E402
     34 from lightning.app.core.flow import LightningFlow  # noqa: E402

/opt/conda/lib/python3.8/site-packages/lightning/app/__init__.py in <module>
     23 
     24 from lightning.app import __about__  # noqa: E402
---> 25 from lightning.app import components  # noqa: E402, F401
     26 from lightning.app.__about__ import *  # noqa: E402, F401, F403
     27 

/opt/conda/lib/python3.8/site-packages/lightning/app/components/__init__.py in <module>
----> 1 from lightning.app.components.database.client import DatabaseClient
      2 from lightning.app.components.database.server import Database
      3 from lightning.app.components.multi_node import (
      4     LightningTrainerMultiNode,
      5     LiteMultiNode,

/opt/conda/lib/python3.8/site-packages/lightning/app/components/database/__init__.py in <module>
----> 1 from lightning.app.components.database.client import DatabaseClient
      2 from lightning.app.components.database.server import Database
      3 
      4 __all__ = ["Database", "DatabaseClient"]

/opt/conda/lib/python3.8/site-packages/lightning/app/components/database/client.py in <module>
     20 from urllib3.util.retry import Retry
     21 
---> 22 from lightning.app.components.database.utilities import _GeneralModel
     23 
     24 _CONNECTION_RETRY_TOTAL = 5

/opt/conda/lib/python3.8/site-packages/lightning/app/components/database/utilities.py in <module>
     18 from typing import Any, Dict, Generic, List, Type, TypeVar
     19 
---> 20 from fastapi import Response, status
     21 from fastapi.encoders import jsonable_encoder
     22 from pydantic import BaseModel, parse_obj_as

/opt/conda/lib/python3.8/site-packages/fastapi/__init__.py in <module>
      5 from starlette import status as status
      6 
----> 7 from .applications import FastAPI as FastAPI
      8 from .background import BackgroundTasks as BackgroundTasks
      9 from .datastructures import UploadFile as UploadFile

/opt/conda/lib/python3.8/site-packages/fastapi/applications.py in <module>
     13 )
     14 
---> 15 from fastapi import routing
     16 from fastapi.datastructures import Default, DefaultPlaceholder
     17 from fastapi.encoders import DictIntStrAny, SetIntStr

/opt/conda/lib/python3.8/site-packages/fastapi/routing.py in <module>
     20 )
     21 
---> 22 from fastapi import params
     23 from fastapi.datastructures import Default, DefaultPlaceholder
     24 from fastapi.dependencies.models import Dependant

/opt/conda/lib/python3.8/site-packages/fastapi/params.py in <module>
      2 from typing import Any, Callable, Dict, Optional, Sequence
      3 
----> 4 from pydantic.fields import FieldInfo, Undefined
      5 
      6 

ImportError: cannot import name 'Undefined' from 'pydantic.fields' (/home/ubuntu/.local/lib/python3.8/site-packages/pydantic/fields.py)

Request:

Could someone please confirm which version of Pydantic is compatible? Additionally, any insights into resolving this compatibility issue would be greatly appreciated.

konstantinklemmer commented 7 months ago

Hmm, I cannot find any information online about this particular import error. Here are the versions of relevant packages that work for me: PyTorch Lignting: 2.1.1 PyTorch: 2.1.0+cu118 FastAPI: 0.110.1 Pydantic: 2.7.0