"counter" dataset raises an error in normal mode, but not in streaming mode
{'login': 'severo', 'id': 1676121, 'node_id': 'MDQ6VXNlcjE2NzYxMjE=', 'avatar_url': 'https://avatars.githubusercontent.com/u/1676121?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/severo', 'html_url': 'https://github.com/severo', 'followers_url': 'https://api.github.com/users/severo/followers', 'following_url': 'https://api.github.com/users/severo/following{/other_user}', 'gists_url': 'https://api.github.com/users/severo/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/severo/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/severo/subscriptions', 'organizations_url': 'https://api.github.com/users/severo/orgs', 'repos_url': 'https://api.github.com/users/severo/repos', 'events_url': 'https://api.github.com/users/severo/events{/privacy}', 'received_events_url': 'https://api.github.com/users/severo/received_events', 'type': 'User', 'site_admin': False}
[{'id': 1935892857, 'node_id': 'MDU6TGFiZWwxOTM1ODkyODU3', 'url': 'https://api.github.com/repos/huggingface/datasets/labels/bug', 'name': 'bug', 'color': 'd73a4a', 'default': True, 'description': "Something isn't working"}]
{'login': 'lhoestq', 'id': 42851186, 'node_id': 'MDQ6VXNlcjQyODUxMTg2', 'avatar_url': 'https://avatars.githubusercontent.com/u/42851186?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/lhoestq', 'html_url': 'https://github.com/lhoestq', 'followers_url': 'https://api.github.com/users/lhoestq/followers', 'following_url': 'https://api.github.com/users/lhoestq/following{/other_user}', 'gists_url': 'https://api.github.com/users/lhoestq/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/lhoestq/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/lhoestq/subscriptions', 'organizations_url': 'https://api.github.com/users/lhoestq/orgs', 'repos_url': 'https://api.github.com/users/lhoestq/repos', 'events_url': 'https://api.github.com/users/lhoestq/events{/privacy}', 'received_events_url': 'https://api.github.com/users/lhoestq/received_events', 'type': 'User', 'site_admin': False}
[{'login': 'lhoestq', 'id': 42851186, 'node_id': 'MDQ6VXNlcjQyODUxMTg2', 'avatar_url': 'https://avatars.githubusercontent.com/u/42851186?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/lhoestq', 'html_url': 'https://github.com/lhoestq', 'followers_url': 'https://api.github.com/users/lhoestq/followers', 'following_url': 'https://api.github.com/users/lhoestq/following{/other_user}', 'gists_url': 'https://api.github.com/users/lhoestq/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/lhoestq/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/lhoestq/subscriptions', 'organizations_url': 'https://api.github.com/users/lhoestq/orgs', 'repos_url': 'https://api.github.com/users/lhoestq/repos', 'events_url': 'https://api.github.com/users/lhoestq/events{/privacy}', 'received_events_url': 'https://api.github.com/users/lhoestq/received_events', 'type': 'User', 'site_admin': False}]
['Hi @severo, thanks for reporting.\r\n\r\nJust note that currently not all canonical datasets support streaming mode: this is one case!\r\n\r\nAll datasets that use `pathlib` joins (using `/`) instead of `os.path.join` (as in this dataset) do not support streaming mode yet.'
 "OK. Do you think it's possible to detect this, and raise an exception (maybe `NotImplementedError`, or a specific `StreamingError`)?"
 'We should definitely support datasets using `pathlib` in streaming mode...\r\n\r\nFor non-supported datasets in streaming mode, we have already a request of raising an error/warning: see #2654.'
 'Hi @severo, please note that "counter" dataset will be streamable (at least until it arrives at the missing file, error already in normal mode) once these PRs are merged:\r\n- #2874\r\n- #2876\r\n- #2880\r\n\r\nI have tested it. 😉 '
 'Now (on master), we get:\r\n\r\n```\r\nimport datasets as ds\r\nds.load_dataset(\'counter\', split="train", streaming=False)\r\n```\r\n\r\n```\r\nUsing custom data configuration default\r\nDownloading and preparing dataset counter/default (download: 1.29 MiB, generated: 2.48 MiB, post-processed: Unknown size, total: 3.77 MiB) to /home/slesage/.cache/huggingface/datasets/counter/default/1.0.0/9f84962fa0f35bec5a34fe0bdff8681838d497008c457f7856c48654476ec0e9...\r\nTraceback (most recent call last):\r\n  File "/home/slesage/hf/datasets/src/datasets/builder.py", line 726, in _download_and_prepare\r\n    self._prepare_split(split_generator, **prepare_split_kwargs)\r\n  File "/home/slesage/hf/datasets/src/datasets/builder.py", line 1124, in _prepare_split\r\n    for key, record in utils.tqdm(\r\n  File "/home/slesage/hf/datasets/.venv/lib/python3.8/site-packages/tqdm/std.py", line 1185, in __iter__\r\n    for obj in iterable:\r\n  File "/home/slesage/.cache/huggingface/modules/datasets_modules/datasets/counter/9f84962fa0f35bec5a34fe0bdff8681838d497008c457f7856c48654476ec0e9/counter.py", line 161, in _generate_examples\r\n    with derived_file.open(encoding="utf-8") as f:\r\n  File "/home/slesage/.pyenv/versions/3.8.11/lib/python3.8/pathlib.py", line 1222, in open\r\n    return io.open(self, mode, buffering, encoding, errors, newline,\r\n  File "/home/slesage/.pyenv/versions/3.8.11/lib/python3.8/pathlib.py", line 1078, in _opener\r\n    return self._accessor.open(self, flags, mode)\r\nFileNotFoundError: [Errno 2] No such file or directory: \'/home/slesage/.cache/huggingface/datasets/downloads/extracted/b57aa6db5601a738e57b95c1fd8cced54ff28fc540efcdaf0f6c4f1bb5dfe211/COUNTER/0032p.xml\'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File "<stdin>", line 1, in <module>\r\n  File "/home/slesage/hf/datasets/src/datasets/load.py", line 1112, in load_dataset\r\n    builder_instance.download_and_prepare(\r\n  File "/home/slesage/hf/datasets/src/datasets/builder.py", line 636, in download_and_prepare\r\n    self._download_and_prepare(\r\n  File "/home/slesage/hf/datasets/src/datasets/builder.py", line 728, in _download_and_prepare\r\n    raise OSError(\r\nOSError: Cannot find data file.\r\nOriginal error:\r\n[Errno 2] No such file or directory: \'/home/slesage/.cache/huggingface/datasets/downloads/extracted/b57aa6db5601a738e57b95c1fd8cced54ff28fc540efcdaf0f6c4f1bb5dfe211/COUNTER/0032p.xml\'\r\n```\r\n\r\nThe error is now the same with or without streaming. I close the issue, thanks @albertvillanova and @lhoestq!\r\n'
 'Note that we might want to open an issue to fix the "counter" dataset by itself, but I let it up to you.'
 'Fixed here: https://github.com/huggingface/datasets/pull/2894. Thanks @albertvillanova '
 'On master, I get:\r\n\r\n```python\r\n>>> import datasets as ds\r\n>>> iterable_dataset = ds.load_dataset(\'counter\', split="train", streaming=True)\r\n>>> rows = list(iterable_dataset.take(100))\r\nTraceback (most recent call last):\r\n  File "<stdin>", line 1, in <module>\r\n  File "/home/slesage/hf/datasets/src/datasets/iterable_dataset.py", line 341, in __iter__\r\n    for key, example in self._iter():\r\n  File "/home/slesage/hf/datasets/src/datasets/iterable_dataset.py", line 338, in _iter\r\n    yield from ex_iterable\r\n  File "/home/slesage/hf/datasets/src/datasets/iterable_dataset.py", line 273, in __iter__\r\n    yield from islice(self.ex_iterable, self.n)\r\n  File "/home/slesage/hf/datasets/src/datasets/iterable_dataset.py", line 78, in __iter__\r\n    for key, example in self.generate_examples_fn(**self.kwargs):\r\n  File "/home/slesage/.cache/huggingface/modules/datasets_modules/datasets/counter/b9e4378dbd3f5ce235d2302e48168c00196e67bbcd13cc7e1f6e69ef82c0cf2a/counter.py", line 153, in _generate_examples\r\n    files = sorted(base_path.glob(r"[0-9][0-9][0-9][0-9].xml"))\r\nTypeError: xpathglob() missing 1 required positional argument: \'pattern\'\r\n```'
 'Associated to the above exception, if I create a test and run it with pytest, I get an awful traceback.\r\n\r\n- create a file `test_counter.py`\r\n\r\n```python\r\nimport pytest\r\nfrom datasets import load_dataset, IterableDataset\r\nfrom typing import Any, cast\r\n\r\n\r\ndef test_counter() -> Any:\r\n    iterable_dataset = cast(IterableDataset, load_dataset("counter", split="train", streaming=True))\r\n    with pytest.raises(TypeError):\r\n        list(iterable_dataset.take(100))\r\n```\r\n\r\n- run the test with pytest\r\n\r\n```bash\r\n$ python -m pytest -x test_counter.py\r\n============================================================================================================================= test session starts ==============================================================================================================================\r\nplatform linux -- Python 3.9.6, pytest-6.2.5, py-1.10.0, pluggy-1.0.0\r\nrootdir: /home/slesage/hf/datasets-preview-backend, configfile: pyproject.toml\r\nplugins: anyio-3.3.2, cov-2.12.1\r\ncollected 1 item\r\n\r\ntests/test_counter.py .                                                                                                                                                                                                                                                  [100%]Traceback (most recent call last):\r\n  File "/home/slesage/.pyenv/versions/3.9.6/lib/python3.9/runpy.py", line 197, in _run_module_as_main\r\n    return _run_code(code, main_globals, None,\r\n  File "/home/slesage/.pyenv/versions/3.9.6/lib/python3.9/runpy.py", line 87, in _run_code\r\n    exec(code, run_globals)\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/pytest/__main__.py", line 5, in <module>\r\n    raise SystemExit(pytest.console_main())\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/_pytest/config/__init__.py", line 185, in console_main\r\n    code = main()\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/_pytest/config/__init__.py", line 162, in main\r\n    ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/pluggy/_hooks.py", line 265, in __call__\r\n    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/pluggy/_manager.py", line 80, in _hookexec\r\n    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/pluggy/_callers.py", line 60, in _multicall\r\n    return outcome.get_result()\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/pluggy/_result.py", line 60, in get_result\r\n    raise ex[1].with_traceback(ex[2])\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/pluggy/_callers.py", line 39, in _multicall\r\n    res = hook_impl.function(*args)\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/_pytest/main.py", line 316, in pytest_cmdline_main\r\n    return wrap_session(config, _main)\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/_pytest/main.py", line 304, in wrap_session\r\n    config.hook.pytest_sessionfinish(\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/pluggy/_hooks.py", line 265, in __call__\r\n    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/pluggy/_manager.py", line 80, in _hookexec\r\n    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/pluggy/_callers.py", line 55, in _multicall\r\n    gen.send(outcome)\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/_pytest/terminal.py", line 803, in pytest_sessionfinish\r\n    outcome.get_result()\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/pluggy/_result.py", line 60, in get_result\r\n    raise ex[1].with_traceback(ex[2])\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/pluggy/_callers.py", line 39, in _multicall\r\n    res = hook_impl.function(*args)\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/_pytest/cacheprovider.py", line 428, in pytest_sessionfinish\r\n    config.cache.set("cache/nodeids", sorted(self.cached_nodeids))\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/_pytest/cacheprovider.py", line 188, in set\r\n    f = path.open("w")\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/datasets/utils/streaming_download_manager.py", line 199, in xpathopen\r\n    return xopen(_as_posix(path), *args, **kwargs)\r\n  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.9/site-packages/datasets/utils/streaming_download_manager.py", line 117, in _as_posix\r\n    path_as_posix = path.as_posix()\r\nAttributeError: \'str\' object has no attribute \'as_posix\'\r\n```\r\n'
 "I opened a PR to fix these issues.\r\nAlso in your test you expect a TypeError but I don't know why. On my side it works fine without raising a TypeError"
 "I had the issue (TypeError raised) on my branch, but it's fixed now. Thanks"]
