Validate config name and data_files in packaged modules
Opened by albertvillanova (closed)

Validate the config attributes `name` and `data_files` in packaged modules by making the derived classes call their parent `__post_init__` method.

Note that their parent `BuilderConfig` validates its attributes `name` and `data_files` in its `__post_init__` method: https://github.com/huggingface/datasets/blob/60d21efbc01e15d0b596ac1072750cbecd91548a/src/datasets/builder.py#L128-L137

This PR makes the derived config classes call their parent `__post_init__` method to validate their `name` and `data_files` attributes.

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

I pushed a change that fixes 2.15 cache reloading (I fixed the packaged module hash), feel free to merge if this change is fine for you

Something weird happened in GitHub: I just merged this PR to main, See: https://github.com/huggingface/datasets/commit/5bbbf1b19766e31a6905f3e82bf3aa3f9f84a982

However this PR still appears as Open...

If I retry to merge this PR, an error appears: "Merge attempt failed: Merge already in progress"
![Screenshot from 2024-06-06 06-29-22](https://github.com/huggingface/datasets/assets/8515462/5fe87442-cc5d-4e9b-b60e-fdfbab830c81)


<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.005543 / 0.011353 (-0.005810) | 0.004059 / 0.011008 (-0.006949) | 0.064678 / 0.038508 (0.026170) | 0.032615 / 0.023109 (0.009506) | 0.245883 / 0.275898 (-0.030015) | 0.273545 / 0.323480 (-0.049935) | 0.004268 / 0.007986 (-0.003718) | 0.003160 / 0.004328 (-0.001168) | 0.051982 / 0.004250 (0.047731) | 0.051186 / 0.037052 (0.014134) | 0.254009 / 0.258489 (-0.004480) | 0.289594 / 0.293841 (-0.004247) | 0.028459 / 0.128546 (-0.100087) | 0.011061 / 0.075646 (-0.064585) | 0.203571 / 0.419271 (-0.215700) | 0.038049 / 0.043533 (-0.005484) | 0.243700 / 0.255139 (-0.011439) | 0.264816 / 0.283200 (-0.018383) | 0.019556 / 0.141683 (-0.122127) | 1.114395 / 1.452155 (-0.337759) | 1.168915 / 1.492716 (-0.323802) |

### 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.098814 / 0.018006 (0.080808) | 0.308218 / 0.000490 (0.307728) | 0.000221 / 0.000200 (0.000022) | 0.000047 / 0.000054 (-0.000008) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.019660 / 0.037411 (-0.017752) | 0.070542 / 0.014526 (0.056017) | 0.078906 / 0.176557 (-0.097650) | 0.126658 / 0.737135 (-0.610477) | 0.080427 / 0.296338 (-0.215911) |

### 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.280686 / 0.215209 (0.065477) | 2.767480 / 2.077655 (0.689825) | 1.455325 / 1.504120 (-0.048795) | 1.336677 / 1.541195 (-0.204518) | 1.380359 / 1.468490 (-0.088131) | 0.576310 / 4.584777 (-4.008467) | 2.431829 / 3.745712 (-1.313883) | 2.815266 / 5.269862 (-2.454595) | 1.908962 / 4.565676 (-2.656714) | 0.065306 / 0.424275 (-0.358969) | 0.005229 / 0.007607 (-0.002378) | 0.336018 / 0.226044 (0.109973) | 3.349283 / 2.268929 (1.080355) | 1.814696 / 55.444624 (-53.629929) | 1.520969 / 6.876477 (-5.355508) | 1.735322 / 2.142072 (-0.406751) | 0.661513 / 4.805227 (-4.143714) | 0.121465 / 6.500664 (-6.379199) | 0.044505 / 0.075469 (-0.030964) |

### 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.989204 / 1.841788 (-0.852584) | 12.608414 / 8.074308 (4.534106) | 10.133358 / 10.191392 (-0.058034) | 0.133986 / 0.680424 (-0.546438) | 0.014332 / 0.534201 (-0.519869) | 0.293207 / 0.579283 (-0.286076) | 0.265657 / 0.434364 (-0.168707) | 0.325972 / 0.540337 (-0.214365) | 0.478103 / 1.386936 (-0.908833) |

</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.006070 / 0.011353 (-0.005283) | 0.004122 / 0.011008 (-0.006886) | 0.050572 / 0.038508 (0.012064) | 0.033732 / 0.023109 (0.010623) | 0.271282 / 0.275898 (-0.004616) | 0.296247 / 0.323480 (-0.027233) | 0.004400 / 0.007986 (-0.003585) | 0.002914 / 0.004328 (-0.001415) | 0.049332 / 0.004250 (0.045082) | 0.042213 / 0.037052 (0.005161) | 0.281230 / 0.258489 (0.022741) | 0.315514 / 0.293841 (0.021673) | 0.030864 / 0.128546 (-0.097682) | 0.011185 / 0.075646 (-0.064461) | 0.059227 / 0.419271 (-0.360044) | 0.034006 / 0.043533 (-0.009527) | 0.270059 / 0.255139 (0.014920) | 0.284014 / 0.283200 (0.000814) | 0.019502 / 0.141683 (-0.122181) | 1.143650 / 1.452155 (-0.308505) | 1.190968 / 1.492716 (-0.301749) |

### 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.100502 / 0.018006 (0.082496) | 0.307863 / 0.000490 (0.307373) | 0.000212 / 0.000200 (0.000012) | 0.000043 / 0.000054 (-0.000012) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.023442 / 0.037411 (-0.013969) | 0.080185 / 0.014526 (0.065659) | 0.089372 / 0.176557 (-0.087185) | 0.131030 / 0.737135 (-0.606105) | 0.091174 / 0.296338 (-0.205165) |

### 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.304187 / 0.215209 (0.088978) | 3.043055 / 2.077655 (0.965400) | 1.629578 / 1.504120 (0.125459) | 1.533762 / 1.541195 (-0.007432) | 1.546134 / 1.468490 (0.077643) | 0.577739 / 4.584777 (-4.007038) | 0.986310 / 3.745712 (-2.759402) | 2.791650 / 5.269862 (-2.478212) | 1.841190 / 4.565676 (-2.724487) | 0.064943 / 0.424275 (-0.359333) | 0.005251 / 0.007607 (-0.002356) | 0.355009 / 0.226044 (0.128965) | 3.560935 / 2.268929 (1.292007) | 1.991995 / 55.444624 (-53.452629) | 1.708796 / 6.876477 (-5.167681) | 1.917721 / 2.142072 (-0.224351) | 0.667667 / 4.805227 (-4.137561) | 0.119956 / 6.500664 (-6.380708) | 0.042069 / 0.075469 (-0.033400) |

### 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.006242 / 1.841788 (-0.835546) | 13.321644 / 8.074308 (5.247336) | 10.712409 / 10.191392 (0.521017) | 0.134036 / 0.680424 (-0.546388) | 0.017645 / 0.534201 (-0.516555) | 0.289077 / 0.579283 (-0.290206) | 0.131356 / 0.434364 (-0.303007) | 0.333062 / 0.540337 (-0.207275) | 0.425327 / 1.386936 (-0.961609) |

</details>
</details>

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


Indeed, the merge commit is: https://github.com/huggingface/datasets/commit/5bbbf1b19766e31a6905f3e82bf3aa3f9f84a982

The following commit is just empty: https://github.com/huggingface/datasets/commit/09ebf5190afbd017f3ca24ef444be2d933411eed