iter_archive on zipfiles with better compression type check
CONTRIBUTOR
Hello @lhoestq, thank you for your answer.

I don't use pytest a lot so I think I might need some help on it :) but I tried some tests for `streaming_download_manager.py` only. I don't know how to test `download_manager.py` since we need to use local files.

# Comments : 
* In **download_manager.py** I removed some unnecessary imports after the simplification of `_get_extraction_protocol_local`.
* In **streaming_download_manager** I moved the raised Error as suggested.
 
### I also started some tests on `StreamingDownloadManager()` :
* Used an existing zipfile url and added a new one that has a folder and many files : 
```python
TEST_GG_DRIVE_ZIPPED_URL = "https://drive.google.com/uc?export=download&id=1k92sUfpHxKq8PXWRr7Y5aNHXwOCNUmqh"
TEST_GG_DRIVE2_ZIPPED_URL = "https://drive.google.com/uc?export=download&id=1X4jyUBBbShyCRfD-vCO1ZvfqFXP3NEeU"
``` 
* **For now is being tested :**
     * Return type of the function  : should be tuple
     * Files names
     * Files content
 * Added an `xfail` test for the gzip file, because I get a `zipfile.BadZipFile exception`.


 * And lastly, changed the test for `_get_extraction_protocol_throws` since it was moved to `_extract` : 
 ```diff
@pytest.mark.xfail(raises=NotImplementedError)
def test_streaming_dl_manager_get_extraction_protocol_throws(urlpath):
-    _get_extraction_protocol(urlpath)

@pytest.mark.xfail(raises=NotImplementedError)
def test_streaming_dl_manager_get_extraction_protocol_throws(urlpath):
+    StreamingDownloadManager()._extract(urlpath)
```



2021-12-08T01:15:47Z
https://github.com/huggingface/datasets/pull/3379#issuecomment-988402435
https://api.github.com/repos/huggingface/datasets/issues/3379
IC_kwDODunzps466dMD
https://api.github.com/repos/huggingface/datasets/issues/comments/988402435/reactions
2021-12-08T01:15:47Z
https://api.github.com/repos/huggingface/datasets/issues/comments/988402435
https://avatars.githubusercontent.com/u/56029953?v=4
https://api.github.com/users/Mehdi2402/events{/privacy}
https://api.github.com/users/Mehdi2402/followers
https://api.github.com/users/Mehdi2402/following{/other_user}
https://api.github.com/users/Mehdi2402/gists{/gist_id}
https://github.com/Mehdi2402
Mehdi2402
MDQ6VXNlcjU2MDI5OTUz
https://api.github.com/users/Mehdi2402/orgs
https://api.github.com/users/Mehdi2402/received_events
https://api.github.com/users/Mehdi2402/repos
https://api.github.com/users/Mehdi2402/starred{/owner}{/repo}
https://api.github.com/users/Mehdi2402/subscriptions
User
https://api.github.com/users/Mehdi2402
public
CONTRIBUTOR
Hello,
In this Commit was taken into account all the comment escept the `test_download _manager.py`.
I will work on that for the next commit.

Sorry again for being inactive lately in this PR.


2022-02-03T23:08:35Z
https://github.com/huggingface/datasets/pull/3379#issuecomment-1029484667
https://api.github.com/repos/huggingface/datasets/issues/3379
IC_kwDODunzps49XLB7
https://api.github.com/repos/huggingface/datasets/issues/comments/1029484667/reactions
2022-02-03T23:08:35Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1029484667
https://avatars.githubusercontent.com/u/56029953?v=4
https://api.github.com/users/Mehdi2402/events{/privacy}
https://api.github.com/users/Mehdi2402/followers
https://api.github.com/users/Mehdi2402/following{/other_user}
https://api.github.com/users/Mehdi2402/gists{/gist_id}
https://github.com/Mehdi2402
Mehdi2402
MDQ6VXNlcjU2MDI5OTUz
https://api.github.com/users/Mehdi2402/orgs
https://api.github.com/users/Mehdi2402/received_events
https://api.github.com/users/Mehdi2402/repos
https://api.github.com/users/Mehdi2402/starred{/owner}{/repo}
https://api.github.com/users/Mehdi2402/subscriptions
User
https://api.github.com/users/Mehdi2402
public
MEMBER
thanks a lot ! This CI seems to have import errors now though ?
2022-02-04T15:16:56Z
https://github.com/huggingface/datasets/pull/3379#issuecomment-1030081144
https://api.github.com/repos/huggingface/datasets/issues/3379
IC_kwDODunzps49Zcp4
https://api.github.com/repos/huggingface/datasets/issues/comments/1030081144/reactions
2022-02-04T15:16:56Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1030081144
https://avatars.githubusercontent.com/u/42851186?v=4
https://api.github.com/users/lhoestq/events{/privacy}
https://api.github.com/users/lhoestq/followers
https://api.github.com/users/lhoestq/following{/other_user}
https://api.github.com/users/lhoestq/gists{/gist_id}
https://github.com/lhoestq
lhoestq
MDQ6VXNlcjQyODUxMTg2
https://api.github.com/users/lhoestq/orgs
https://api.github.com/users/lhoestq/received_events
https://api.github.com/users/lhoestq/repos
https://api.github.com/users/lhoestq/starred{/owner}{/repo}
https://api.github.com/users/lhoestq/subscriptions
User
https://api.github.com/users/lhoestq
public
CONTRIBUTOR
> thanks a lot ! This CI seems to have import errors now though ?