## Describe the bug

`counter` dataset raises an error on `load_dataset()`, but simply returns an empty iterator in streaming mode.

## Steps to reproduce the bug

```python
>>> import datasets as ds
>>> a = ds.load_dataset('counter', split="train", streaming=False)
Using custom data configuration default
Downloading and preparing dataset counter/default (download: 1.29 MiB, generated: 2.48 MiB, post-processed: Unknown size, total: 3.77 MiB) to /home/slesage/.cache/huggingface/datasets/counter/default/1.0.0/9f84962fa0f35bec5a34fe0bdff8681838d497008c457f7856c48654476ec0e9...
Traceback (most recent call last):
  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.8/site-packages/datasets/builder.py", line 726, in _download_and_prepare
    self._prepare_split(split_generator, **prepare_split_kwargs)
  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.8/site-packages/datasets/builder.py", line 1124, in _prepare_split
    for key, record in utils.tqdm(
  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.8/site-packages/tqdm/std.py", line 1185, in __iter__
    for obj in iterable:
  File "/home/slesage/.cache/huggingface/modules/datasets_modules/datasets/counter/9f84962fa0f35bec5a34fe0bdff8681838d497008c457f7856c48654476ec0e9/counter.py", line 161, in _generate_examples
    with derived_file.open(encoding="utf-8") as f:
  File "/home/slesage/.pyenv/versions/3.8.11/lib/python3.8/pathlib.py", line 1222, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/home/slesage/.pyenv/versions/3.8.11/lib/python3.8/pathlib.py", line 1078, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/slesage/.cache/huggingface/datasets/downloads/extracted/b57aa6db5601a738e57b95c1fd8cced54ff28fc540efcdaf0f6c4f1bb5dfe211/COUNTER/0032p.xml'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.8/site-packages/datasets/load.py", line 1112, in load_dataset
    builder_instance.download_and_prepare(
  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.8/site-packages/datasets/builder.py", line 636, in download_and_prepare
    self._download_and_prepare(
  File "/home/slesage/hf/datasets-preview-backend/.venv/lib/python3.8/site-packages/datasets/builder.py", line 728, in _download_and_prepare
    raise OSError(
OSError: Cannot find data file.
Original error:
[Errno 2] No such file or directory: '/home/slesage/.cache/huggingface/datasets/downloads/extracted/b57aa6db5601a738e57b95c1fd8cced54ff28fc540efcdaf0f6c4f1bb5dfe211/COUNTER/0032p.xml'
```

```python
>>> import datasets as ds
>>> b = ds.load_dataset('counter', split="train", streaming=True)
Using custom data configuration default
>>> list(b)
[]
```

## Expected results

An exception should be raised in streaming mode

## Actual results

No exception is raised in streaming mode: there is no way to tell if something has broken or if the dataset is simply empty.

## Environment info

- `datasets` version: 1.11.1.dev0
- Platform: Linux-5.11.0-1016-aws-x86_64-with-glibc2.29
- Python version: 3.8.11
- PyArrow version: 4.0.1

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