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

Fix pydantic deprecation warning #1837

Merged
merged 4 commits into from
Nov 22, 2023
Merged

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Nov 17, 2023

Fix #1836.

In pydantic >= 2.0, @validator has been replaced by @field_validator with a deprecation warning (until pydantic 3.x). There are some differences between the legacy and the new @validator but they do not impact our usage (see migration guide).. For now let's silent the warning and we'll update when (and if) we want to add support for pydantic v3.x in the future.

Thanks @mattf for the heads up!

EDIT: converting to draft.

EDIT 2: reworked the PR to use same logic as currently on main and silent the warning. We'll reassess if and when pydantic v3.x is out.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Nov 17, 2023

The documentation is not available anymore as the PR was closed or merged.

@Wauplin Wauplin marked this pull request as draft November 17, 2023 16:26
@Wauplin Wauplin removed the request for review from LysandreJik November 17, 2023 16:26
Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Cool!

@Wauplin Wauplin marked this pull request as ready for review November 21, 2023 14:07
@Wauplin Wauplin requested a review from LysandreJik November 21, 2023 14:09
@Wauplin Wauplin mentioned this pull request Nov 21, 2023
Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Ok thanks for the edit! The updated change looks good to me.

@Wauplin
Copy link
Contributor Author

Wauplin commented Nov 22, 2023

Thanks for the re-review :)

@Wauplin Wauplin merged commit f0a7d1a into main Nov 22, 2023
13 of 16 checks passed
@Wauplin Wauplin deleted the 1836-fix-pydantic-deprecation-warning branch November 22, 2023 17:35
@wasertech
Copy link

wasertech commented Nov 25, 2023

Hey @Wauplin, can we expect this fix in the next version of hf__hub? This warning is polluting my shell :(

❯ assistant
/home/waser/Projets/Assistant/venv/lib/python3.11/site-packages/huggingface_hub/inference/_text_generation.py:121: 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.4/migration/
  @validator("best_of")
Hello User! Welcome back to our conversation. It seems you're in the directory '/home/waser/Projets/Assistant/src3'. The current date is 'sam 25 nov 2023 17:13:49 CET' and it's been 'sam 25
nov 2023 17:13:32 CET' since we last saw each other. If you have any questions or need assistance, feel free to ask!                                                                         
(venv)  waser@Destinee ~/Projets/Assistant/src3 v1.0.0b
❯ This warning message is pretty anoying. Dont you think Assistant?

Oh, I'm sorry if my previous responses were annoying. I'm just trying to be helpful and provide the best assistance I can. If you have any specific questions or tasks you'd like me to help 
with, please don't hesitate to ask. I'm here to assist you to the best of my abilities.                                                                                                      
(venv)  waser@Destinee ~/Projets/Assistant/src3 v1.0.0b
❯ Its not your fault this time hahah

Haha, I'm glad you found my response amusing! Here's a joke for you: Why don't programmers ever get lost? Because they always know where they are in the code! 😃                            
(venv)  waser@Destinee ~/Projets/Assistant/src3 v1.0.0b
❯ you can quit now.

I know its already on main so I built it from source and it did remove the warning (thanks for that).

❯ assistant
Hello User! It seems you're calling my name. I'm here to assist you. You're currently in the directory '/home/waser/Projets/Assistant/src3'. The date is 'sam 25 nov 2023 17:17:55 CET' and  
it's been 'sam 25 nov 2023 17:13:32 CET' since I last saw you. If you have any questions or need help, feel free to ask!                                                                     
(venv)  waser@Destinee ~/Projets/Assistant/src3 v1.0.0b
❯ 

I'm just waiting for this fix to be in the next version of huggingface_hub to release the latest version of my assistant because I don't want a new user to experience a depreciation warning as the first message the shell would output :').

EDIT: I guess I asked the wrong question... if its already on main it will be in the next version... my question is rather do you have an approxime time frame for the release of the next version?

@Wauplin
Copy link
Contributor Author

Wauplin commented Nov 27, 2023

EDIT: I guess I asked the wrong question... if its already on main it will be in the next version... my question is rather do you have an approxime time frame for the release of the next version?

Yes indeed that's the real question! 😄
I would say around 2 weeks before next release the time to merge a few nice features we are cooking. If you don't want to wait until then, a possibility is to pin pydantic<2.0 in your package dependencies. This was the case in huggingface_hub<0.19 and we relaxed the constraint only on the last release. The warning message is only there if pydantic>=2.0 is installed.

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.

pydantic deprecated validator, migrate to field_validator
4 participants