Yes sorry about that, it's due to a cyclic import I didn't pay attention to.

Will fix that in the next Commit along with adding the tests to download_manager.


2022-02-08T15:16:53Z
https://github.com/huggingface/datasets/pull/3379#issuecomment-1032721249
https://api.github.com/repos/huggingface/datasets/issues/3379
IC_kwDODunzps49jhNh
https://api.github.com/repos/huggingface/datasets/issues/comments/1032721249/reactions
2022-02-08T15:16:53Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1032721249
https://avatars.githubusercontent.com/u/56029953?v=4
https://api.github.com/users/Mehdi2402/events{/privacy}
https://api.github.com/users/Mehdi2402/followers
https://api.github.com/users/Mehdi2402/following{/other_user}
https://api.github.com/users/Mehdi2402/gists{/gist_id}
https://github.com/Mehdi2402
Mehdi2402
MDQ6VXNlcjU2MDI5OTUz
https://api.github.com/users/Mehdi2402/orgs
https://api.github.com/users/Mehdi2402/received_events
https://api.github.com/users/Mehdi2402/repos
https://api.github.com/users/Mehdi2402/starred{/owner}{/repo}
https://api.github.com/users/Mehdi2402/subscriptions
User
https://api.github.com/users/Mehdi2402
public
MEMBER
Hello @Mehdi2402, are you still interested in working on this further? 
2022-09-21T14:40:31Z
https://github.com/huggingface/datasets/pull/3379#issuecomment-1253810597
https://api.github.com/repos/huggingface/datasets/issues/3379
IC_kwDODunzps5Ku6Gl
https://api.github.com/repos/huggingface/datasets/issues/comments/1253810597/reactions
2022-09-21T14:40:31Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1253810597
https://avatars.githubusercontent.com/u/8515462?v=4
https://api.github.com/users/albertvillanova/events{/privacy}
https://api.github.com/users/albertvillanova/followers
https://api.github.com/users/albertvillanova/following{/other_user}
https://api.github.com/users/albertvillanova/gists{/gist_id}
https://github.com/albertvillanova
albertvillanova
MDQ6VXNlcjg1MTU0NjI=
https://api.github.com/users/albertvillanova/orgs
https://api.github.com/users/albertvillanova/received_events
https://api.github.com/users/albertvillanova/repos
https://api.github.com/users/albertvillanova/starred{/owner}{/repo}
https://api.github.com/users/albertvillanova/subscriptions
User
https://api.github.com/users/albertvillanova
public
CONTRIBUTOR
> Hello @Mehdi2402, are you still interested in working on this further?

