datasets icon indicating copy to clipboard operation
datasets copied to clipboard

Nonsensical DL size in progress bar when some files are already downloaded

Open IRDonch opened this issue 4 years ago • 2 comments

Short description Running tfds build <dataset> when some of the files have already been downloaded and some are missing results in meaningless sizes being displayed in the progress bar.

Environment information

  • Operating System: Ubuntu 18.04

  • Python version: 3.7.5

  • tensorflow-datasets/tfds-nightly version: tensorflow-datasets 4.5.2

  • tensorflow/tf-nightly version: tensorflow 2.7.0

  • Does the issue still exists with the last tfds-nightly package (pip install --upgrade tfds-nightly) ? Yes

Reproduction instructions

First, run tfds build voc/2012 and wait for it to finish.

Then, remove $TFDS_DATA_DIR/downloads/pjredd.com_media_files_VOCtra_11-May-20124U92MnDPGT0LX3SxafRBV6Swxu-nCPTdD_eO5pF2O8s.tar and $TFDS_DATA_DIR/voc/2012/4.0.0.

Then run tfds build voc/2012 again. The progress bar will show something like this:

Dl Size...: 100%|█████████████████████████████████████████████▉| 1850626566/1850628467 [00:12<00:00, 146829508.09 MiB/s]

This doesn't make sense, as it implies that the missing file is less than 1% of the total size of the dataset's files, even though it's almost 2 GB in size.

Link to logs N/A

Expected behavior The progress bar should display numbers that are correctly proportioned.

Additional context This most likely happens because the code that reports progress is inconsistent about the units it uses. Here and here it uses bytes, while here it uses megabytes.

IRDonch avatar Feb 08 '22 15:02 IRDonch

Thanks for reporting, indeed: https://github.com/tensorflow/datasets/blob/47baec10e957bffbd52c960cfce1ad31c60e04dd/tensorflow_datasets/core/download/downloader.py#L138 should be updated to use the correct unit. Don't hesitate to send a PR

Conchylicultor avatar Feb 21 '22 09:02 Conchylicultor

I'd like to take this one. It still reproduces on master (4.9.10 nightly). increase_tqdm (cached files) and _sync_file_copy (gfile copies) add url_info.size in bytes to the Dl Size... bar, and that bar counts MiB. With one cached 150 MiB file the bar reads 157286400/157286400 MiB. While checking this I found a second problem on the HTTP path: when a download ends exactly on a MiB boundary, the last MiB is never counted, so a 3 MiB file ends at 2/3. I'll send a small PR that routes both paths through one MiB conversion and adds a regression test for each of the three paths.

Sonica-B avatar Oct 26 '26 04:10 Sonica-B