FORCE_REDOWNLOAD does not work
Describe the bug
With GenerateMode.FORCE_REDOWNLOAD, the documentation says
+------------------------------------+-----------+---------+
| | Downloads | Dataset |
+====================================+===========+=========+
| REUSE_DATASET_IF_EXISTS (default)| Reuse | Reuse |
+------------------------------------+-----------+---------+
| REUSE_CACHE_IF_EXISTS | Reuse | Fresh |
+------------------------------------+-----------+---------+
| FORCE_REDOWNLOAD | Fresh | Fresh |
+------------------------------------+-----------+---------+
However, the old dataset is loaded even when FORCE_REDOWNLOAD is chosen.
Steps to reproduce the bug
import pandas as pd
from datasets import load_dataset, GenerateMode
pd.DataFrame(range(5), columns=['numbers']).to_csv('/tmp/test.tsv.gz', index=False)
ee = load_dataset('csv', data_files=['/tmp/test.tsv.gz'], delimiter='\t', split='train', download_mode=GenerateMode.FORCE_REDOWNLOAD)
print(ee)
pd.DataFrame(range(10), columns=['numerals']).to_csv('/tmp/test.tsv.gz', index=False)
ee = load_dataset('csv', data_files=['/tmp/test.tsv.gz'], delimiter='\t', split='train', download_mode=GenerateMode.FORCE_REDOWNLOAD)
print(ee)
Expected results
Dataset({ features: ['numbers'], num_rows: 5 }) Dataset({ features: ['numerals'], num_rows: 10 })
Actual results
Dataset({ features: ['numbers'], num_rows: 5 }) Dataset({ features: ['numbers'], num_rows: 5 })
Environment info
datasetsversion: 1.8.0- Platform: Linux-4.14.181-108.257.amzn1.x86_64-x86_64-with-glibc2.10
- Python version: 3.7.10
- PyArrow version: 3.0.0
Hi ! Thanks for reporting. The error seems to happen only if you use compressed files.
The second dataset is prepared in another dataset cache directory than the first - which is normal, since the source file is different. However, it doesn't uncompress the new data file because it finds the old uncompressed data in the extraction cache directory.
If we fix the extraction cache mechanism to uncompress a local file if it changed then it should fix the issue. Currently the extraction cache mechanism only takes into account the path of the compressed file, which is an issue.
Facing the same issue, is there any way to overtake this issue until it will be fixed?
You can clear your extraction cache in the meantime (by default at ~/.cache/huggingface/datasets/downloads/extracted)
This looks fixed already. I ran the snippet from the first post on a few versions: on 1.15.1 the second load still comes back 5 rows / ['numbers'], and on 1.16.0 and on current main (3e2c1a6c3) it comes back 10 rows / ['numerals'], which is what the issue asks for.
#3275 is the one that did it, and it landed between those two releases. builder.py still passes force_extract=download_mode == DownloadMode.FORCE_REDOWNLOAD into the DownloadConfig, so the extraction cache gets rebuilt instead of reused. The stale behaviour is still there without that flag, it just isn't reachable through force_redownload any more.
Probably closeable.