Hello @albertvillanova, yes I would like to resume work on this.
2022-09-22T21:17:02Z
https://github.com/huggingface/datasets/pull/3379#issuecomment-1255556856
https://api.github.com/repos/huggingface/datasets/issues/3379
IC_kwDODunzps5K1kb4
https://api.github.com/repos/huggingface/datasets/issues/comments/1255556856/reactions
2022-09-22T21:17:02Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1255556856
https://avatars.githubusercontent.com/u/56029953?v=4
https://api.github.com/users/Mehdi2402/events{/privacy}
https://api.github.com/users/Mehdi2402/followers
https://api.github.com/users/Mehdi2402/following{/other_user}
https://api.github.com/users/Mehdi2402/gists{/gist_id}
https://github.com/Mehdi2402
Mehdi2402
MDQ6VXNlcjU2MDI5OTUz
https://api.github.com/users/Mehdi2402/orgs
https://api.github.com/users/Mehdi2402/received_events
https://api.github.com/users/Mehdi2402/repos
https://api.github.com/users/Mehdi2402/starred{/owner}{/repo}
https://api.github.com/users/Mehdi2402/subscriptions
User
https://api.github.com/users/Mehdi2402
public
MEMBER
Great, we would like to have this feature.

First, you should resolve the conflicts with the main branch, by merging main into your feature branch and then fixing the conflicts by hand. Let us know if you would need some help on this: we can resolve the conflicts for you, so that you can continue your contribution afterwards.
2022-09-23T06:44:49Z
https://github.com/huggingface/datasets/pull/3379#issuecomment-1255850746
https://api.github.com/repos/huggingface/datasets/issues/3379
IC_kwDODunzps5K2sL6
https://api.github.com/repos/huggingface/datasets/issues/comments/1255850746/reactions
2022-09-23T06:51:47Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1255850746
https://avatars.githubusercontent.com/u/8515462?v=4
https://api.github.com/users/albertvillanova/events{/privacy}
https://api.github.com/users/albertvillanova/followers
https://api.github.com/users/albertvillanova/following{/other_user}
https://api.github.com/users/albertvillanova/gists{/gist_id}
https://github.com/albertvillanova
albertvillanova
MDQ6VXNlcjg1MTU0NjI=
https://api.github.com/users/albertvillanova/orgs
https://api.github.com/users/albertvillanova/received_events
https://api.github.com/users/albertvillanova/repos
https://api.github.com/users/albertvillanova/starred{/owner}{/repo}
https://api.github.com/users/albertvillanova/subscriptions
User
https://api.github.com/users/albertvillanova
public
NONE
_The documentation is not available anymore as the PR was closed or merged._
2023-01-20T15:44:33Z
https://github.com/huggingface/datasets/pull/3379#issuecomment-1398579678
https://api.github.com/repos/huggingface/datasets/issues/3379
IC_kwDODunzps5TXKHe
https://api.github.com/repos/huggingface/datasets/issues/comments/1398579678/reactions
2023-01-24T12:55:53Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1398579678
https://avatars.githubusercontent.com/u/99929124?v=4
https://api.github.com/users/HuggingFaceDocBuilderDev/events{/privacy}
https://api.github.com/users/HuggingFaceDocBuilderDev/followers
https://api.github.com/users/HuggingFaceDocBuilderDev/following{/other_user}
https://api.github.com/users/HuggingFaceDocBuilderDev/gists{/gist_id}
https://github.com/HuggingFaceDocBuilderDev
HuggingFaceDocBuilderDev
U_kgDOBfTMJA
https://api.github.com/users/HuggingFaceDocBuilderDev/orgs
https://api.github.com/users/HuggingFaceDocBuilderDev/received_events
https://api.github.com/users/HuggingFaceDocBuilderDev/repos
https://api.github.com/users/HuggingFaceDocBuilderDev/starred{/owner}{/repo}
https://api.github.com/users/HuggingFaceDocBuilderDev/subscriptions
User
https://api.github.com/users/HuggingFaceDocBuilderDev
public
COLLABORATOR
I refactored the code to make this PR ready for the final review.
2023-01-20T16:19:58Z
https://github.com/huggingface/datasets/pull/3379#issuecomment-1398621836
https://api.github.com/repos/huggingface/datasets/issues/3379
IC_kwDODunzps5TXUaM
https://api.github.com/repos/huggingface/datasets/issues/comments/1398621836/reactions
2023-01-20T16:19:58Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1398621836
https://avatars.githubusercontent.com/u/47462742?v=4
https://api.github.com/users/mariosasko/events{/privacy}
https://api.github.com/users/mariosasko/followers
https://api.github.com/users/mariosasko/following{/other_user}
https://api.github.com/users/mariosasko/gists{/gist_id}
https://github.com/mariosasko
mariosasko
MDQ6VXNlcjQ3NDYyNzQy
https://api.github.com/users/mariosasko/orgs
https://api.github.com/users/mariosasko/received_events
https://api.github.com/users/mariosasko/repos
https://api.github.com/users/mariosasko/starred{/owner}{/repo}
https://api.github.com/users/mariosasko/subscriptions
User
https://api.github.com/users/mariosasko
public
NONE
<details>
<summary>Show benchmarks</summary>

PyArrow==6.0.0

<details>
<summary>Show updated benchmarks!</summary>

### Benchmark: benchmark_array_xd.json

| metric | read_batch_formatted_as_numpy after write_array2d | read_batch_formatted_as_numpy after write_flattened_sequence | read_batch_formatted_as_numpy after write_nested_sequence | read_batch_unformated after write_array2d | read_batch_unformated after write_flattened_sequence | read_batch_unformated after write_nested_sequence | read_col_formatted_as_numpy after write_array2d | read_col_formatted_as_numpy after write_flattened_sequence | read_col_formatted_as_numpy after write_nested_sequence | read_col_unformated after write_array2d | read_col_unformated after write_flattened_sequence | read_col_unformated after write_nested_sequence | read_formatted_as_numpy after write_array2d | read_formatted_as_numpy after write_flattened_sequence | read_formatted_as_numpy after write_nested_sequence | read_unformated after write_array2d | read_unformated after write_flattened_sequence | read_unformated after write_nested_sequence | write_array2d | write_flattened_sequence | write_nested_sequence |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.009475 / 0.011353 (-0.001878) | 0.005249 / 0.011008 (-0.005759) | 0.099713 / 0.038508 (0.061205) | 0.036328 / 0.023109 (0.013219) | 0.295955 / 0.275898 (0.020057) | 0.368779 / 0.323480 (0.045299) | 0.007796 / 0.007986 (-0.000190) | 0.005635 / 0.004328 (0.001306) | 0.077351 / 0.004250 (0.073100) | 0.045290 / 0.037052 (0.008238) | 0.306634 / 0.258489 (0.048145) | 0.345025 / 0.293841 (0.051184) | 0.038241 / 0.128546 (-0.090306) | 0.012338 / 0.075646 (-0.063308) | 0.335184 / 0.419271 (-0.084088) | 0.047737 / 0.043533 (0.004204) | 0.295092 / 0.255139 (0.039953) | 0.319810 / 0.283200 (0.036610) | 0.102777 / 0.141683 (-0.038906) | 1.399444 / 1.452155 (-0.052711) | 1.450239 / 1.492716 (-0.042478) |

### Benchmark: benchmark_getitem\_100B.json

| metric | get_batch_of\_1024\_random_rows | get_batch_of\_1024\_rows | get_first_row | get_last_row |
|--------|---|---|---|---|
| new / old (diff) | 0.202919 / 0.018006 (0.184912) | 0.447493 / 0.000490 (0.447003) | 0.004187 / 0.000200 (0.003987) | 0.000083 / 0.000054 (0.000029) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.028570 / 0.037411 (-0.008841) | 0.113536 / 0.014526 (0.099010) | 0.120525 / 0.176557 (-0.056031) | 0.162732 / 0.737135 (-0.574404) | 0.130195 / 0.296338 (-0.166144) |

### Benchmark: benchmark_iterating.json

| metric | read 5000 | read 50000 | read_batch 50000 10 | read_batch 50000 100 | read_batch 50000 1000 | read_formatted numpy 5000 | read_formatted pandas 5000 | read_formatted tensorflow 5000 | read_formatted torch 5000 | read_formatted_batch numpy 5000 10 | read_formatted_batch numpy 5000 1000 | shuffled read 5000 | shuffled read 50000 | shuffled read_batch 50000 10 | shuffled read_batch 50000 100 | shuffled read_batch 50000 1000 | shuffled read_formatted numpy 5000 | shuffled read_formatted_batch numpy 5000 10 | shuffled read_formatted_batch numpy 5000 1000 |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.408831 / 0.215209 (0.193622) | 4.094929 / 2.077655 (2.017274) | 1.810356 / 1.504120 (0.306236) | 1.618532 / 1.541195 (0.077337) | 1.681310 / 1.468490 (0.212820) | 0.705157 / 4.584777 (-3.879620) | 3.789040 / 3.745712 (0.043327) | 2.121842 / 5.269862 (-3.148020) | 1.522505 / 4.565676 (-3.043171) | 0.085443 / 0.424275 (-0.338832) | 0.012065 / 0.007607 (0.004458) | 0.521176 / 0.226044 (0.295132) | 5.201899 / 2.268929 (2.932970) | 2.303055 / 55.444624 (-53.141569) | 1.971721 / 6.876477 (-4.904756) | 2.053827 / 2.142072 (-0.088245) | 0.864810 / 4.805227 (-3.940418) | 0.168040 / 6.500664 (-6.332624) | 0.063332 / 0.075469 (-0.012138) |

### Benchmark: benchmark_map_filter.json

| metric | filter | map fast-tokenizer batched | map identity | map identity batched | map no-op batched | map no-op batched numpy | map no-op batched pandas | map no-op batched pytorch | map no-op batched tensorflow |
|--------|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 1.208105 / 1.841788 (-0.633683) | 14.722757 / 8.074308 (6.648449) | 14.396695 / 10.191392 (4.205303) | 0.152702 / 0.680424 (-0.527722) | 0.028828 / 0.534201 (-0.505373) | 0.439573 / 0.579283 (-0.139710) | 0.438891 / 0.434364 (0.004527) | 0.509043 / 0.540337 (-0.031295) | 0.603531 / 1.386936 (-0.783405) |

</details>
PyArrow==latest

<details>
<summary>Show updated benchmarks!</summary>

### Benchmark: benchmark_array_xd.json

| metric | read_batch_formatted_as_numpy after write_array2d | read_batch_formatted_as_numpy after write_flattened_sequence | read_batch_formatted_as_numpy after write_nested_sequence | read_batch_unformated after write_array2d | read_batch_unformated after write_flattened_sequence | read_batch_unformated after write_nested_sequence | read_col_formatted_as_numpy after write_array2d | read_col_formatted_as_numpy after write_flattened_sequence | read_col_formatted_as_numpy after write_nested_sequence | read_col_unformated after write_array2d | read_col_unformated after write_flattened_sequence | read_col_unformated after write_nested_sequence | read_formatted_as_numpy after write_array2d | read_formatted_as_numpy after write_flattened_sequence | read_formatted_as_numpy after write_nested_sequence | read_unformated after write_array2d | read_unformated after write_flattened_sequence | read_unformated after write_nested_sequence | write_array2d | write_flattened_sequence | write_nested_sequence |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.007337 / 0.011353 (-0.004016) | 0.005080 / 0.011008 (-0.005929) | 0.097916 / 0.038508 (0.059408) | 0.032722 / 0.023109 (0.009612) | 0.338925 / 0.275898 (0.063027) | 0.372945 / 0.323480 (0.049465) | 0.005464 / 0.007986 (-0.002522) | 0.004031 / 0.004328 (-0.000297) | 0.076761 / 0.004250 (0.072511) | 0.046804 / 0.037052 (0.009752) | 0.336088 / 0.258489 (0.077599) | 0.403704 / 0.293841 (0.109863) | 0.036928 / 0.128546 (-0.091618) | 0.012204 / 0.075646 (-0.063442) | 0.335467 / 0.419271 (-0.083804) | 0.049158 / 0.043533 (0.005625) | 0.342040 / 0.255139 (0.086901) | 0.356729 / 0.283200 (0.073530) | 0.101280 / 0.141683 (-0.040403) | 1.432540 / 1.452155 (-0.019614) | 1.545228 / 1.492716 (0.052512) |

### Benchmark: benchmark_getitem\_100B.json

| metric | get_batch_of\_1024\_random_rows | get_batch_of\_1024\_rows | get_first_row | get_last_row |
|--------|---|---|---|---|
| new / old (diff) | 0.226003 / 0.018006 (0.207997) | 0.445601 / 0.000490 (0.445112) | 0.000408 / 0.000200 (0.000208) | 0.000057 / 0.000054 (0.000003) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.028861 / 0.037411 (-0.008551) | 0.112083 / 0.014526 (0.097557) | 0.130843 / 0.176557 (-0.045713) | 0.159275 / 0.737135 (-0.577861) | 0.127582 / 0.296338 (-0.168756) |

### Benchmark: benchmark_iterating.json

