Fix streaming: catch Timeout error
{'login': 'borisdayma', 'id': 715491, 'node_id': 'MDQ6VXNlcjcxNTQ5MQ==', 'avatar_url': 'https://avatars.githubusercontent.com/u/715491?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/borisdayma', 'html_url': 'https://github.com/borisdayma', 'followers_url': 'https://api.github.com/users/borisdayma/followers', 'following_url': 'https://api.github.com/users/borisdayma/following{/other_user}', 'gists_url': 'https://api.github.com/users/borisdayma/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/borisdayma/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/borisdayma/subscriptions', 'organizations_url': 'https://api.github.com/users/borisdayma/orgs', 'repos_url': 'https://api.github.com/users/borisdayma/repos', 'events_url': 'https://api.github.com/users/borisdayma/events{/privacy}', 'received_events_url': 'https://api.github.com/users/borisdayma/received_events', 'type': 'User', 'site_admin': False}
[]
[]
["I'm running a large test.\r\nLet's see if I get any error within a few days."
 'This time it stopped after 8h but correctly raised `ConnectionError: Server Disconnected`.\r\n\r\nTraceback:\r\n```\r\nTraceback (most recent call last):                                                                                                                                                                               \r\n  File "/home/koush/dalle-mini/dev/seq2seq/run_seq2seq_flax.py", line 1027, in <module>                                                                                                                          \r\n    main()                                                                                                                                                                                                       \r\n  File "/home/koush/dalle-mini/dev/seq2seq/run_seq2seq_flax.py", line 991, in main                                                                                                                               \r\n    for batch in tqdm(                                                                                                                                                                                           \r\n  File "/home/koush/.pyenv/versions/dev/lib/python3.9/site-packages/tqdm/std.py", line 1180, in __iter__                                                                                                         \r\n    for obj in iterable:                                                                                                                                                                                         \r\n  File "/home/koush/dalle-mini/dev/seq2seq/run_seq2seq_flax.py", line 376, in data_loader_streaming\r\n    for item in dataset:\r\n  File "/home/koush/datasets/src/datasets/iterable_dataset.py", line 341, in __iter__\r\n    for key, example in self._iter():\r\n  File "/home/koush/datasets/src/datasets/iterable_dataset.py", line 338, in _iter\r\n    yield from ex_iterable\r\n  File "/home/koush/datasets/src/datasets/iterable_dataset.py", line 179, in __iter__\r\n    key_examples_list = [(key, example)] + [\r\n  File "/home/koush/datasets/src/datasets/iterable_dataset.py", line 179, in <listcomp>\r\n    key_examples_list = [(key, example)] + [\r\n  File "/home/koush/datasets/src/datasets/iterable_dataset.py", line 176, in __iter__\r\n    for key, example in iterator:\r\n  File "/home/koush/datasets/src/datasets/iterable_dataset.py", line 225, in __iter__\r\n    for x in self.ex_iterable:\r\n  File "/home/koush/datasets/src/datasets/iterable_dataset.py", line 99, in __iter__\r\n    for key, example in self.generate_examples_fn(**kwargs_with_shuffled_shards):\r\n  File "/home/koush/datasets/src/datasets/iterable_dataset.py", line 287, in wrapper\r\n    for key, table in generate_tables_fn(**kwargs):\r\n  File "/home/koush/datasets/src/datasets/packaged_modules/json/json.py", line 107, in _generate_tables\r\n    batch = f.read(self.config.chunksize)\r\n  File "/home/koush/datasets/src/datasets/utils/streaming_download_manager.py", line 136, in read_with_retries\r\n    raise ConnectionError("Server Disconnected")\r\nConnectionError: Server Disconnected\r\n```\r\n\r\nRight before this error, the warnings were correctly raised:\r\n\r\n```\r\n10/10/2021 06:02:26 - WARNING - datasets.utils.streaming_download_manager - Got disconnected from remote data host. Retrying in 1sec [1/3]\r\n10/10/2021 06:02:27 - WARNING - datasets.utils.streaming_download_manager - Got disconnected from remote data host. Retrying in 1sec [2/3]                                                                       \r\n10/10/2021 06:02:28 - WARNING - datasets.utils.streaming_download_manager - Got disconnected from remote data host. Retrying in 1sec [3/3\r\n```\r\n\r\nI\'m going to see what happens if I change the max retries to 20 and the interval to 5.'
 'Also maybe we can raise the Server Disconnected error with more info about what kind of error caused it (client error, time out, etc.)'
 "I have 2 runs:\r\n* [run 1](https://wandb.ai/dalle-mini/dalle-mini/runs/1nj161cl?workspace=user-borisd13) with [this data](https://huggingface.co/datasets/dalle-mini/encoded) that I will remove soon because I now use the 2nd one\r\n* [run 2](https://wandb.ai/dalle-mini/dalle-mini/runs/he9rrc3q?workspace=user-borisd13) with [this data](https://huggingface.co/datasets/dalle-mini/encoded-vqgan_imagenet_f16_16384)\r\n* `load_dataset(dataset_repo, data_files={'train':'data/train/*.jsonl', 'validation':'data/valid/*.jsonl'}, streaming=True)`\r\n\r\nThey have now been running by a bit more than a day for one run and 15h for the other.\r\n\r\nThe error logs are not shown in wandb because the script use `pylogging` (not sure why, I should change it) but basically so far with the new settings I had one timeout in each with successful reconnect afterwards.\r\n\r\nSo I think it's a good idea to have:\r\n* `STREAMING_READ_RETRY_INTERVAL = 5` since before my runs would get 3 errors in a row (with the default 1 second pause)\r\n* `STREAMING_READ_MAX_RETRIES` should also be increased. Since this type of error does not happen a lot, I\xa0would still have a large number (at least 10) because a stopped training run may be a big issue if checkpointing/restart is not well implemented which is not always trivial"
 'I agree ! Feel free to open a PR to increase both values']
{'url': 'https://api.github.com/repos/huggingface/datasets/pulls/3050', 'html_url': 'https://github.com/huggingface/datasets/pull/3050', 'diff_url': 'https://github.com/huggingface/datasets/pull/3050.diff', 'patch_url': 'https://github.com/huggingface/datasets/pull/3050.patch', 'merged_at': datetime.datetime(2021, 10, 11, 9, 35, 38)}
Catches Timeout error during streaming.

fix #3049 
{'url': 'https://api.github.com/repos/huggingface/datasets/issues/3050/reactions', 'total_count': 0, '+1': 0, '-1': 0, 'laugh': 0, 'hooray': 0, 'confused': 0, 'heart': 0, 'rocket': 0, 'eyes': 0}