coqa NonMatchingChecksumError
State: closed
Labels: description: Something isn't working
name: bug

```
>>> from datasets import load_dataset
>>> dataset = load_dataset("coqa")
Downloading: 3.82kB [00:00, 1.26MB/s]                                                                                                                                                                                                                       
Downloading: 1.79kB [00:00, 733kB/s]                                                                                                                                                                                                                        
Using custom data configuration default
Downloading and preparing dataset coqa/default (download: 55.40 MiB, generated: 18.35 MiB, post-processed: Unknown size, total: 73.75 MiB) to /Users/zhaofengw/.cache/huggingface/datasets/coqa/default/1.0.0/553ce70bfdcd15ff4b5f4abc4fc2f37137139cde1f58f4f60384a53a327716f0...
Downloading: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 222/222 [00:00<00:00, 1.38MB/s]
Downloading: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 222/222 [00:00<00:00, 1.32MB/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:01<00:00,  1.91it/s]
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 1117.44it/s]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/load.py", line 1632, in load_dataset
    builder_instance.download_and_prepare(
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/builder.py", line 607, in download_and_prepare
    self._download_and_prepare(
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/builder.py", line 679, in _download_and_prepare
    verify_checksums(
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/utils/info_utils.py", line 40, in verify_checksums
    raise NonMatchingChecksumError(error_msg + str(bad_urls))
datasets.utils.info_utils.NonMatchingChecksumError: Checksums didn't match for dataset source files:
['https://nlp.stanford.edu/data/coqa/coqa-train-v1.0.json', 'https://nlp.stanford.edu/data/coqa/coqa-dev-v1.0.json']
```

Comments:
Hi @ZhaofengWu, thanks for reporting.

Unfortunately, I'm not able to reproduce your bug:
```python
In [1]: from datasets import load_dataset

In [2]: ds = load_dataset("coqa")
Downloading: 3.82kB [00:00, 1.91MB/s]
Downloading: 1.79kB [00:00, 1.79MB/s]
Using custom data configuration default
Downloading and preparing dataset coqa/default (download: 55.40 MiB, generated: 18.35 MiB, post-processed: Unknown size, total: 73.75 MiB) to .cache\coqa\default\1.0.0\553ce70bfdcd15ff4b5f4abc4fc2f37137139cde1f58f4f60384a53a327716f0...
Downloading: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 49.0M/49.0M [00:06<00:00, 7.17MB/s]
Downloading: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 9.09M/9.09M [00:01<00:00, 6.08MB/s]
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:12<00:00,  6.48s/it]
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 333.26it/s]
Dataset coqa downloaded and prepared to .cache\coqa\default\1.0.0\553ce70bfdcd15ff4b5f4abc4fc2f37137139cde1f58f4f60384a53a327716f0. Subsequent calls will reuse this data.
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 285.49it/s]

In [3]: ds
Out[3]:
DatasetDict({
    train: Dataset({
        features: ['source', 'story', 'questions', 'answers'],
        num_rows: 7199
    })
    validation: Dataset({
        features: ['source', 'story', 'questions', 'answers'],
        num_rows: 500
    })
})
```

Could you please give more details about your development environment? You can run the command `datasets-cli env` and copy-and-paste its output:
```
- `datasets` version:
- Platform:
- Python version:
- PyArrow version:
```
It might be because you are using an old version of `datasets`. Could you please update it (`pip install -U datasets`) and confirm if the problem parsists? 

I'm getting the same error in two separate environments:
```
- `datasets` version: 1.15.1
- Platform: Linux-5.4.0-84-generic-x86_64-with-debian-bullseye-sid
- Python version: 3.7.11
- PyArrow version: 6.0.0
```

```
- `datasets` version: 1.15.1
- Platform: macOS-10.16-x86_64-i386-64bit
- Python version: 3.9.5
- PyArrow version: 6.0.0
```

I'm sorry, but don't get to reproduce the error in the Linux environment.

@mariosasko @lhoestq can you reproduce it?

I also can't reproduce the error on Windows/Linux (tested both the master and the `1.15.1` version). 

Maybe the file had issues during the download ? Could you try to delete your cache and try again ?
By default the downloads cache is at `~/.cache/huggingface/datasets/downloads`

Also can you check if you have a proxy that could prevent the download to succeed ? Are you able to download those files via your browser ?

