Support data_dir parameter in push_to_hub
State: closed

Support `data_dir` parameter in `push_to_hub`.

This allows users to organize the data files according to their specific needs. For example, "wikimedia/wikipedia" files could be organized by year and/or date, e.g. "2024/20240101/20240101.en".

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/datasets/pr_6634). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@huggingface/datasets, feel free to review this PR so that it can be included in the next release.

<details>
<summary>Show benchmarks</summary>

PyArrow==8.0.0

<details>
<summary>Show updated benchmarks!</summary>

### Benchmark: benchmark_array_xd.json

| metric | read_batch_formatted_as_numpy after write_array2d | read_batch_formatted_as_numpy after write_flattened_sequence | read_batch_formatted_as_numpy after write_nested_sequence | read_batch_unformated after write_array2d | read_batch_unformated after write_flattened_sequence | read_batch_unformated after write_nested_sequence | read_col_formatted_as_numpy after write_array2d | read_col_formatted_as_numpy after write_flattened_sequence | read_col_formatted_as_numpy after write_nested_sequence | read_col_unformated after write_array2d | read_col_unformated after write_flattened_sequence | read_col_unformated after write_nested_sequence | read_formatted_as_numpy after write_array2d | read_formatted_as_numpy after write_flattened_sequence | read_formatted_as_numpy after write_nested_sequence | read_unformated after write_array2d | read_unformated after write_flattened_sequence | read_unformated after write_nested_sequence | write_array2d | write_flattened_sequence | write_nested_sequence |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.005125 / 0.011353 (-0.006228) | 0.003772 / 0.011008 (-0.007236) | 0.063258 / 0.038508 (0.024750) | 0.029479 / 0.023109 (0.006370) | 0.245554 / 0.275898 (-0.030344) | 0.266395 / 0.323480 (-0.057085) | 0.003063 / 0.007986 (-0.004922) | 0.003298 / 0.004328 (-0.001031) | 0.049242 / 0.004250 (0.044991) | 0.042390 / 0.037052 (0.005338) | 0.258176 / 0.258489 (-0.000313) | 0.279935 / 0.293841 (-0.013906) | 0.027910 / 0.128546 (-0.100637) | 0.011033 / 0.075646 (-0.064613) | 0.207763 / 0.419271 (-0.211509) | 0.036127 / 0.043533 (-0.007405) | 0.247363 / 0.255139 (-0.007776) | 0.261309 / 0.283200 (-0.021890) | 0.020259 / 0.141683 (-0.121424) | 1.152760 / 1.452155 (-0.299395) | 1.194853 / 1.492716 (-0.297863) |

### Benchmark: benchmark_getitem\_100B.json

| metric | get_batch_of\_1024\_random_rows | get_batch_of\_1024\_rows | get_first_row | get_last_row |
|--------|---|---|---|---|
| new / old (diff) | 0.088936 / 0.018006 (0.070930) | 0.298396 / 0.000490 (0.297906) | 0.000211 / 0.000200 (0.000011) | 0.000050 / 0.000054 (-0.000004) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.018434 / 0.037411 (-0.018977) | 0.061991 / 0.014526 (0.047466) | 0.072786 / 0.176557 (-0.103771) | 0.120437 / 0.737135 (-0.616698) | 0.078375 / 0.296338 (-0.217964) |

### Benchmark: benchmark_iterating.json

| metric | read 5000 | read 50000 | read_batch 50000 10 | read_batch 50000 100 | read_batch 50000 1000 | read_formatted numpy 5000 | read_formatted pandas 5000 | read_formatted tensorflow 5000 | read_formatted torch 5000 | read_formatted_batch numpy 5000 10 | read_formatted_batch numpy 5000 1000 | shuffled read 5000 | shuffled read 50000 | shuffled read_batch 50000 10 | shuffled read_batch 50000 100 | shuffled read_batch 50000 1000 | shuffled read_formatted numpy 5000 | shuffled read_formatted_batch numpy 5000 10 | shuffled read_formatted_batch numpy 5000 1000 |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.275821 / 0.215209 (0.060612) | 2.703358 / 2.077655 (0.625703) | 1.446783 / 1.504120 (-0.057337) | 1.333556 / 1.541195 (-0.207639) | 1.325753 / 1.468490 (-0.142737) | 0.565196 / 4.584777 (-4.019581) | 2.411193 / 3.745712 (-1.334520) | 2.702764 / 5.269862 (-2.567098) | 1.727425 / 4.565676 (-2.838252) | 0.062966 / 0.424275 (-0.361309) | 0.004985 / 0.007607 (-0.002622) | 0.333473 / 0.226044 (0.107428) | 3.270615 / 2.268929 (1.001687) | 1.822213 / 55.444624 (-53.622411) | 1.546572 / 6.876477 (-5.329905) | 1.568767 / 2.142072 (-0.573305) | 0.655907 / 4.805227 (-4.149321) | 0.117173 / 6.500664 (-6.383491) | 0.042415 / 0.075469 (-0.033054) |

### Benchmark: benchmark_map_filter.json

| metric | filter | map fast-tokenizer batched | map identity | map identity batched | map no-op batched | map no-op batched numpy | map no-op batched pandas | map no-op batched pytorch | map no-op batched tensorflow |
|--------|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.987966 / 1.841788 (-0.853822) | 11.851206 / 8.074308 (3.776898) | 10.327751 / 10.191392 (0.136359) | 0.127929 / 0.680424 (-0.552494) | 0.013781 / 0.534201 (-0.520420) | 0.286910 / 0.579283 (-0.292373) | 0.273615 / 0.434364 (-0.160749) | 0.323373 / 0.540337 (-0.216965) | 0.426407 / 1.386936 (-0.960529) |

</details>
PyArrow==latest

<details>
<summary>Show updated benchmarks!</summary>

### Benchmark: benchmark_array_xd.json

| metric | read_batch_formatted_as_numpy after write_array2d | read_batch_formatted_as_numpy after write_flattened_sequence | read_batch_formatted_as_numpy after write_nested_sequence | read_batch_unformated after write_array2d | read_batch_unformated after write_flattened_sequence | read_batch_unformated after write_nested_sequence | read_col_formatted_as_numpy after write_array2d | read_col_formatted_as_numpy after write_flattened_sequence | read_col_formatted_as_numpy after write_nested_sequence | read_col_unformated after write_array2d | read_col_unformated after write_flattened_sequence | read_col_unformated after write_nested_sequence | read_formatted_as_numpy after write_array2d | read_formatted_as_numpy after write_flattened_sequence | read_formatted_as_numpy after write_nested_sequence | read_unformated after write_array2d | read_unformated after write_flattened_sequence | read_unformated after write_nested_sequence | write_array2d | write_flattened_sequence | write_nested_sequence |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.005412 / 0.011353 (-0.005941) | 0.003619 / 0.011008 (-0.007389) | 0.049603 / 0.038508 (0.011095) | 0.031246 / 0.023109 (0.008136) | 0.279723 / 0.275898 (0.003825) | 0.298557 / 0.323480 (-0.024923) | 0.004253 / 0.007986 (-0.003733) | 0.002758 / 0.004328 (-0.001570) | 0.048931 / 0.004250 (0.044680) | 0.044245 / 0.037052 (0.007193) | 0.295876 / 0.258489 (0.037387) | 0.322720 / 0.293841 (0.028879) | 0.046746 / 0.128546 (-0.081800) | 0.010841 / 0.075646 (-0.064805) | 0.058528 / 0.419271 (-0.360744) | 0.034224 / 0.043533 (-0.009308) | 0.279192 / 0.255139 (0.024053) | 0.299775 / 0.283200 (0.016576) | 0.017862 / 0.141683 (-0.123820) | 1.154478 / 1.452155 (-0.297677) | 1.190483 / 1.492716 (-0.302234) |

### Benchmark: benchmark_getitem\_100B.json

| metric | get_batch_of\_1024\_random_rows | get_batch_of\_1024\_rows | get_first_row | get_last_row |
|--------|---|---|---|---|
| new / old (diff) | 0.088717 / 0.018006 (0.070710) | 0.297905 / 0.000490 (0.297415) | 0.000209 / 0.000200 (0.000009) | 0.000050 / 0.000054 (-0.000004) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.021458 / 0.037411 (-0.015953) | 0.075616 / 0.014526 (0.061090) | 0.087080 / 0.176557 (-0.089476) | 0.125315 / 0.737135 (-0.611821) | 0.088958 / 0.296338 (-0.207381) |

### Benchmark: benchmark_iterating.json

| metric | read 5000 | read 50000 | read_batch 50000 10 | read_batch 50000 100 | read_batch 50000 1000 | read_formatted numpy 5000 | read_formatted pandas 5000 | read_formatted tensorflow 5000 | read_formatted torch 5000 | read_formatted_batch numpy 5000 10 | read_formatted_batch numpy 5000 1000 | shuffled read 5000 | shuffled read 50000 | shuffled read_batch 50000 10 | shuffled read_batch 50000 100 | shuffled read_batch 50000 1000 | shuffled read_formatted numpy 5000 | shuffled read_formatted_batch numpy 5000 10 | shuffled read_formatted_batch numpy 5000 1000 |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.287085 / 0.215209 (0.071876) | 2.807798 / 2.077655 (0.730143) | 1.552201 / 1.504120 (0.048081) | 1.422374 / 1.541195 (-0.118820) | 1.437908 / 1.468490 (-0.030582) | 0.569738 / 4.584777 (-4.015039) | 2.493921 / 3.745712 (-1.251791) | 2.648376 / 5.269862 (-2.621486) | 1.741721 / 4.565676 (-2.823955) | 0.063023 / 0.424275 (-0.361253) | 0.005166 / 0.007607 (-0.002441) | 0.336927 / 0.226044 (0.110882) | 3.384517 / 2.268929 (1.115588) | 1.909888 / 55.444624 (-53.534736) | 1.641879 / 6.876477 (-5.234597) | 1.727734 / 2.142072 (-0.414338) | 0.647127 / 4.805227 (-4.158100) | 0.115831 / 6.500664 (-6.384833) | 0.041161 / 0.075469 (-0.034309) |

### Benchmark: benchmark_map_filter.json

| metric | filter | map fast-tokenizer batched | map identity | map identity batched | map no-op batched | map no-op batched numpy | map no-op batched pandas | map no-op batched pytorch | map no-op batched tensorflow |
|--------|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 1.016310 / 1.841788 (-0.825477) | 12.088500 / 8.074308 (4.014192) | 10.799730 / 10.191392 (0.608338) | 0.129049 / 0.680424 (-0.551375) | 0.015379 / 0.534201 (-0.518822) | 0.291352 / 0.579283 (-0.287931) | 0.284579 / 0.434364 (-0.149785) | 0.331214 / 0.540337 (-0.209124) | 0.422902 / 1.386936 (-0.964034) |

</details>
</details>

![](https://cml.dev/watermark.png#991169ed4901d129d0e0ab8d7fccd6a0728da4b8 "CML watermark")