GitHub issue #5457: prebuilt dataset relies on `downloads/extracted`
State: open | Created: 2023-01-24T02:09:32Z

### Describe the bug

I pre-built the dataset:
```
python -c 'import sys; from datasets import load_dataset; ds=load_dataset(sys.argv[1])' HuggingFaceM4/general-pmd-synthetic-testing
```
and it can be used just fine.

now I wipe out `downloads/extracted` and it no longer works. 
```
rm -r ~/.cache/huggingface/datasets/downloads
```
That is I can still load it:
```
python -c 'import sys; from datasets import load_dataset; ds=load_dataset(sys.argv[1])' HuggingFaceM4/general-pmd-synthetic-testing
No config specified, defaulting to: general-pmd-synthetic-testing/100.unique
Found cached dataset general-pmd-synthetic-testing (/home/stas/.cache/huggingface/datasets/HuggingFaceM4___general-pmd-synthetic-testing/100.unique/1.1.1/86bc445e3e48cb5ef79de109eb4e54ff85b318cd55c3835c4ee8f86eae33d9d2)
```
but if I try to use it:
```
E               stderr: Traceback (most recent call last):
E               stderr:   File "/mnt/nvme0/code/huggingface/m4-master-6/m4/training/main.py", line 116, in <module>
E               stderr:     train_loader, val_loader = get_dataloaders(
E               stderr:   File "/mnt/nvme0/code/huggingface/m4-master-6/m4/training/dataset.py", line 170, in get_dataloaders
E               stderr:     train_loader = get_dataloader_from_config(
E               stderr:   File "/mnt/nvme0/code/huggingface/m4-master-6/m4/training/dataset.py", line 443, in get_dataloader_from_config
E               stderr:     dataloader = get_dataloader(
E               stderr:   File "/mnt/nvme0/code/huggingface/m4-master-6/m4/training/dataset.py", line 264, in get_dataloader
E               stderr:     is_pmd = "meta" in hf_dataset[0] and "source" in hf_dataset[0]
E               stderr:   File "/mnt/nvme0/code/huggingface/datasets-master/src/datasets/arrow_dataset.py", line 2601, in __getitem__
E               stderr:     return self._getitem(
E               stderr:   File "/mnt/nvme0/code/huggingface/datasets-master/src/datasets/arrow_dataset.py", line 2586, in _getitem
E               stderr:     formatted_output = format_table(
E               stderr:   File "/mnt/nvme0/code/huggingface/datasets-master/src/datasets/formatting/formatting.py", line 634, in format_table
E               stderr:     return formatter(pa_table, query_type=query_type)
E               stderr:   File "/mnt/nvme0/code/huggingface/datasets-master/src/datasets/formatting/formatting.py", line 406, in __call__
E               stderr:     return self.format_row(pa_table)
E               stderr:   File "/mnt/nvme0/code/huggingface/datasets-master/src/datasets/formatting/formatting.py", line 442, in format_row
E               stderr:     row = self.python_features_decoder.decode_row(row)
E               stderr:   File "/mnt/nvme0/code/huggingface/datasets-master/src/datasets/formatting/formatting.py", line 225, in decode_row
E               stderr:     return self.features.decode_example(row) if self.features else row
E               stderr:   File "/mnt/nvme0/code/huggingface/datasets-master/src/datasets/features/features.py", line 1846, in decode_example
E               stderr:     return {
E               stderr:   File "/mnt/nvme0/code/huggingface/datasets-master/src/datasets/features/features.py", line 1847, in <dictcomp>
E               stderr:     column_name: decode_nested_example(feature, value, token_per_repo_id=token_per_repo_id)
E               stderr:   File "/mnt/nvme0/code/huggingface/datasets-master/src/datasets/features/features.py", line 1304, in decode_nested_example
E               stderr:     return decode_nested_example([schema.feature], obj)
E               stderr:   File "/mnt/nvme0/code/huggingface/datasets-master/src/datasets/features/features.py", line 1296, in decode_nested_example
E               stderr:     if decode_nested_example(sub_schema, first_elmt) != first_elmt:
E               stderr:   File "/mnt/nvme0/code/huggingface/datasets-master/src/datasets/features/features.py", line 1309, in decode_nested_example
E               stderr:     return schema.decode_example(obj, token_per_repo_id=token_per_repo_id)
E               stderr:   File "/mnt/nvme0/code/huggingface/datasets-master/src/datasets/features/image.py", line 144, in decode_example
E               stderr:     image = PIL.Image.open(path)
E               stderr:   File "/home/stas/anaconda3/envs/py38-pt113/lib/python3.8/site-packages/PIL/Image.py", line 3092, in open
E               stderr:     fp = builtins.open(filename, "rb")
E               stderr: FileNotFoundError: [Errno 2] No such file or directory: '/mnt/nvme0/code/data/cache/huggingface/datasets/downloads/extracted/134227b9b94c4eccf19b205bf3021d4492d0227b9be6c2ddb6bf517d8d55a8cb/data/101/images_01.jpg'
``` 

Only if I wipe out the cached dir and rebuild then it starts working as `download/extracted` is back again with extracted files.


```
rm -r ~/.cache/huggingface/datasets/HuggingFaceM4___general-pmd-synthetic-testing
python -c 'import sys; from datasets import load_dataset; ds=load_dataset(sys.argv[1])' HuggingFaceM4/general-pmd-synthetic-testing
```

I think there are 2 issues here:

1. why does it still rely on extracted files after `arrow` files were printed - did I do something incorrectly when creating this dataset?
2. why doesn't the dataset know that it has been gutted and loads just fine? If it has a dependency on `download/extracted` then `load_dataset` should check if it's there and fail or force rebuilding. I am sure this could be a very expensive operation, so probably really solving #1 will not require this check. and this second item is probably an overkill. Other than perhaps if it had an optional `check_consistency` flag to do that.

### Environment info

datasets@main