NeMo-Guardrails icon indicating copy to clipboard operation
NeMo-Guardrails copied to clipboard

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

Open LukeKan opened this issue 10 months ago • 4 comments

Did you check the docs?

  • [x] I have read all the NeMo-Guardrails docs

Is your feature request related to a problem? Please describe.

I suggest to keep up with the latest Pydantic versions since the model_validators that are used inside the library (e.g. nemoguardrails /rails/llm/config.py:975) are deprecated.

Here is an example of the warnings when using the latest Pydantic version (v2.10.5): nemoguardrails/rails/llm/config.py:975: PydanticDeprecatedSince20: Pydantic V1 style @root_validator validators are deprecated. You should migrate to Pydantic V2 style @model_validator validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.9/migration/ @root_validator(pre=True, allow_reuse=True)

Describe the solution you'd like

Update the @root_validator to Pydantic V2 style @model_validator validators.

Describe alternatives you've considered

No relevant alternatives, just update the library.

Additional context

No response

LukeKan avatar Jan 13 '25 13:01 LukeKan

Thank you @LukeKan 👍🏻 Indeed we should upgrade to v2. I think it was not done completely due to backward compatibility reasons but we should be able to do it now.

Pouyanpi avatar Jan 20 '25 16:01 Pouyanpi

@Pouyanpi hi, I tried to raise a PR for this issue, can you help take a look... thanks a lot... https://github.com/NVIDIA/NeMo-Guardrails/pull/967

xiaobo8204 avatar Feb 03 '25 08:02 xiaobo8204

Thank you @xiaobo8204 , I'll review your PR soon.

Pouyanpi avatar Feb 03 '25 10:02 Pouyanpi

@Pouyanpi sure, updated the PR with the review feedback, thanks a lot...

xiaobo8204 avatar Feb 03 '25 20:02 xiaobo8204