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

Commit creation on pr error when using v0.24.0 #2411

Closed
narugo1992 opened this issue Jul 23, 2024 · 5 comments · Fixed by #2413
Closed

Commit creation on pr error when using v0.24.0 #2411

narugo1992 opened this issue Jul 23, 2024 · 5 comments · Fixed by #2413
Labels
bug Something isn't working

Comments

@narugo1992
Copy link

narugo1992 commented Jul 23, 2024

Describe the bug

When use v0.24.0 to create commit to a pr, 404 error is occurred.

But when i downgrade it to 0.23.5, it's runnable.

Seems like it is related to the empty commit skipped mentioned in #1411, this url is double quoted: https://huggingface.co/api/datasets/narugo/sample_tars/revision/refs%252Fpr%252F2

Reproduction

import os

from huggingface_hub import HfApi, HfFileSystem, CommitOperationAdd

hf_client = HfApi(token=os.environ['HF_TOKEN'])
hf_fs = HfFileSystem(token=os.environ['HF_TOKEN'])

repo = 'my/dataset_repo'
pr_id = 2

ref = hf_client.get_discussion_details(
    repo_id=repo,
    repo_type='dataset',
    discussion_num=pr_id,
).git_reference

# runnable on 0.23.*
# 404 error on 0.24.0, error message
# No files have been modified since last commit. Skipping to prevent empty commit.
# huggingface_hub.utils._errors.RevisionNotFoundError: 404 Client Error. (Request ID: Root=1-669fba92-11c9368a00e7f82e01e5c86e;c4a76daa-bbf7-41e3-8e27-ae75792a0db8)
# Revision Not Found for url: https://huggingface.co/api/datasets/narugo/sample_tars/revision/refs%252Fpr%252F2.
# Invalid rev id: refs%2Fpr%2F2
hf_client.create_commit(
    repo_id=repo,
    repo_type='dataset',
    revision=ref,
    operations=[],
    commit_message='Test Message',
)

Logs

Traceback (most recent call last):                                                                                                                                                                         
  File "/home/narugo/wtf-projects/hfutils/venv/lib/python3.8/site-packages/huggingface_hub/utils/_errors.py", line 304, in hf_raise_for_status
    response.raise_for_status()                                                                                                                                                                            
  File "/home/narugo/wtf-projects/hfutils/venv/lib/python3.8/site-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)                                                                                                                                                         
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://huggingface.co/api/datasets/narugo/sample_tars/revision/refs%252Fpr%252F2
                                                                                                                                                                                                           
The above exception was the direct cause of the following exception:                                                                                                                                       
                                                                                                                                                                                                           
Traceback (most recent call last):                                                                                                                                                                         
  File "test_x.py", line 53, in <module>                                                                                                                                                                   
    hf_client.create_commit(                                                                                                                                                                               
  File "/home/narugo/wtf-projects/hfutils/venv/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn                                                                  
    return fn(*args, **kwargs)                                                                                                                                                                             
  File "/home/narugo/wtf-projects/hfutils/venv/lib/python3.8/site-packages/huggingface_hub/hf_api.py", line 1398, in _inner       
    return fn(self, *args, **kwargs)                                                                                                                                                                       
  File "/home/narugo/wtf-projects/hfutils/venv/lib/python3.8/site-packages/huggingface_hub/hf_api.py", line 3804, in create_commit
    info = self.repo_info(repo_id=repo_id, repo_type=repo_type, revision=revision, token=token)                                                                                                            
  File "/home/narugo/wtf-projects/hfutils/venv/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)                                                                       
  File "/home/narugo/wtf-projects/hfutils/venv/lib/python3.8/site-packages/huggingface_hub/hf_api.py", line 2588, in repo_info
    return method(                                                                                   
  File "/home/narugo/wtf-projects/hfutils/venv/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
  File "/home/narugo/wtf-projects/hfutils/venv/lib/python3.8/site-packages/huggingface_hub/hf_api.py", line 2446, in dataset_info
    hf_raise_for_status(r)
  File "/home/narugo/wtf-projects/hfutils/venv/lib/python3.8/site-packages/huggingface_hub/utils/_errors.py", line 311, in hf_raise_for_status
    raise RevisionNotFoundError(message, response) from e
huggingface_hub.utils._errors.RevisionNotFoundError: 404 Client Error. (Request ID: Root=1-669fba92-11c9368a00e7f82e01e5c86e;c4a76daa-bbf7-41e3-8e27-ae75792a0db8)

Revision Not Found for url: https://huggingface.co/api/datasets/narugo/sample_tars/revision/refs%252Fpr%252F2.
Invalid rev id: refs%2Fpr%2F2

System info

- huggingface_hub version: 0.23.5
- Platform: Linux-5.15.0-116-generic-x86_64-with-glibc2.2.5
- Python version: 3.8.1
- Running in iPython ?: No
- Running in notebook ?: No
- Running in Google Colab ?: No
- Token path ?: /home/narugo/.cache/huggingface/token
- Has saved token ?: True
- Who am I ?: narugo
- Configured git credential helpers: 
- FastAI: N/A
- Tensorflow: N/A
- Torch: N/A
- Jinja2: 3.1.2
- Graphviz: N/A
- keras: N/A
- Pydot: N/A
- Pillow: N/A
- hf_transfer: N/A
- gradio: N/A
- tensorboard: N/A
- numpy: 1.24.4
- pydantic: N/A
- aiohttp: N/A
- ENDPOINT: https://huggingface.co
- HF_HUB_CACHE: /home/narugo/.cache/huggingface/hub
- HF_ASSETS_CACHE: /home/narugo/.cache/huggingface/assets
- HF_TOKEN_PATH: /home/narugo/.cache/huggingface/token
- 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_ENABLE_HF_TRANSFER: False
- HF_HUB_ETAG_TIMEOUT: 10
- HF_HUB_DOWNLOAD_TIMEOUT: 10
@Wauplin
Copy link
Contributor

Wauplin commented Jul 23, 2024

Thanks for reporting @narugo1992, this is indeed a bug. I just opened #2413 to fix it.

@Wauplin
Copy link
Contributor

Wauplin commented Jul 23, 2024

Regarding your script, no need to pass token=os.environ['HF_TOKEN'] since HF_TOKEN environment variable is read by default. This is just a nit, not related to the issue :)

@narugo1992
Copy link
Author

Thanks for reporting @narugo1992, this is indeed a bug. I just opened #2413 to fix it.

ohh, i just open a pr for this lol

@narugo1992
Copy link
Author

@Wauplin btw, will #2413 be in version 0.24.1 or some other version? my library hfutils has dependency on huggingface_hub and this operation. if so i will use huggingface>=0.23,!=0.24.0 in new version.

@Wauplin
Copy link
Contributor

Wauplin commented Jul 24, 2024

@narugo1992 I just merged the PR and shipped huggingface_hub==0.24.2 patch release: https://github.com/huggingface/huggingface_hub/releases/tag/v0.24.2. Both 0.24.0 and 0.24.1 contain the bug you've reported.

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.

2 participants