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 import error for Huggingface-hub version >=0.26.0 & Update Notebooks #750

Merged

Conversation

lenglaender
Copy link
Member

This PR solves an import error, which causes Adapters to not work with huggingface_hub version >= 0.26. This import error comes from HuggingFace removing deprecated functions.

Additionally, I updated all our example notebooks because they were outdated and used the use_auth_token parameter that isn't used by Hugging Face anymore.

Context for Why This Error Occurred

To download files from repositories, we have the download_cached(...) and get_from_cache(...) functions in src/adapters/utils.py. Hugging Face has used similar methods in the past, too - our get_from_cache is copied from them. Now, Hugging Face uses a new method: hf_hub_download(...) (huggingface_hub/file_download.py)

However, we can't use the new hf_hub_download(...) function because it has the validate_hf_hub_args decorator that checks if the arguments are valid. This includes checking if the URL is a Hugging Face repo. Our function, however, also needs to download files from GitHub since we have the mapping between the old AdapterHub adapter paths to the new Hugging Face Hub paths in files that are in GitHub. Therefore, we cannot use the new method and have these methods still copied.

Copy link
Member

@calpt calpt 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 fixing this!

@@ -180,6 +181,38 @@ def remote_file_exists(url):
return r.status_code == 200


# Copied from here: https://github.com/huggingface/huggingface_hub/blob/v0.25.0/src/huggingface_hub/file_download.py#L266
def url_to_filename(url: str, etag: Optional[str] = None) -> str:

Choose a reason for hiding this comment

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

should not add this function back again. Use hf_hub_download() instead.
https://github.com/huggingface/huggingface_hub/releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants