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

Logging fix for hf_api, logging documentation #748

Merged
merged 3 commits into from
Mar 10, 2022
Merged

Conversation

LysandreJik
Copy link
Member

This fixes an issue with the logging of hf_api, replaces logger.error for deprecation warnings by a FutureWarning, and adds a small document regarding how to use logging with huggingface_hub.

cc @FrancescoSaverioZuppichini as you have raised the issue with hf_api this morning.

Copy link
Contributor

@muellerzr muellerzr left a comment

Choose a reason for hiding this comment

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

LG2M, should we also include a note on how to expose the logging functionality when running tests?

E.g.

pytest -sv tests/ --log-cli-level=INFO

Copy link
Contributor

@osanseviero osanseviero left a comment

Choose a reason for hiding this comment

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

LG!

```

## Controlling the logging of `huggingface_hub`
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this information be in README? How are we going to create the documentation for this library? We probably need quite a few user guides and I think this should go in one of those, which probably should be located in the /doc folder.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm putting this here for now, but this should definitely be in a separate guide as outlined in https://github.com/huggingface/huggingface_hub/issues/754

logging.error(
"HfApi.login: This method is deprecated in favor of `set_access_token`."
warnings.warn(
"HfApi.login: This method is deprecated in favor of `set_access_token`.",
Copy link
Contributor

Choose a reason for hiding this comment

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

should we mention when it will be removed? Do we have a deprecation cycle policy?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm adding a mention to v0.7: we should remove this as soon as possible, but there are downstream libraries using it still, so it's important to give them time to switch.

There's no written deprecation cycle policy, but I agree it would be welcome.

src/huggingface_hub/hf_api.py Show resolved Hide resolved
@LysandreJik LysandreJik requested a review from adrinjalali March 10, 2022 08:09
Copy link
Contributor

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

Thanks @LysandreJik , other than the formatting LGTM.

Comment on lines +145 to +146
match=r"HfApi.login: This method is deprecated in favor of "
r"`set_access_token` and will be removed in v0.7.",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is not black formatted.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, it is! I've split it in two to respect the 88 line char limit, black seems okay with it

Copy link
Member Author

Choose a reason for hiding this comment

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

Black unindented it, the second line was previously indented at the same level as the | in match=|

Copy link
Contributor

Choose a reason for hiding this comment

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

OK

@adrinjalali adrinjalali merged commit b5cb233 into main Mar 10, 2022
@adrinjalali adrinjalali deleted the logging-fix branch March 10, 2022 12:50
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.

4 participants