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

feat: refactor validators and fields to support pydantic v2 #967

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

xiaobo8204
Copy link
Contributor

Description

This PR aims to update Pydantic to the latest v2.10.6, and switch to use the new model_validator/Field/field_validator in the new Pydantic version.

Related Issue(s)

Checklist

  • [Y] I've read the CONTRIBUTING guidelines.
  • [Y] I've updated the documentation if applicable.
  • [Y] I've added tests if applicable.
  • [Y] @mentions of the person or team responsible for reviewing proposed changes.

@xiaobo8204 xiaobo8204 changed the title Upgrade Pydantic to v2.10.6: Migrated Validators, Field Enhancements #929 Upgrade Pydantic to v2.10.6: Migrated Validators, Field Enhancements Feb 3, 2025
@Pouyanpi Pouyanpi self-requested a review February 3, 2025 10:09
@Pouyanpi
Copy link
Collaborator

Pouyanpi commented Feb 3, 2025

@xiaobo8204 thanks for your contribution to NeMo Guardrails 👍🏻 would you please sign all your commits following the contributing guidelines. You should see a Verified tag for all your commits.

@Pouyanpi Pouyanpi added the enhancement New feature or request label Feb 3, 2025
@@ -65,7 +65,7 @@ langchain-community = ">=0.0.16,<0.4.0"
lark = ">=1.1.7"
nest-asyncio = ">=1.5.6,"
prompt-toolkit = ">=3.0"
pydantic = ">=1.10"
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should relax it a bit, probably >= 2.0

And I still need to see the reasons we were still supporting Pydantic 1.0, I'll get back to this later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the extra log.text and hidden file, changed the version to >= 2.0, and signed the commit, thanks...

@Pouyanpi Pouyanpi changed the title Upgrade Pydantic to v2.10.6: Migrated Validators, Field Enhancements feat: refactor validators and fields to support pydantic v2 Feb 3, 2025
@xiaobo8204 xiaobo8204 force-pushed the feature/xiaobo_dev_features branch from c5a4d19 to 8581787 Compare February 3, 2025 20:23
- Refactored code to use `@model_validator` instead of `@root_validator`
- Updated `Field` usage to align with Pydantic v2 standards
- Modified validation logic to comply with the new API
- Updated `poetry.lock` and dependencies in `pyproject.toml`
@xiaobo8204 xiaobo8204 force-pushed the feature/xiaobo_dev_features branch from 8581787 to bb87907 Compare February 3, 2025 20:44
@Pouyanpi Pouyanpi added this to the v0.13.0 milestone Feb 26, 2025
@Pouyanpi Pouyanpi self-assigned this Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature: Update Pydantic to v2.10.5 and remove Deprecated validators
2 participants