| metric | read 5000 | read 50000 | read_batch 50000 10 | read_batch 50000 100 | read_batch 50000 1000 | read_formatted numpy 5000 | read_formatted pandas 5000 | read_formatted tensorflow 5000 | read_formatted torch 5000 | read_formatted_batch numpy 5000 10 | read_formatted_batch numpy 5000 1000 | shuffled read 5000 | shuffled read 50000 | shuffled read_batch 50000 10 | shuffled read_batch 50000 100 | shuffled read_batch 50000 1000 | shuffled read_formatted numpy 5000 | shuffled read_formatted_batch numpy 5000 10 | shuffled read_formatted_batch numpy 5000 1000 |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.446357 / 0.215209 (0.231148) | 4.448568 / 2.077655 (2.370914) | 2.197861 / 1.504120 (0.693741) | 2.004675 / 1.541195 (0.463480) | 2.052082 / 1.468490 (0.583592) | 0.710770 / 4.584777 (-3.874007) | 3.868936 / 3.745712 (0.123224) | 2.095008 / 5.269862 (-3.174854) | 1.363064 / 4.565676 (-3.202613) | 0.086734 / 0.424275 (-0.337541) | 0.012272 / 0.007607 (0.004665) | 0.546378 / 0.226044 (0.320334) | 5.475189 / 2.268929 (3.206260) | 2.702742 / 55.444624 (-52.741882) | 2.335880 / 6.876477 (-4.540597) | 2.396194 / 2.142072 (0.254121) | 0.856249 / 4.805227 (-3.948978) | 0.170466 / 6.500664 (-6.330198) | 0.063585 / 0.075469 (-0.011884) |

### Benchmark: benchmark_map_filter.json

| metric | filter | map fast-tokenizer batched | map identity | map identity batched | map no-op batched | map no-op batched numpy | map no-op batched pandas | map no-op batched pytorch | map no-op batched tensorflow |
|--------|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 1.236981 / 1.841788 (-0.604807) | 15.046616 / 8.074308 (6.972307) | 14.551781 / 10.191392 (4.360389) | 0.144485 / 0.680424 (-0.535939) | 0.017774 / 0.534201 (-0.516427) | 0.446274 / 0.579283 (-0.133010) | 0.436871 / 0.434364 (0.002507) | 0.504503 / 0.540337 (-0.035834) | 0.602014 / 1.386936 (-0.784922) |

</details>
</details>

![](https://cml.dev/watermark.png#697b6d6e718ebec777061a803582864e31486dba "CML watermark")

2023-01-24T13:00:19Z
https://github.com/huggingface/datasets/pull/3379#issuecomment-1401910392
https://api.github.com/repos/huggingface/datasets/issues/3379
IC_kwDODunzps5Tj3R4
https://api.github.com/repos/huggingface/datasets/issues/comments/1401910392/reactions
2023-01-24T13:00:19Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1401910392
https://avatars.githubusercontent.com/in/15368?v=4
https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}
https://api.github.com/users/github-actions%5Bbot%5D/followers
https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}
https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}
https://github.com/apps/github-actions
github-actions[bot]
MDM6Qm90NDE4OTgyODI=
https://api.github.com/users/github-actions%5Bbot%5D/orgs
https://api.github.com/users/github-actions%5Bbot%5D/received_events
https://api.github.com/users/github-actions%5Bbot%5D/repos
https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}
https://api.github.com/users/github-actions%5Bbot%5D/subscriptions
Bot
https://api.github.com/users/github-actions%5Bbot%5D
public
Hello @lhoestq , thank you for your detailed answer on previous PR ! 
I made this new PR because I misused git on the previous one #3347.
Related issue #3272.

# Comments  : 

* For extension check I used the `_get_extraction_protocol` function in **download_manager.py** with a slight change and called it `_get_extraction_protocol_local`: 

**I removed this part :**
 ```python
    elif path.endswith(".tar.gz") or path.endswith(".tgz"):
        raise NotImplementedError(
            f"Extraction protocol for TAR archives like '{urlpath}' is not implemented in streaming mode. Please use `dl_manager.iter_archive` instead."
        )
```
**And also changed :** 
```diff
- extension = path.split(".")[-1]
+ extension = "tar" if path.endswith(".tar.gz") else path.split(".")[-1]
```
The reason for this is a compression like **.tar.gz** will be considered a **.gz** which is handled with **zipfile**, though **tar.gz** can only be opened using **tarfile**.

Please tell me if there's anything to change.

# Tasks : 
- [x] download_manager.py
- [x] streaming_download_manager.py 