Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot Import 'UndefinedType' from 'pydantic.fields' #592

Closed
iliion opened this issue Sep 4, 2023 · 5 comments · Fixed by #594
Closed

Cannot Import 'UndefinedType' from 'pydantic.fields' #592

iliion opened this issue Sep 4, 2023 · 5 comments · Fixed by #594

Comments

@iliion
Copy link

iliion commented Sep 4, 2023

The following dependencies are in a setup.py

"stac_pydantic==2.0.3",
"stac-fastapi.types==2.4.8",
"stac-fastapi.api==2.4.8",
"stac-fastapi.extensions==2.4.8", 

pip install -e <dir>[dev,server] will give me the following import error:

Traceback (most recent call last):
  File "/home/..../stac_fastapi/elasticsearch/app.py", line 6, in <module>
    from stac_fastapi.api.models import create_get_request_model, create_post_request_model
  File "/home/.../.venv/lib/python3.8/site-packages/stac_fastapi/api/models.py", line 9, in <module>
    from pydantic.fields import UndefinedType
ImportError: cannot import name 'UndefinedType' from 'pydantic.fields' (/home/.../.venv/lib/python3.8/site-packages/pydantic/fields.py)

Are there any constraints in package versions in order to make this work? whatever i do i get the above error

Related issue

@iliion
Copy link
Author

iliion commented Sep 5, 2023

ok. UndefinedType has become PydanticUndefined. I close the issue

@iliion iliion closed this as completed Sep 5, 2023
@gadomski
Copy link
Member

gadomski commented Sep 5, 2023

Did you have to modify your enviornment (e.g. pin dependencies) to get things to work? If so, we should uptake those changes to this repo to help others out.

@iliion
Copy link
Author

iliion commented Sep 5, 2023

yes exactly. stac-fastapi is incompatible with V2 of pydantic

The following is V1 -> reference
FYI:

class UndefinedType:
    def __repr__(self) -> str:
        return 'PydanticUndefined'

    def __copy__(self: T) -> T:
        return self

    def __reduce__(self) -> str:
        return 'Undefined'

    def __deepcopy__(self: T, _: Any) -> T:
        return self

@gadomski
Copy link
Member

gadomski commented Sep 5, 2023

Re-opening as this is a pin that should be added to stac-fastapi.

@gadomski gadomski reopened this Sep 5, 2023
@gadomski gadomski mentioned this issue Sep 6, 2023
4 tasks
@iliion
Copy link
Author

iliion commented Sep 7, 2023

just for some extra info, the following works for me:

    "pydantic[dotenv]==1.8.2",   
    "stac_pydantic==2.0.3",
    "stac-fastapi.types==2.4.1",
    "stac-fastapi.api==2.4.1",
    "geojson-pydantic==0.6.0",  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants