← All tasks
pythonhuggingface/huggingface_hub #3777Not a task: already works

Issue with downloading a model using hf cli.

envgap__huggingface__huggingface_hub-3777

01 / FAILURE SIGNATURE

As reported upstream

AttributeError: 'UnixFileLock' object has no attribute '_thread_lock'
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
1346ac63a33af77247bfdf4c09bf081cf2c0d4c6
Manifest
setup.py
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

huggingface/huggingface_hub #3777 · read the original issue
### Describe the bug

Hello I got this error when downloading again a public model from the repository: 
```shell  
hf download Xenova/paraphrase-multilingual-MiniLM-L12-v2 --local-dir ./models/paraphrase-multilingual-MiniLM-L12-v
```

was after deleting the model from my local, and decided to run the HF download, but was successful the first time I ran it

### Reproduction

_No response_

### Logs

```shell
Downloading (incomplete total...): 0.00B [00:00, ?B/s]Exception ignored in: <function BaseFileLock.__del__ at 0x7f4be643c820>
Traceback (most recent call last):
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 240, in __del__
Exception ignored in: <function BaseFileLock.__del__ at 0x7f4be643c820>
    self.release(force=True)
Traceback (most recent call last):
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 240, in __del__
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 201, in release
    self.release(force=True)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 201, in release
Exception ignored in: <function BaseFileLock.__del__ at 0x7f4be643c820>
Traceback (most recent call last):
Exception ignored in: <function BaseFileLock.__del__ at 0x7f4be643c820>
Traceback (most recent call last):
Exception ignored in: <function BaseFileLock.__del__ at 0x7f4be643c820>
Traceback (most recent call last):
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 240, in __del__
Exception ignored in: <function BaseFileLock.__del__ at 0x7f4be643c820>
Traceback (most recent call last):
Exception ignored in: <function BaseFileLock.__del__ at 0x7f4be643c820>
Traceback (most recent call last):
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 240, in __del__
    with self._thread_lock:

Exception ignored in: <function BaseFileLock.__del__ at 0x7f4be643c820>
Traceback (most recent call last):
AttributeError: 'UnixFileLock' object has no attribute '_thread_lock'
Fetching 15 files:   0%|                                                                                                              | 0/15 [00:00<?, ?it/s]  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 240, in __del__
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 240, in __del__
    with self._thread_lock:
AttributeError: 'UnixFileLock' object has no attribute '_thread_lock'
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 240, in __del__
    self.release(force=True)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 201, in release
    self.release(force=True)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 201, in release
    self.release(force=True)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 240, in __del__
    with self._thread_lock:
Exception ignored in: <function BaseFileLock.__del__ at 0x7f4be643c820>
Traceback (most recent call last):
AttributeError: 'UnixFileLock' object has no attribute '_thread_lock'
    self.release(force=True)
    self.release(force=True)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 201, in release
Exception ignored in: <function BaseFileLock.__del__ at 0x7f4be643c820>
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 201, in release
    self.release(force=True)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 201, in release
    with self._thread_lock:
AttributeError: 'UnixFileLock' object has no attribute '_thread_lock'
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 240, in __del__
    with self._thread_lock:
AttributeError: 'UnixFileLock' object has no attribute '_thread_lock'
Fetching 15 files:   0%|                                                                                                              | 0/15 [00:00<?, ?it/s]AttributeError: 'UnixFileLock' object has no attribute '_thread_lock'
Traceback (most recent call last):

    with self._thread_lock:
    self.release(force=True)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 201, in release
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 240, in __del__
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 201, in release
    self.release(force=True)
AttributeError: 'UnixFileLock' object has no attribute '_thread_lock'
    with self._thread_lock:
AttributeError: 'UnixFileLock' object has no attribute '_thread_lock'
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/filelock/_api.py", line 201, in release
    with self._thread_lock:
AttributeError: 'UnixFileLock' object has no attribute '_thread_lock'
    with self._thread_lock:
AttributeError: 'UnixFileLock' object has no attribute '_thread_lock'
Traceback (most recent call last):
  File "/home/aflores/.pyenv/versions/venvexample/bin/hf", line 8, in <module>
    sys.exit(main())
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/huggingface_hub/cli/hf.py", line 77, in main
    app()
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/typer/main.py", line 336, in __call__
    raise e
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/typer/main.py", line 319, in __call__
    return get_command(self)(*args, **kwargs)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/typer/core.py", line 814, in main
    return _main(
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/typer/core.py", line 190, in _main
    rv = self.invoke(ctx)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/typer/main.py", line 706, in wrapper
    return callback(**use_params)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/huggingface_hub/cli/download.py", line 196, in download
    _print_result(run_download())
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/huggingface_hub/cli/download.py", line 157, in run_download
    return snapshot_download(
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 89, in _inner_fn
    return fn(*args, **kwargs)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/huggingface_hub/_snapshot_download.py", line 449, in snapshot_download
    thread_map(
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/tqdm/contrib/concurrent.py", line 69, in thread_map
    return _executor_map(ThreadPoolExecutor, fn, *iterables, **tqdm_kwargs)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/tqdm/contrib/concurrent.py", line 51, in _executor_map
    return list(tqdm_class(ex.map(fn, *iterables, chunksize=chunksize), **kwargs))
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/tqdm/std.py", line 1181, in __iter__
    for obj in iterable:
  File "/home/aflores/.pyenv/versions/3.10.3/lib/python3.10/concurrent/futures/_base.py", line 609, in result_iterator
    yield fs.pop().result()
  File "/home/aflores/.pyenv/versions/3.10.3/lib/python3.10/concurrent/futures/_base.py", line 439, in result
    return self.__get_result()
  File "/home/aflores/.pyenv/versions/3.10.3/lib/python3.10/concurrent/futures/_base.py", line 391, in __get_result
    raise self._exception
  File "/home/aflores/.pyenv/versions/3.10.3/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/huggingface_hub/_snapshot_download.py", line 429, in _inner_hf_hub_download
    hf_hub_download(  # type: ignore
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 89, in _inner_fn
    return fn(*args, **kwargs)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1003, in hf_hub_download
    return _hf_hub_download_to_local_dir(
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1288, in _hf_hub_download_to_local_dir
    paths = get_local_download_paths(local_dir=local_dir, filename=filename)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/huggingface_hub/_local_folder.py", line 218, in get_local_download_paths
    metadata_path = _huggingface_dir(local_dir) / "download" / f"{sanitized_filename}.metadata"
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/huggingface_hub/_local_folder.py", line 437, in _huggingface_dir
    with WeakFileLock(gitignore_lock, timeout=0.1):
  File "/home/aflores/.pyenv/versions/3.10.3/lib/python3.10/contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "/home/aflores/.pyenv/versions/3.10.3/envs/venvexample/lib/python3.10/site-packages/huggingface_hub/utils/_fixes.py", line 92, in WeakFileLock
    lock = FileLock(lock_file, timeout=log_interval, mode=0o664)
TypeError: BaseFileLock.__init__() got an unexpected keyword argument 'mode'
Downloading (incomplete total...): 0.00B [00:00, ?B/s]
```

### System info

```shell
Copy-and-paste the text below in your GitHub issue.

- huggingface_hub version: 1.4.0
- Platform: Linux-5.15.0-139-generic-x86_64-with-glibc2.31
- Python version: 3.10.3
- Running in iPython ?: No
- Running in notebook ?: No
- Running in Google Colab ?: No
- Running in Google Colab Enterprise ?: No
- Token path ?: /home/aflores/.cache/huggingface/token
- Has saved token ?: True
- Who am I ?: alexc957
- Configured git credential helpers: 
- Installation method: unknown
- httpx: 0.28.1
- hf_xet: 1.2.0
- gradio: N/A
- tensorboard: N/A
- ENDPOINT: https://huggingface.co
- HF_HUB_CACHE: /home/aflores/.cache/huggingface/hub
- HF_ASSETS_CACHE: /home/aflores/.cache/huggingface/assets
- HF_TOKEN_PATH: /home/aflores/.cache/huggingface/token
- HF_STORED_TOKENS_PATH: /home/aflores/.cache/huggingface/stored_tokens
- HF_HUB_OFFLINE: False
- HF_HUB_DISABLE_TELEMETRY: False
- HF_HUB_DISABLE_PROGRESS_BARS: None
- HF_HUB_DISABLE_SYMLINKS_WARNING: False
- HF_HUB_DISABLE_EXPERIMENTAL_WARNING: False
- HF_HUB_DISABLE_IMPLICIT_TOKEN: False
- HF_HUB_DISABLE_XET: False
- HF_HUB_ETAG_TIMEOUT: 10
- HF_HUB_DOWNLOAD_TIMEOUT: 10
- HF_XET_HIGH_PERFORMANCE: False
```
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]