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

πŸ‘¨β€πŸ’» Configure HF Hub URL with environment variable #815

Merged
merged 8 commits into from
Apr 4, 2022

Conversation

SBrandeis
Copy link
Contributor

Closes #808

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Mar 31, 2022

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

@SBrandeis SBrandeis marked this pull request as ready for review March 31, 2022 14:30
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.

This is certainly an interesting solution to the issue.

I think it's an improvement to what we have, so I'd be happy to merge, but I was thinking of a solution where HfApi accepts a hub url, and that one could pass a HfApi instance to Repository. The latter solution would allow for further customization of HfApi used in Repository.

But I'm happy with this solution anyway.

src/huggingface_hub/hf_api.py Outdated Show resolved Hide resolved
@SBrandeis
Copy link
Contributor Author

Is d2dba15 more aligned with what you had in mind ?

@SBrandeis SBrandeis changed the title Configure HF Hub URL with an environment variable Configure HF Hub URL Mar 31, 2022
@SBrandeis SBrandeis changed the title Configure HF Hub URL πŸ‘¨β€πŸ’» Configure HF Hub URL with environment variable Mar 31, 2022
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.

This looks great now.

@@ -13,7 +13,7 @@ def get_version() -> str:

install_requires = [
"filelock",
"requests",
"requests>=2.27",
Copy link
Contributor

Choose a reason for hiding this comment

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

What makes us require a very recent version of requests? This potentially creates dependency conflicts for users trying to install our library alongside other packages which potentially don't support latest requests versions. What's the oldest version we can work with here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Minimal required version of requests is 2.27.0 because we use JSONDecodeError, and it was introduced only in 2.27.0: https://docs.python-requests.org/en/latest/community/updates/#id2

Copy link
Member

Choose a reason for hiding this comment

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

When was 2.27.0 released? and do we know of libraries that pin an upper bound on the version of requests they use?

Copy link
Contributor Author

@SBrandeis SBrandeis Apr 4, 2022

Choose a reason for hiding this comment

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

2.27.0 was released on 2022-03-01 2022-01-03

Copy link
Contributor Author

Choose a reason for hiding this comment

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

requests.JSONDecodeError was introduced by psf/requests#5856

Copy link
Member

Choose a reason for hiding this comment

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

Ok, in my opinion this is ok to ship this version pin, given that most libraries would probably not pin an upper bound on the version of requests they use. And we can always relax this constraint if we realize it's affecting users?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's merge this with this pinned version, I'll open a PR today to fix it and remove the constraint before we release a new version. The pinned version is way too recent. cc @LysandreJik

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.

Thanks for working on it, @SBrandeis!

[Out of scope for this PR, but some thoughts about passing a HfApi argument to other classes]
I didn't expect HfApi to be an argument to Repository. I think it is an elegant solution to the problem, but I wonder if the name that is given to its instance, hf_api, is the best to describe what it actually does.

To me hf_api describes an API that has methods you can call. But here, we're using it as a stateful client instance to the API, which contains configured values which may be leveraged by other classes. To that end, I wonder if client or something along those lines wouldn't be a better variable name after an HfApi instantiation.

@SBrandeis SBrandeis requested a review from adrinjalali April 4, 2022 08:33
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.

Other than renaming the argument, LGTM.

@@ -13,7 +13,7 @@ def get_version() -> str:

install_requires = [
"filelock",
"requests",
"requests>=2.27",
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's merge this with this pinned version, I'll open a PR today to fix it and remove the constraint before we release a new version. The pinned version is way too recent. cc @LysandreJik

src/huggingface_hub/repository.py Outdated Show resolved Hide resolved
@SBrandeis SBrandeis merged commit 9edcb30 into main Apr 4, 2022
@SBrandeis SBrandeis deleted the 808-config-hub-url branch April 4, 2022 09:52
@adrinjalali
Copy link
Contributor

Thanks for the work @SBrandeis. For future PRs, it'd be nice if you could send them from your own fork rather than creating feature branches on the main repo :) We're also trying to have a reviewer merge the PR rather than the author of the PR here :)

@SBrandeis
Copy link
Contributor Author

OK, noted !

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.

HfApi.endpoint should be configurable in Repository
5 participants