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

Huggingface-hub 0.26.0 causes ImportError 'url_to_filename' from 'huggingface_hub.file_download' when import 'LoRAConfig' #748

Closed
sybrenjansen opened this issue Oct 21, 2024 · 3 comments · Fixed by #750
Assignees
Labels
bug Something isn't working

Comments

@sybrenjansen
Copy link

sybrenjansen commented Oct 21, 2024

Environment info

  • adapters version: 1.0.0
  • transformers version: 4.43.4
  • Platform: macOS-14.6.1-arm64-arm-64bit
  • Python version: 3.10.13
  • Huggingface_hub version: 0.26.0
  • Safetensors version: 0.4.5
  • Accelerate version: 0.34.2
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.4.1 (False)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed

Information

When importing from adapters import LoRAConfig I get the following error:

RuntimeError: Failed to import adapters.configuration because of the following error (look up to see its traceback):
cannot import name 'url_to_filename' from 'huggingface_hub.file_download' (./venv/lib/python3.10/site-packages/huggingface_hub/file_download.py)

From looking at the release notes of huggingface-hub, the url_to_filename function has been removed and you should use a different function.

I expect that this will be an issue on different locations in the repo as well.

To reproduce

Steps to reproduce the behavior:

  1. pip install -U adapters transformers huggingface-hub
  2. python -c "from adapters import LoRAConfig"

Giv

Traceback (most recent call last):
  File "./venv/lib/python3.10/site-packages/transformers/utils/import_utils.py", line 1586, in _get_module
    return importlib.import_module("." + module_name, self.__name__)
  File "/Users/x/miniconda3/envs/py310/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "./venv/lib/python3.10/site-packages/adapters/configuration/__init__.py", line 2, in <module>
    from .adapter_config import *
  File "./venv/lib/python3.10/site-packages/adapters/configuration/adapter_config.py", line 6, in <module>
    from ..utils import resolve_adapter_config
  File "./venv/lib/python3.10/site-packages/adapters/utils.py", line 28, in <module>
    from huggingface_hub.file_download import http_get, url_to_filename
ImportError: cannot import name 'url_to_filename' from 'huggingface_hub.file_download' (./venv/lib/python3.10/site-packages/huggingface_hub/file_download.py)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 1075, in _handle_fromlist
  File "./venv/lib/python3.10/site-packages/transformers/utils/import_utils.py", line 1576, in __getattr__
    module = self._get_module(self._class_to_module[name])
  File "./venv/lib/python3.10/site-packages/transformers/utils/import_utils.py", line 1588, in _get_module
    raise RuntimeError(
RuntimeError: Failed to import adapters.configuration because of the following error (look up to see its traceback):
cannot import name 'url_to_filename' from 'huggingface_hub.file_download' (./venv/lib/python3.10/site-packages/huggingface_hub/file_download.py)

Expected behavior

The import statement shouldn't throw an error, but import as normal.

@sybrenjansen sybrenjansen added the bug Something isn't working label Oct 21, 2024
@sybrenjansen sybrenjansen changed the title New huggingface-hub causes ImportError Huggingface-hub 0.26.0 causes ImportError 'url_to_filename' from 'huggingface_hub.file_download' when import 'LoRAConfig' Oct 21, 2024
@14H034160212
Copy link

I met this issue as well. After huggingface-hub 0.26.0, the url_to_filename has been removed. The relative code in the utils.py should be updated.
https://github.com/huggingface/huggingface_hub/releases

@lenglaender lenglaender self-assigned this Oct 22, 2024
@lenglaender
Copy link
Member

Thanks for reporting this critical bug. We will look into this ASAP.

Quick fix: Don't use huggingface_hub version 0.26 or higher. Install the latest compatible release via: pip install huggingface-hub==0.25

@lenglaender
Copy link
Member

Should be fixed once #750 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants