Issue: Fix download for dict of dicts of URLs
State: closed
Author: albertvillanova

Fix download for a dict of dicts of URLs when batched (default), introduced by:
- #6794

This PR also implements regression tests.

Fix #6869, fix #6850.

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

Once merged, I think a patch release is needed.

Once the CI is green, I am merging this PR and making a patch release, @huggingface/datasets. 

<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.005352 / 0.011353 (-0.006001) | 0.004140 / 0.011008 (-0.006868) | 0.063844 / 0.038508 (0.025336) | 0.030712 / 0.023109 (0.007603) | 0.232790 / 0.275898 (-0.043108) | 0.262334 / 0.323480 (-0.061145) | 0.003264 / 0.007986 (-0.004721) | 0.002654 / 0.004328 (-0.001674) | 0.049775 / 0.004250 (0.045524) | 0.046803 / 0.037052 (0.009751) | 0.250667 / 0.258489 (-0.007822) | 0.283581 / 0.293841 (-0.010260) | 0.027660 / 0.128546 (-0.100886) | 0.010560 / 0.075646 (-0.065087) | 0.208676 / 0.419271 (-0.210596) | 0.035415 / 0.043533 (-0.008118) | 0.235380 / 0.255139 (-0.019759) | 0.261220 / 0.283200 (-0.021980) | 0.019551 / 0.141683 (-0.122132) | 1.140196 / 1.452155 (-0.311959) | 1.173021 / 1.492716 (-0.319696) |

### 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.092665 / 0.018006 (0.074659) | 0.301524 / 0.000490 (0.301034) | 0.000216 / 0.000200 (0.000016) | 0.000043 / 0.000054 (-0.000011) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.018485 / 0.037411 (-0.018927) | 0.061722 / 0.014526 (0.047196) | 0.074701 / 0.176557 (-0.101855) | 0.121443 / 0.737135 (-0.615692) | 0.076268 / 0.296338 (-0.220070) |

### 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.284143 / 0.215209 (0.068934) | 2.789979 / 2.077655 (0.712324) | 1.501156 / 1.504120 (-0.002964) | 1.379414 / 1.541195 (-0.161781) | 1.419092 / 1.468490 (-0.049398) | 0.554107 / 4.584777 (-4.030670) | 2.365659 / 3.745712 (-1.380053) | 2.763963 / 5.269862 (-2.505898) | 1.712587 / 4.565676 (-2.853090) | 0.060961 / 0.424275 (-0.363314) | 0.005301 / 0.007607 (-0.002306) | 0.346253 / 0.226044 (0.120209) | 3.351833 / 2.268929 (1.082905) | 1.831946 / 55.444624 (-53.612679) | 1.556530 / 6.876477 (-5.319947) | 1.574185 / 2.142072 (-0.567887) | 0.630396 / 4.805227 (-4.174831) | 0.116126 / 6.500664 (-6.384538) | 0.042391 / 0.075469 (-0.033078) |

### 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.981430 / 1.841788 (-0.860358) | 11.619671 / 8.074308 (3.545363) | 9.718227 / 10.191392 (-0.473165) | 0.130918 / 0.680424 (-0.549506) | 0.014116 / 0.534201 (-0.520085) | 0.288729 / 0.579283 (-0.290554) | 0.259183 / 0.434364 (-0.175181) | 0.323764 / 0.540337 (-0.216574) | 0.420336 / 1.386936 (-0.966600) |

</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.005255 / 0.011353 (-0.006098) | 0.003664 / 0.011008 (-0.007344) | 0.051376 / 0.038508 (0.012868) | 0.030429 / 0.023109 (0.007320) | 0.263090 / 0.275898 (-0.012808) | 0.289959 / 0.323480 (-0.033521) | 0.004214 / 0.007986 (-0.003772) | 0.002782 / 0.004328 (-0.001546) | 0.049043 / 0.004250 (0.044793) | 0.041016 / 0.037052 (0.003964) | 0.275616 / 0.258489 (0.017127) | 0.303350 / 0.293841 (0.009509) | 0.029484 / 0.128546 (-0.099062) | 0.010329 / 0.075646 (-0.065317) | 0.058680 / 0.419271 (-0.360591) | 0.032818 / 0.043533 (-0.010715) | 0.263368 / 0.255139 (0.008229) | 0.286839 / 0.283200 (0.003640) | 0.018029 / 0.141683 (-0.123654) | 1.169207 / 1.452155 (-0.282948) | 1.206568 / 1.492716 (-0.286148) |

### 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.101394 / 0.018006 (0.083387) | 0.310414 / 0.000490 (0.309924) | 0.000213 / 0.000200 (0.000013) | 0.000053 / 0.000054 (-0.000002) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.021662 / 0.037411 (-0.015749) | 0.075320 / 0.014526 (0.060794) | 0.086607 / 0.176557 (-0.089949) | 0.127268 / 0.737135 (-0.609867) | 0.088244 / 0.296338 (-0.208095) |

### 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.293591 / 0.215209 (0.078382) | 2.871845 / 2.077655 (0.794190) | 1.543624 / 1.504120 (0.039504) | 1.426698 / 1.541195 (-0.114497) | 1.445348 / 1.468490 (-0.023142) | 0.565156 / 4.584777 (-4.019621) | 0.961782 / 3.745712 (-2.783930) | 2.827904 / 5.269862 (-2.441958) | 1.747728 / 4.565676 (-2.817949) | 0.063275 / 0.424275 (-0.361000) | 0.004987 / 0.007607 (-0.002620) | 0.349652 / 0.226044 (0.123607) | 3.448635 / 2.268929 (1.179707) | 1.891734 / 55.444624 (-53.552890) | 1.624274 / 6.876477 (-5.252202) | 1.641531 / 2.142072 (-0.500541) | 0.642081 / 4.805227 (-4.163146) | 0.116136 / 6.500664 (-6.384528) | 0.040807 / 0.075469 (-0.034662) |

### 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.002090 / 1.841788 (-0.839697) | 12.401097 / 8.074308 (4.326788) | 9.799316 / 10.191392 (-0.392076) | 0.131770 / 0.680424 (-0.548654) | 0.016817 / 0.534201 (-0.517384) | 0.301136 / 0.579283 (-0.278147) | 0.136810 / 0.434364 (-0.297554) | 0.384740 / 0.540337 (-0.155598) | 0.423779 / 1.386936 (-0.963157) |

</details>
</details>

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