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 FutureWarnings for huggingface_hub>=0.10 #152

Closed

Conversation

BenjaminBossan
Copy link
Collaborator

For that Hub version, the use of the token argument produces a FutureWarning, leading our CI to fail. This PR fixes the warnings while leaving everything the same on the user side (i.e. they don't need to change the token argument).

Implementation

As discussed, we will not change the argument name on the skops, preferring token to use_auth_token.

For the version checking, I went with the private Version class from scipy, which follows PEP440. This follows the approach taken in skorch (see this issue: skorch-dev/skorch#887), though we import it here instead of vendoring. Let me know if another approach is preferred.

For that Hub version, the use of the "token" argument produces a
FutureWarning, leading our CI to fail. This PR fixes the warnings while
leaving everything the same on the user side (i.e. they don't need to
change the "token" argument).

Implementation

As discussed, we will not change the argument name on the skops,
preferring token to use_auth_token.

For the version checking, I went with the private Version class from
scipy, which follows PEP440. This follows the approach taken in
skorch (see this issue:
skorch-dev/skorch#887), though we import it
here instead of vendoring. Let me know if another approach is preferred.
- Since version is currently RC, it is not in fact >=0.10
- There is a somewhat confusing mixture of token and use_auth_token
@BenjaminBossan
Copy link
Collaborator Author

@skops-dev/maintainers ready for review. Until this or another fix is merged, all our CI runs will fail, so this PR should have priority over the others.

CI only checks huggingface_hub-0.10.0rc0 but locally I also tested with huggingface_hub-0.9.1 and it succeeded. Theoretically, it would be best to add both versions to the test matrix if we plan on supporting them for a while, but that would multiply the number of test runs by another factor of 2, so not worth it IMO.

Copy link
Member

@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.

Comment on lines +630 to +634
# TODO: remove once we drop support for Hub<0.10
if Version(huggingface_hub.__version__) <= Version("0.9.1"):
extra_kwargs = {"token": token}
else:
extra_kwargs = {"use_auth_token": token}
Copy link
Member

Choose a reason for hiding this comment

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

rather have this in fixes.py as well.

Copy link
Member

Choose a reason for hiding this comment

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

and we don't need to check for version, we try with use_auth_token, if it fails we do token.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, I understand that try...except allows us to skirt having version checking code. But having a bunch of

try:
    client.foo(repo_id=repo_id, repo_type="model", token=token)
except TypeError:
    client.foo(repo_id=repo_id, repo_type="model", use_auth_token=token)

looks suboptimal to me. It litters our code in multiple places, instead of dealing with the issue once. And, just as a stupid example, what if Hub re-introduces the token argument but with a different functionality, it could lead to unwanted side-effects.

Copy link
Member

Choose a reason for hiding this comment

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

We can have a Client class in fixes.py which does this, and import that instead, and that class exposes the methods we need in skops, and handles different versions there. The rest of the codebase would stay clean this way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That might be a solution, though a bit of a bigger undertaking with some open questions:

  • private or public?
  • automatically expose all methods or only those we use?
  • handle versions with try...expect or version checks?
  • also handle inference api?
  • testing will probably not be quite trivial

As a quick fix for this issue here, we could also pin the huggingface_hub version and close this PR. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Since we don't have many users yet, I'm also okay with closing this, and then moving along with using modelcards from the new release, which would mean depending on the latest one anyway, and we won't have this issue. So happy to close (I'd leave that to you).

@BenjaminBossan
Copy link
Collaborator Author

I'm also okay with closing this, and then moving along with using modelcards from the new release, which would mean depending on the latest one anyway, and we won't have this issue. So happy to close (I'd leave that to you).

Agree. We also merged #158 for now, so this PR is not strictly necessary.

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.

2 participants