mlflow / mlflow

Open source platform for the machine learning lifecycle
https://mlflow.org
Apache License 2.0
18.28k stars 4.13k forks source link

[BUG] Pydantic validator and root_validator are deprecated #12654

Open MariusMerkleQC opened 1 month ago

MariusMerkleQC commented 1 month ago

Issues Policy acknowledgement

Where did you encounter this bug?

Local machine

Willingness to contribute

Yes. I would be willing to contribute a fix for this bug with guidance from the MLflow community.

MLflow version

System information

Describe the problem

Pydantic's validator and root_validator are deprecated and should be changed to field_validator and model_validator, respectively.

Tracking information

REPLACE_ME

Code to reproduce issue

import mlflow

Stack trace

/opt/homebrew/Caskroom/mambaforge/base/envs/<virual_environemnt>/lib/python3.11/site-packages/mlflow/gateway/config.py:412: PydanticDeprecatedSince20: Pydantic V1 style `@validator` validators are deprecated. You should migrate to Pydantic V2 style `@field_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.8/migration/
    @validator("route_type", pre=True)

/opt/homebrew/Caskroom/mambaforge/base/envs/<virtual_environment>/lib/python3.11/site-packages/mlflow/gateway/config.py:390: 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.8/migration/
    @root_validator(skip_on_failure=True)

Other info / logs

REPLACE_ME

What component(s) does this bug affect?

What interface(s) does this bug affect?

What language(s) does this bug affect?

What integration(s) does this bug affect?

B-Step62 commented 1 month ago

@MariusMerkleQC Thank you for reporting the issue! Yes, it seems there are quite a few places that uses the old decorator in this config file.

We still needs to keep backward compatibility to pydantic V1, so ideally we can have version handling like this. Would you mind contributing for this update?

MariusMerkleQC commented 1 month ago

Sure, I just opened the PR.

github-actions[bot] commented 1 month ago

@mlflow/mlflow-team Please assign a maintainer and start triaging this issue.

bonastreyair commented 1 week ago

I am sorry, I just created a duplicated ticket ticket, sorry... https://github.com/mlflow/mlflow/issues/13018

I closed it and support this one.