|
28 | 28 | from typing import Callable, Dict, Generator, Iterable, List, Optional, Tuple, Union |
29 | 29 |
|
30 | 30 | from .. import config |
| 31 | +from ..utils import tqdm as hf_tqdm |
31 | 32 | from ..utils.deprecation_utils import DeprecatedEnum, deprecated |
32 | 33 | from ..utils.file_utils import cached_path, get_from_cache, hash_url_to_filename, is_relative_path, url_or_path_join |
33 | 34 | from ..utils.info_utils import get_size_checksum_dict |
34 | | -from ..utils.logging import get_logger, is_progress_bar_enabled, tqdm |
| 35 | +from ..utils.logging import get_logger |
35 | 36 | from ..utils.py_utils import NestedDataStructure, map_nested, size_str |
36 | 37 | from .download_config import DownloadConfig |
37 | 38 |
|
@@ -327,18 +328,16 @@ def upload(local_file_path): |
327 | 328 | uploaded_path_or_paths = map_nested( |
328 | 329 | lambda local_file_path: upload(local_file_path), |
329 | 330 | downloaded_path_or_paths, |
330 | | - disable_tqdm=not is_progress_bar_enabled(), |
331 | 331 | ) |
332 | 332 | return uploaded_path_or_paths |
333 | 333 |
|
334 | 334 | def _record_sizes_checksums(self, url_or_urls: NestedDataStructure, downloaded_path_or_paths: NestedDataStructure): |
335 | 335 | """Record size/checksum of downloaded files.""" |
336 | 336 | delay = 5 |
337 | | - for url, path in tqdm( |
| 337 | + for url, path in hf_tqdm( |
338 | 338 | list(zip(url_or_urls.flatten(), downloaded_path_or_paths.flatten())), |
339 | 339 | delay=delay, |
340 | 340 | desc="Computing checksums", |
341 | | - disable=not is_progress_bar_enabled(), |
342 | 341 | ): |
343 | 342 | # call str to support PathLike objects |
344 | 343 | self._recorded_sizes_checksums[str(url)] = get_size_checksum_dict( |
@@ -373,9 +372,7 @@ def download_custom(self, url_or_urls, custom_download): |
373 | 372 | def url_to_downloaded_path(url): |
374 | 373 | return os.path.join(cache_dir, hash_url_to_filename(url)) |
375 | 374 |
|
376 | | - downloaded_path_or_paths = map_nested( |
377 | | - url_to_downloaded_path, url_or_urls, disable_tqdm=not is_progress_bar_enabled() |
378 | | - ) |
| 375 | + downloaded_path_or_paths = map_nested(url_to_downloaded_path, url_or_urls) |
379 | 376 | url_or_urls = NestedDataStructure(url_or_urls) |
380 | 377 | downloaded_path_or_paths = NestedDataStructure(downloaded_path_or_paths) |
381 | 378 | for url, path in zip(url_or_urls.flatten(), downloaded_path_or_paths.flatten()): |
@@ -426,7 +423,6 @@ def download(self, url_or_urls): |
426 | 423 | url_or_urls, |
427 | 424 | map_tuple=True, |
428 | 425 | num_proc=download_config.num_proc, |
429 | | - disable_tqdm=not is_progress_bar_enabled(), |
430 | 426 | desc="Downloading data files", |
431 | 427 | ) |
432 | 428 | duration = datetime.now() - start_time |
@@ -534,7 +530,6 @@ def extract(self, path_or_paths, num_proc="deprecated"): |
534 | 530 | partial(cached_path, download_config=download_config), |
535 | 531 | path_or_paths, |
536 | 532 | num_proc=download_config.num_proc, |
537 | | - disable_tqdm=not is_progress_bar_enabled(), |
538 | 533 | desc="Extracting data files", |
539 | 534 | ) |
540 | 535 | path_or_paths = NestedDataStructure(path_or_paths) |
|
0 commit comments