Skip to content

Commit

Permalink
add download dataset progress bar (erikbern#7)
Browse files Browse the repository at this point in the history
* order algos

* add download progress
  • Loading branch information
wxywb authored Mar 3, 2020
1 parent 36d5911 commit 6750180
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion ann_benchmarks/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,34 @@
import os
import random
import sys
import progressbar

from urllib.request import urlopen
from urllib.request import urlretrieve

from ann_benchmarks.distance import dataset_transform


class MyProgressBar():
def __init__(self):
self.pbar = None

def __call__(self, block_num, block_size, total_size):
if not self.pbar:
self.pbar=progressbar.ProgressBar(maxval=total_size)
self.pbar.start()

downloaded = block_num * block_size
if downloaded < total_size:
self.pbar.update(downloaded)
else:
self.pbar.finish()

def download(src, dst):
if not os.path.exists(dst):
# TODO: should be atomic
print('downloading %s -> %s...' % (src, dst))
urlretrieve(src, dst)
urlretrieve(src, dst, MyProgressBar())


def get_dataset_fn(dataset):
Expand Down
Empty file added print_results.py
Empty file.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ psutil==5.4.2
scipy==1.0.0
scikit-learn==0.19.1
jinja2==2.10
progressbar2==3.50.0

0 comments on commit 6750180

Please sign in to comment.