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.PydanticUserError #32

Closed
IgorFreitasCruz opened this issue Apr 12, 2024 · 6 comments
Closed

pydantic.errors.PydanticUserError #32

IgorFreitasCruz opened this issue Apr 12, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@IgorFreitasCruz
Copy link
Contributor

pydantic.errors.PydanticUserError: model_config cannot be used as a model field name. Use model_config for model configuration.

Followed alI the steps for local development but containers backend and celeryworker didn't spin up outputting the same pydantic error.

I'm on a Mac M1 Sonoma 14.4.1

@blink1073
Copy link
Member

Hi @IgorFreitasCruz, I just ran a fresh install using the local steps and on my Mac M1 Sonoma 14.4.1 and did not encounter that error. Can you please share the full traceback?

@IgorFreitasCruz
Copy link
Contributor Author

Hi @blink1073.

From backend service:

Executing task: docker logs --tail 1000 -f 950fa4526844a8ef178555c37ce215721952f7d8a3148313d0116241c7270a3e 

Traceback (most recent call last):
  File "/app/app/backend_pre_start.py", line 6, in <module>
    from app.db.session import ping
  File "/app/app/db/session.py", line 4, in <module>
    from odmantic import AIOEngine
  File "/app/.venv/lib/python3.11/site-packages/odmantic/__init__.py", line 4, in <module>
    from .engine import AIOEngine, SyncEngine
  File "/app/.venv/lib/python3.11/site-packages/odmantic/engine.py", line 31, in <module>
    from odmantic.model import Model
  File "/app/.venv/lib/python3.11/site-packages/odmantic/model.py", line 520, in <module>
    class _BaseODMModel(pydantic.BaseModel, metaclass=ABCMeta):
  File "/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 91, in __new__
    config_wrapper = ConfigWrapper.for_model(bases, namespace, kwargs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_config.py", line 122, in for_model
    raise PydanticUserError(
pydantic.errors.PydanticUserError: `model_config` cannot be used as a model field name. Use `model_config` for model configuration.

For further information visit https://errors.pydantic.dev/2.7/u/model-config-invalid-field-name
Traceback (most recent call last):
  File "/app/app/initial_data.py", line 4, in <module>
    from app.db.init_db import init_db
  File "/app/app/db/init_db.py", line 3, in <module>
    from app import crud, schemas
  File "/app/app/crud/__init__.py", line 1, in <module>
    from .crud_user import user
  File "/app/app/crud/crud_user.py", line 5, in <module>
    from app.core.security import get_password_hash, verify_password
  File "/app/app/core/security.py", line 11, in <module>
    from app.schemas import NewTOTP
  File "/app/app/schemas/__init__.py", line 4, in <module>
    from .token import (
  File "/app/app/schemas/token.py", line 3, in <module>
    from odmantic import Model, ObjectId
  File "/app/.venv/lib/python3.11/site-packages/odmantic/__init__.py", line 4, in <module>
    from .engine import AIOEngine, SyncEngine
  File "/app/.venv/lib/python3.11/site-packages/odmantic/engine.py", line 31, in <module>
    from odmantic.model import Model
  File "/app/.venv/lib/python3.11/site-packages/odmantic/model.py", line 520, in <module>
    class _BaseODMModel(pydantic.BaseModel, metaclass=ABCMeta):
  File "/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 91, in __new__
    config_wrapper = ConfigWrapper.for_model(bases, namespace, kwargs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_config.py", line 122, in for_model
    raise PydanticUserError(
pydantic.errors.PydanticUserError: `model_config` cannot be used as a model field name. Use `model_config` for model configuration.

For further information visit https://errors.pydantic.dev/2.7/u/model-config-invalid-field-name
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/app/inboard/start.py", line 134, in <module>
    run_pre_start_script(logger=logger)
  File "/app/inboard/start.py", line 30, in run_pre_start_script
    subprocess.run([process, pre_start_path], check=True)
  File "/usr/local/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['sh', '/app/prestart.sh']' returned non-zero exit status 1.
 *  Terminal will be reused by tasks, press any key to close it.

From celeryworker service:

Executing task: docker logs --tail 1000 -f 7ace5b20b9ac4d9525047d9eda5e43b1cf25c1d4e62591980a240a937c0399b0 

Checking dependencies
Traceback (most recent call last):
  File "/app/app/celeryworker_pre_start.py", line 6, in <module>
    from app.db.session import ping
  File "/app/app/db/session.py", line 4, in <module>
    from odmantic import AIOEngine
  File "/app/.venv/lib/python3.11/site-packages/odmantic/__init__.py", line 4, in <module>
    from .engine import AIOEngine, SyncEngine
  File "/app/.venv/lib/python3.11/site-packages/odmantic/engine.py", line 31, in <module>
    from odmantic.model import Model
  File "/app/.venv/lib/python3.11/site-packages/odmantic/model.py", line 520, in <module>
    class _BaseODMModel(pydantic.BaseModel, metaclass=ABCMeta):
  File "/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 91, in __new__
    config_wrapper = ConfigWrapper.for_model(bases, namespace, kwargs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_config.py", line 122, in for_model
    raise PydanticUserError(
pydantic.errors.PydanticUserError: `model_config` cannot be used as a model field name. Use `model_config` for model configuration.

For further information visit https://errors.pydantic.dev/2.7/u/model-config-invalid-field-name
 *  Terminal will be reused by tasks, press any key to close it.

@blink1073
Copy link
Member

Ah, this has been reported as art049/odmantic#451.

@IgorFreitasCruz
Copy link
Contributor Author

Hi @IgorFreitasCruz, I just ran a fresh install using the local steps and on my Mac M1 Sonoma 14.4.1 and did not encounter that error. Can you please share the full traceback?

How did you manage to get this working? Previous version of odmantic?

@blink1073
Copy link
Member

My guess is a local pip cache. For now you can manually pin pydantic<2.7.

@blink1073 blink1073 reopened this Apr 15, 2024
@blink1073
Copy link
Member

We're going to pin for now in #38. I opened https://jira.mongodb.org/browse/PYTHON-4363 to track unpinning.

@blink1073 blink1073 added the bug Something isn't working label Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants