ProgramComputer
commited on
Commit
•
72239bc
1
Parent(s):
e334fb2
Update test.py
Browse files
test.py
CHANGED
@@ -31,10 +31,6 @@ from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, Ty
|
|
31 |
import warnings
|
32 |
import datasets
|
33 |
import urllib3
|
34 |
-
import urllib
|
35 |
-
|
36 |
-
a = urllib.request.urlopen("https://raw.githubusercontent.com/huggingface/datasets/main/src/datasets/utils/py_utils.py")
|
37 |
-
eval(a.read())
|
38 |
|
39 |
|
40 |
|
@@ -209,54 +205,7 @@ class Test(datasets.GeneratorBasedBuilder):
|
|
209 |
targets = (
|
210 |
["audio1", "audio2"] if self.config.name == "audio" else [self.config.name]
|
211 |
)
|
212 |
-
|
213 |
-
nonlocal dl_manager
|
214 |
-
"""
|
215 |
-
Download given urls(s) by calling `custom_download`.
|
216 |
-
|
217 |
-
Args:
|
218 |
-
url_or_urls (`str` or `list` or `dict`):
|
219 |
-
URL or `list` or `dict` of URLs to download and extract. Each URL is a `str`.
|
220 |
-
custom_download (`Callable[src_url, dst_path]`):
|
221 |
-
The source URL and destination path. For example
|
222 |
-
`tf.io.gfile.copy`, that lets you download from Google storage.
|
223 |
-
|
224 |
-
Returns:
|
225 |
-
downloaded_path(s): `str`, The downloaded paths matching the given input
|
226 |
-
`url_or_urls`.
|
227 |
-
|
228 |
-
Example:
|
229 |
-
|
230 |
-
```py
|
231 |
-
>>> downloaded_files = dl_manager.download_custom('s3://my-bucket/data.zip', custom_download_for_my_private_bucket)
|
232 |
-
```
|
233 |
-
"""
|
234 |
-
cache_dir = dl_manager.download_config.cache_dir #or config.DOWNLOADED_DATASETS_PATH
|
235 |
-
max_retries = dl_manager.download_config.max_retries
|
236 |
-
|
237 |
-
def url_to_downloaded_path(url):
|
238 |
-
return os.path.join(cache_dir, hash_url_to_filename(url))
|
239 |
-
|
240 |
-
downloaded_path_or_paths = map_nested(
|
241 |
-
url_to_downloaded_path, url_or_urls, disable_tqdm=not is_progress_bar_enabled()
|
242 |
-
)
|
243 |
-
url_or_urls = NestedDataStructure(url_or_urls)
|
244 |
-
downloaded_path_or_paths = NestedDataStructure(downloaded_path_or_paths)
|
245 |
-
for url, path in zip(url_or_urls.flatten(), downloaded_path_or_paths.flatten()):
|
246 |
-
try:
|
247 |
-
get_from_cache(
|
248 |
-
url, cache_dir=cache_dir, local_files_only=True, use_etag=False, max_retries=max_retries
|
249 |
-
)
|
250 |
-
cached = True
|
251 |
-
except FileNotFoundError:
|
252 |
-
cached = False
|
253 |
-
if not cached or dl_manager.download_config.force_download:
|
254 |
-
custom_download(url, path)
|
255 |
-
get_from_cache(
|
256 |
-
url, cache_dir=cache_dir, local_files_only=True, use_etag=False, max_retries=max_retries
|
257 |
-
)
|
258 |
-
dl_manager._record_sizes_checksums(url_or_urls, downloaded_path_or_paths)
|
259 |
-
return downloaded_path_or_paths.data
|
260 |
|
261 |
def download_custom(placeholder_url, path):
|
262 |
nonlocal dl_manager
|
@@ -337,7 +286,7 @@ class Test(datasets.GeneratorBasedBuilder):
|
|
337 |
)
|
338 |
)
|
339 |
|
340 |
-
mapped_paths = dl_manager.extract(
|
341 |
|
342 |
dict(
|
343 |
(
|
|
|
31 |
import warnings
|
32 |
import datasets
|
33 |
import urllib3
|
|
|
|
|
|
|
|
|
34 |
|
35 |
|
36 |
|
|
|
205 |
targets = (
|
206 |
["audio1", "audio2"] if self.config.name == "audio" else [self.config.name]
|
207 |
)
|
208 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
|
210 |
def download_custom(placeholder_url, path):
|
211 |
nonlocal dl_manager
|
|
|
286 |
)
|
287 |
)
|
288 |
|
289 |
+
mapped_paths = dl_manager.extract(dl_manager.custom_download(
|
290 |
|
291 |
dict(
|
292 |
(
|