504 Gateway Timeout when uploading large dataset to Hugging Face Hub
CONTRIBUTOR
I transferred to the `datasets` repository. Is there any retry mechanism in `datasets` @lhoestq ?

Another solution @hotchpotch if you want to get your dataset pushed to the Hub in a robust way is to save it to a local folder first and then use `huggingface-cli upload-large-folder` (see https://huggingface.co/docs/huggingface_hub/guides/upload#upload-a-large-folder). It has better retry mechanism in case of failure.
2025-02-14T09:58:20Z
https://github.com/huggingface/datasets/issues/7400#issuecomment-2658794908
https://api.github.com/repos/huggingface/datasets/issues/7400
IC_kwDODunzps6eef2c
https://api.github.com/repos/huggingface/datasets/issues/comments/2658794908/reactions
2025-02-14T09:58:20Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2658794908
https://avatars.githubusercontent.com/u/11801849?v=4
https://api.github.com/users/Wauplin/events{/privacy}
https://api.github.com/users/Wauplin/followers
https://api.github.com/users/Wauplin/following{/other_user}
https://api.github.com/users/Wauplin/gists{/gist_id}
https://github.com/Wauplin
Wauplin
MDQ6VXNlcjExODAxODQ5
https://api.github.com/users/Wauplin/orgs
https://api.github.com/users/Wauplin/received_events
https://api.github.com/users/Wauplin/repos
https://api.github.com/users/Wauplin/starred{/owner}{/repo}
https://api.github.com/users/Wauplin/subscriptions
User
https://api.github.com/users/Wauplin
public
MEMBER
There is no retry mechanism for `api.preupload_lfs_files` in `push_to_hub()` but we can definitely add one here

https://github.com/huggingface/datasets/blob/de062f0552a810c52077543c1169c38c1f0c53fc/src/datasets/arrow_dataset.py#L5372
2025-02-14T17:59:27Z
https://github.com/huggingface/datasets/issues/7400#issuecomment-2659949243
https://api.github.com/repos/huggingface/datasets/issues/7400
IC_kwDODunzps6ei5q7
https://api.github.com/repos/huggingface/datasets/issues/comments/2659949243/reactions
2025-02-14T17:59:27Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2659949243
https://avatars.githubusercontent.com/u/42851186?v=4
https://api.github.com/users/lhoestq/events{/privacy}
https://api.github.com/users/lhoestq/followers
https://api.github.com/users/lhoestq/following{/other_user}
https://api.github.com/users/lhoestq/gists{/gist_id}
https://github.com/lhoestq
lhoestq
MDQ6VXNlcjQyODUxMTg2
https://api.github.com/users/lhoestq/orgs
https://api.github.com/users/lhoestq/received_events
https://api.github.com/users/lhoestq/repos
https://api.github.com/users/lhoestq/starred{/owner}{/repo}
https://api.github.com/users/lhoestq/subscriptions
User
https://api.github.com/users/lhoestq
public
NONE
@Wauplin 

Thank you! I believe that to use load_dataset() to read data from Hugging Face, we need to first save the markdown metadata and parquet files in our local filesystem, then upload them using upload-large-folder. If you know how to do this, could you please let me know?


2025-02-14T23:46:30Z
https://github.com/huggingface/datasets/issues/7400#issuecomment-2660511169
https://api.github.com/repos/huggingface/datasets/issues/7400
IC_kwDODunzps6elC3B
https://api.github.com/repos/huggingface/datasets/issues/comments/2660511169/reactions
2025-02-14T23:46:30Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2660511169
https://avatars.githubusercontent.com/u/3500?v=4
https://api.github.com/users/hotchpotch/events{/privacy}
https://api.github.com/users/hotchpotch/followers
https://api.github.com/users/hotchpotch/following{/other_user}
https://api.github.com/users/hotchpotch/gists{/gist_id}
https://github.com/hotchpotch
hotchpotch
MDQ6VXNlcjM1MDA=
https://api.github.com/users/hotchpotch/orgs
https://api.github.com/users/hotchpotch/received_events
https://api.github.com/users/hotchpotch/repos
https://api.github.com/users/hotchpotch/starred{/owner}{/repo}
https://api.github.com/users/hotchpotch/subscriptions
User
https://api.github.com/users/hotchpotch
public
NONE
@lhoestq 

I see, so adding a retry mechanism there would solve it. If I continue to have issues, I'll consider implementing that kind of solution.
2025-02-14T23:48:35Z
https://github.com/huggingface/datasets/issues/7400#issuecomment-2660514471
https://api.github.com/repos/huggingface/datasets/issues/7400
IC_kwDODunzps6elDqn
https://api.github.com/repos/huggingface/datasets/issues/comments/2660514471/reactions
2025-02-14T23:48:35Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2660514471
https://avatars.githubusercontent.com/u/3500?v=4
https://api.github.com/users/hotchpotch/events{/privacy}
https://api.github.com/users/hotchpotch/followers
https://api.github.com/users/hotchpotch/following{/other_user}
https://api.github.com/users/hotchpotch/gists{/gist_id}
https://github.com/hotchpotch
hotchpotch
MDQ6VXNlcjM1MDA=
https://api.github.com/users/hotchpotch/orgs
https://api.github.com/users/hotchpotch/received_events
https://api.github.com/users/hotchpotch/repos
https://api.github.com/users/hotchpotch/starred{/owner}{/repo}
https://api.github.com/users/hotchpotch/subscriptions
User
https://api.github.com/users/hotchpotch
public
### Description
I encountered consistent 504 Gateway Timeout errors while attempting to upload a large dataset (approximately 500GB) to the Hugging Face Hub. The upload fails during the process with a Gateway Timeout error.

I will continue trying to upload. While it might succeed in future attempts, I wanted to report this issue in the meantime.

### Reproduction
- I attempted the upload 3 times
- Each attempt resulted in the same 504 error during the upload process (not at the start, but in the middle of the upload)
- Using `dataset.push_to_hub()` method

### Environment Information


```
- huggingface_hub version: 0.28.0
- Platform: Linux-6.8.0-52-generic-x86_64-with-glibc2.39
- Python version: 3.11.10
- Running in iPython ?: No
- Running in notebook ?: No
- Running in Google Colab ?: No
- Running in Google Colab Enterprise ?: No
- Token path ?: /home/hotchpotch/.cache/huggingface/token
- Has saved token ?: True
- Who am I ?: hotchpotch
- Configured git credential helpers: store
- FastAI: N/A
- Tensorflow: N/A
- Torch: 2.5.1
- Jinja2: 3.1.5
- Graphviz: N/A
- keras: N/A
- Pydot: N/A
- Pillow: 10.4.0
- hf_transfer: N/A
- gradio: N/A
- tensorboard: N/A
- numpy: 1.26.4
- pydantic: 2.10.6
- aiohttp: 3.11.11
- ENDPOINT: https://huggingface.co
- HF_HUB_CACHE: /home/hotchpotch/.cache/huggingface/hub
- HF_ASSETS_CACHE: /home/hotchpotch/.cache/huggingface/assets
- HF_TOKEN_PATH: /home/hotchpotch/.cache/huggingface/token
- HF_STORED_TOKENS_PATH: /home/hotchpotch/.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_ENABLE_HF_TRANSFER: False
- HF_HUB_ETAG_TIMEOUT: 10
- HF_HUB_DOWNLOAD_TIMEOUT: 10

```



### Full Error Traceback

```python
Traceback (most recent call last):
  File "/home/hotchpotch/src/github.com/hotchpotch/fineweb-2-edu-classifier-japanese/.venv/lib/python3.11/site-packages/huggingface_hub/utils/_http.py", line 406, in hf_raise_for_status
    response.raise_for_status()
  File "/home/hotchpotch/src/github.com/hotchpotch/fineweb-2-edu-classifier-japanese/.venv/lib/python3.11/site-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 504 Server Error: Gateway Time-out for url: https://huggingface.co/datasets/hotchpotch/fineweb-2-edu-japanese.git/info/lfs/objects/batch

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

Traceback (most recent call last):
  File "/home/hotchpotch/src/github.com/hotchpotch/fineweb-2-edu-classifier-japanese/create_edu_japanese_ds/upload_edu_japanese_ds.py", line 12, in <module>
    ds.push_to_hub("hotchpotch/fineweb-2-edu-japanese", private=True)
  File "/home/hotchpotch/src/github.com/hotchpotch/fineweb-2-edu-classifier-japanese/.venv/lib/python3.11/site-packages/datasets/dataset_dict.py", line 1665, in push_to_hub
    split_additions, uploaded_size, dataset_nbytes = self[split]._push_parquet_shards_to_hub(
                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hotchpotch/src/github.com/hotchpotch/fineweb-2-edu-classifier-japanese/.venv/lib/python3.11/site-packages/datasets/arrow_dataset.py", line 5301, in _push_parquet_shards_to_hub
    api.preupload_lfs_files(
  File "/home/hotchpotch/src/github.com/hotchpotch/fineweb-2-edu-classifier-japanese/.venv/lib/python3.11/site-packages/huggingface_hub/hf_api.py", line 4215, in preupload_lfs_files
    _upload_lfs_files(
  File "/home/hotchpotch/src/github.com/hotchpotch/fineweb-2-edu-classifier-japanese/.venv/lib/python3.11/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/hotchpotch/src/github.com/hotchpotch/fineweb-2-edu-classifier-japanese/.venv/lib/python3.11/site-packages/huggingface_hub/_commit_api.py", line 395, in _upload_lfs_files
    batch_actions_chunk, batch_errors_chunk = post_lfs_batch_info(
                                              ^^^^^^^^^^^^^^^^^^^^
  File "/home/hotchpotch/src/github.com/hotchpotch/fineweb-2-edu-classifier-japanese/.venv/lib/python3.11/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/hotchpotch/src/github.com/hotchpotch/fineweb-2-edu-classifier-japanese/.venv/lib/python3.11/site-packages/huggingface_hub/lfs.py", line 168, in post_lfs_batch_info
    hf_raise_for_status(resp)
  File "/home/hotchpotch/src/github.com/hotchpotch/fineweb-2-edu-classifier-japanese/.venv/lib/python3.11/site-packages/huggingface_hub/utils/_http.py", line 477, in hf_raise_for_status
    raise _format(HfHubHTTPError, str(e), response) from e
huggingface_hub.errors.HfHubHTTPError: 504 Server Error: Gateway Time-out for url: https://huggingface.co/datasets/hotchpotch/fineweb-2-edu-japanese.git/info/lfs/objects/batch
```