I got the same error in a third environment (google cloud) as well. The internet for these three environments are all different so I don't think that's the reason.
```
- `datasets` version: 1.12.1
- Platform: Linux-5.11.0-1022-gcp-x86_64-with-glibc2.31
- Python version: 3.9.7
- PyArrow version: 6.0.0
```
I deleted the entire `~/.cache/huggingface/datasets` on my local mac, and got a different first time error.
```
Python 3.9.5 (default, May 18 2021, 12:31:01) 
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from datasets import load_dataset
>>> dataset = load_dataset("coqa")
Downloading: 3.82kB [00:00, 1.19MB/s]                                                                                                                                                                                                                       
Downloading: 1.79kB [00:00, 712kB/s]                                                                                                                                                                                                                        
Using custom data configuration default
Downloading and preparing dataset coqa/default (download: 55.40 MiB, generated: 18.35 MiB, post-processed: Unknown size, total: 73.75 MiB) to /Users/zhaofengw/.cache/huggingface/datasets/coqa/default/1.0.0/553ce70bfdcd15ff4b5f4abc4fc2f37137139cde1f58f4f60384a53a327716f0...
Downloading: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 222/222 [00:00<00:00, 1.36MB/s]
 50%|████████████████████████████████████████████████████████████████████████████████████████████████████████████▌                                                                                                            | 1/2 [00:00<00:00,  2.47it/s]Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/load.py", line 1632, in load_dataset
    builder_instance.download_and_prepare(
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/builder.py", line 607, in download_and_prepare
    self._download_and_prepare(
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/builder.py", line 675, in _download_and_prepare
    split_generators = self._split_generators(dl_manager, **split_generators_kwargs)
  File "/Users/zhaofengw/.cache/huggingface/modules/datasets_modules/datasets/coqa/553ce70bfdcd15ff4b5f4abc4fc2f37137139cde1f58f4f60384a53a327716f0/coqa.py", line 70, in _split_generators
    downloaded_files = dl_manager.download_and_extract(urls_to_download)
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/utils/download_manager.py", line 284, in download_and_extract
    return self.extract(self.download(url_or_urls))
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/utils/download_manager.py", line 196, in download
    downloaded_path_or_paths = map_nested(
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/utils/py_utils.py", line 216, in map_nested
    mapped = [
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/utils/py_utils.py", line 217, in <listcomp>
    _single_map_nested((function, obj, types, None, True))
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/utils/py_utils.py", line 152, in _single_map_nested
    return function(data_struct)
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/utils/download_manager.py", line 217, in _download
    return cached_path(url_or_filename, download_config=download_config)
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/utils/file_utils.py", line 295, in cached_path
    output_path = get_from_cache(
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/utils/file_utils.py", line 594, in get_from_cache
    raise ConnectionError("Couldn't reach {}".format(url))
ConnectionError: Couldn't reach https://nlp.stanford.edu/data/coqa/coqa-dev-v1.0.json
>>> dataset = load_dataset("coqa")
Using custom data configuration default
Downloading and preparing dataset coqa/default (download: 55.40 MiB, generated: 18.35 MiB, post-processed: Unknown size, total: 73.75 MiB) to /Users/zhaofengw/.cache/huggingface/datasets/coqa/default/1.0.0/553ce70bfdcd15ff4b5f4abc4fc2f37137139cde1f58f4f60384a53a327716f0...
Downloading: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 222/222 [00:00<00:00, 1.38MB/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00,  6.26it/s]
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 1087.45it/s]
 50%|████████████████████████████████████████████████████████████████████████████████████████████████████████████▌                                                                                                            | 1/2 [00:45<00:45, 45.60s/it]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/load.py", line 1632, in load_dataset
    builder_instance.download_and_prepare(
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/builder.py", line 607, in download_and_prepare
    self._download_and_prepare(
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/builder.py", line 679, in _download_and_prepare
    verify_checksums(
  File "/Users/zhaofengw/miniconda3/lib/python3.9/site-packages/datasets/utils/info_utils.py", line 40, in verify_checksums
    raise NonMatchingChecksumError(error_msg + str(bad_urls))
datasets.utils.info_utils.NonMatchingChecksumError: Checksums didn't match for dataset source files:
['https://nlp.stanford.edu/data/coqa/coqa-train-v1.0.json', 'https://nlp.stanford.edu/data/coqa/coqa-dev-v1.0.json']
```
I can access the URL using my browser, though I did notice a redirection -- could that have something to do with it?

Hi @ZhaofengWu, 

