Skip to content

Commit

Permalink
Merge pull request #184 from jpgill86/fix-download-unknown-size-old-tqdm
Browse files Browse the repository at this point in the history
Fix incompatibility with old versions of tqdm and unknown download size
  • Loading branch information
jpgill86 authored Feb 6, 2020
2 parents 6329e5d + d87d412 commit e861ba7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions neurotic/datasets/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,11 @@ def _download_with_progress_bar(url, local_file, show_progress=True, bytes_per_c
# knowing the file size allows progress to be displayed
file_size_in_bytes = int(dist.headers['Content-Length'])
num_chunks = int(np.ceil(file_size_in_bytes/bytes_per_chunk))
total = num_chunks*bytes_per_chunk
else:
# progress can't be displayed, but other stats can be
num_chunks = np.inf
pbar = tqdm(total=num_chunks*bytes_per_chunk, unit='B', unit_scale=True)
total = None
pbar = tqdm(total=total, unit='B', unit_scale=True)
while True:
chunk = dist.read(bytes_per_chunk)
if chunk:
Expand Down

0 comments on commit e861ba7

Please sign in to comment.