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

Avoid model_ namespace Pydantic warning #137

Merged
merged 4 commits into from
Nov 19, 2024
Merged

Conversation

CoreyEWood
Copy link
Contributor

@CoreyEWood CoreyEWood commented Nov 19, 2024

Apparently Pydantic fields beginning with model_ fall under the default protected namespace, resulting in these warnings:

/root/.cache/pypoetry/virtualenvs/groundlight-edge-5vySdna4-py3.11/lib/python3.11/site-packages/pydantic/_internal/_fields.py:132: UserWarning: Field "model_binary_id" in ModelInfoWithBinary has conflict with protected namespace "model_".

You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.
  warnings.warn(
/root/.cache/pypoetry/virtualenvs/groundlight-edge-5vySdna4-py3.11/lib/python3.11/site-packages/pydantic/_internal/_fields.py:132: UserWarning: Field "model_binary_url" in ModelInfoWithBinary has conflict with protected namespace "model_".

You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.
  warnings.warn(

@tyler-romero
Copy link
Member

I'd actually much prefer to just set model_config['protected_namespaces'] = () as suggested by the warning. That way we keep the same variable names across services / reduces context switching overhead.

@CoreyEWood CoreyEWood changed the title Rename model fields to avoid Pydantic warning Avoid model_ namespace Pydantic warning Nov 19, 2024
Copy link
Member

@tyler-romero tyler-romero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@CoreyEWood CoreyEWood merged commit 8a0b7da into main Nov 19, 2024
7 checks passed
@CoreyEWood CoreyEWood deleted the model-info-model-fix branch November 19, 2024 22:48
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 this pull request may close these issues.

2 participants