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

pydantic.errors.PydanticImportError: BaseSettings has been moved to the pydantic-settings package #1594

Open
harupy opened this issue Feb 29, 2024 · 5 comments

Comments

@harupy
Copy link

harupy commented Feb 29, 2024

How to reproduce:

docker run -it python:3.9 bash
>>> pip install mlserver
>>> python -c "import mlserver"

Package versions:

> pip list | grep mlserver
mlserver                                 1.4.0

> pip list | grep pydantic
pydantic                                 2.6.3
pydantic_core                            2.16.3

Traceback:

/usr/local/lib/python3.9/site-packages/pydantic/_migration.py:283: UserWarning: `pydantic.error_wrappers:ValidationError` has been moved to `pydantic:ValidationError`.
  warnings.warn(f'`{import_path}` has been moved to `{new_location}`.')
/usr/local/lib/python3.9/site-packages/pydantic/_migration.py:283: UserWarning: `pydantic:PyObject` has been moved to `pydantic.types:ImportString`.
  warnings.warn(f'`{import_path}` has been moved to `{new_location}`.')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/mlserver/__init__.py", line 2, in <module>
    from .server import MLServer
  File "/usr/local/lib/python3.9/site-packages/mlserver/server.py", line 7, in <module>
    from mlserver.repository.factory import ModelRepositoryFactory
  File "/usr/local/lib/python3.9/site-packages/mlserver/repository/__init__.py", line 1, in <module>
    from .repository import (
  File "/usr/local/lib/python3.9/site-packages/mlserver/repository/repository.py", line 8, in <module>
    from ..settings import ModelParameters, ModelSettings
  File "/usr/local/lib/python3.9/site-packages/mlserver/settings.py", line 8, in <module>
    from pydantic import PyObject, Extra, Field, BaseSettings as _BaseSettings
  File "/usr/local/lib/python3.9/site-packages/pydantic/__init__.py", line 374, in __getattr__
    return _getattr_migration(attr_name)
  File "/usr/local/lib/python3.9/site-packages/pydantic/_migration.py", line 296, in wrapper
    raise PydanticImportError(
pydantic.errors.PydanticImportError: `BaseSettings` has been moved to the `pydantic-settings` package. See https://docs.pydantic.dev/2.6/migration/#basesettings-has-moved-to-pydantic-settings for more details.

For further information visit https://errors.pydantic.dev/2.6/u/import-error
@sakoush
Copy link
Member

sakoush commented Feb 29, 2024

@harupy many thanks for your issue, we have not migrated yet mlserver to use pydantic v2 and until we do the short-term fix is to downgrade your pydantic dependency in your env to v1.

@privatedumbo
Copy link

@sakoush , you probably are aware, but just in case, there is an issue about making this compatible with (or supporting) Pydantic v2.

@tomityrrell
Copy link

@jesse-c Any plans yet to release a pydantic v2 compatible version?

@jesse-c
Copy link
Contributor

jesse-c commented Jun 6, 2024

Hi @tomityrrell, it's out of my hands now! @sakoush is one of those who are involved in a release happening.

@sakoush
Copy link
Member

sakoush commented Jun 6, 2024

@tomityrrell we are planning to have a release of mlserver soon that will include pydantic v2 upgrade in the next couple of weeks.

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.

5 participants