What about in Google Colab? Can you run this notebook without errors? 
https://colab.research.google.com/drive/1CCpiiHmtNlfO_4CZ3-fW-TSShr1M0rL4?usp=sharing

I can run your notebook fine, but if I create one myself, it has that error: https://colab.research.google.com/drive/107GIdhrauPO6ZiFDY7G9S74in4qqI2Kx?usp=sharing.

It's so funny -- it's like whenever you guys run it it's fine but whenever I run it it fails, whatever the environment is.

I guess it must be some connection issue: the data owner may be blocking requests coming from your country or IP range...

I mean, I don't think google colab sends the connection from my IP. Same applies to google cloud.

Hello, I am having the same error with @ZhaofengWu first with "social bias frames" dataset. As I found this report, I tried also "coqa" and it fails as well. 

I test this on Google Colab. 

```
- `datasets` version: 1.15.1
- Platform: Linux-5.4.104+-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.7.12
- PyArrow version: 3.0.0
```

Then another environment

```
- `datasets` version: 1.15.1
- Platform: macOS-12.0.1-arm64-arm-64bit
- Python version: 3.9.7
- PyArrow version: 6.0.1
```

I tried the notebook @albertvillanova provided earlier, and it fails...


Hi, still not able to reproduce the issue with `coqa`. If you still have this issue, could you please run these additional commands ?
```python
>>> import os
>>> from hashlib import md5
>>> from datasets.utils import DownloadManager, DownloadConfig
>>> path = DownloadManager(download_config=DownloadConfig(use_etag=False)).download("https://nlp.stanford.edu/data/coqa/coqa-dev-v1.0.json")  # it returns the cached file
>>> os.path.getsize(path)
9090845
>>> m = md5()
>>> m.update(open(path, "rb").read())
>>> m.hexdigest()
`95d427588e3733e4ebec55f6938dbba6`
>>> open(path).read(500)
'{\n  "version": "1.0",\n  "data": [\n    {\n      "source": "mctest",\n      "id": "3dr23u6we5exclen4th8uq9rb42tel",\n      "filename": "mc160.test.41",\n      "story": "Once upon a time, in a barn near a farm house, there lived a little white kitten named Cotton. Cotton lived high up in a nice warm place above the barn where all of the farmer\'s horses slept. But Cotton wasn\'t alone in her little home above the barn, oh no. She shared her hay bed with her mommy and 5 other sisters. All of her sisters w'
```

This way we can know whether you downloaded a corrupted file or an error file that could cause the `NonMatchingChecksumError` error to happen

```
>>> import os
>>> from hashlib import md5
>>> from datasets.utils import DownloadManager, DownloadConfig
>>> path = DownloadManager(download_config=DownloadConfig(use_etag=False)).download("https://nlp.stanford.edu/data/coqa/coqa-dev-v1.0.json")  # it returns the cached file
>>> os.path.getsize(path)
222
>>> m = md5()
>>> m.update(open(path, "rb").read())
>>> m.hexdigest()
'1195812a37c01a4481a4748c85d0c6a9'
>>> open(path).read(500)
'<html>\n<head><title>503 Service Temporarily Unavailable</title></head>\n<body bgcolor="white">\n<center><h1>503 Service Temporarily Unavailable</h1></center>\n<hr><center>nginx/1.10.3 (Ubuntu)</center>\n</body>\n</html>\n'
```
Looks like there was a server-side error when downloading the dataset? But I don't believe this is a transient error given (a) deleting the cache and re-downloading gives the same error; (b) it happens on multiple platforms with different network configurations; (c) other people are getting this error too, see above. So I'm not sure why it works for some people but not others.

`wget https://nlp.stanford.edu/data/coqa/coqa-dev-v1.0.json` does work. So I suspect there might be some problem in `datasets`' networking code? Can you give me some snippet that simulates how `datasets` requests the resource which I can run on my end?

There is a redirection -- I don't know if that's the cause.

Ok This is an issue with the server that hosts the data at `https://nlp.stanford.edu/nlp/data` that randomly returns 503 (by trying several times it also happens on my side), hopefully it can be fixed soon. I'll try to reach the people in charge of hosting the data

Thanks. Also it might help to display a more informative error message?

You're right. I just opened a PR that would show this error if it happens again:
```python
ConnectionError: Couldn't reach https://nlp.stanford.edu/data/coqa/coqa-dev-v1.0.json (error 503)
```