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

Use huggingface_hub dependency, remove inlined HF code #409

Merged
merged 4 commits into from
Feb 13, 2021

Conversation

jonashaag
Copy link
Collaborator

Refs #401

Switch to huggingface_hub and allow for https://huggingface.co/ prefixed URLs.

We can also merge without the URL change if @julien-c doesn't like it.

CI currently fails due to missing dependency bump

@mpariente
Copy link
Collaborator

Thanks !
I like the URL change, it makes sense to keep it for me.
Let's add the deps so that CI passes.

We might be able to remove some of the hub dependencies thanks to this.
We might want to merge #386 before this PR, right?

url = hf_bucket_url(model_id=model_id, filename=HF_WEIGHTS_NAME, revision=revision)
return hf_get_from_cache(url, cache_dir=get_cache_dir())
url = huggingface_hub.hf_hub_url(
model_id, filename=huggingface_hub.file_download.PYTORCH_WEIGHTS_NAME, revision=revision
Copy link
Contributor

Choose a reason for hiding this comment

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

I can expose PYTORCH_WEIGHTS_NAME in the library's init.py so that you don't have to import from a nested file

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 would be great.

@@ -57,7 +46,9 @@ def cached_download(filename_or_url):
if os.path.isfile(filename_or_url):
return filename_or_url

if urlparse(filename_or_url).scheme in ("http", "https"):
if filename_or_url.startswith(("http://", "https://")) and not filename_or_url.startswith(
huggingface_hub.file_download.HUGGINGFACE_CO_REPO_URL_BASE
Copy link
Contributor

Choose a reason for hiding this comment

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

I would just add a https://huggingface.co/ constant in this local file as this is unlikely to ever change:)

Copy link
Contributor

Choose a reason for hiding this comment

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

(and I would add the prefix-stripping here, unless you feel strongly about it!)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No strong feelings, we can do it here.

@mpariente
Copy link
Collaborator

Let's address the comments from Julien and merge this?

Your PR in the official repo has been merged right? So we can have the good pip deps?

@jonashaag
Copy link
Collaborator Author

No, we need to move the URL stripping here, see huggingface/huggingface_hub#8. And create a PR for PYTORCH_WEIGHTS_NAME

@julien-c
Copy link
Contributor

Sorry about the looong delay!

I've opened #440 on top of this PR, to make code simpler and re-add the hf.co url prefix trimming.

* Update to huggingface_hub>=0.0.2

* Feature: trim https://huggingface.co/ prefix
@mpariente mpariente merged commit 1db96b2 into master Feb 13, 2021
@mpariente mpariente deleted the huggingface-lib branch February 13, 2021 09:59
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.

3 participants