Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add User-Agent header to download_dataset function #550

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion python/cuvs_bench/cuvs_bench/get_dataset/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import sys
from urllib.request import urlretrieve

import urllib.request

def get_dataset_path(name, ann_bench_data_path):
if not os.path.exists(ann_bench_data_path):
Expand All @@ -29,7 +30,10 @@ def get_dataset_path(name, ann_bench_data_path):
def download_dataset(url, path):
if not os.path.exists(path):
print(f"downloading {url} -> {path}...")
urlretrieve(url, path)
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
with urllib.request.urlopen(req) as response, open(path, 'wb') as out_file:
data = response.read()
out_file.write(data)


def convert_hdf5_to_fbin(path, normalize):
Expand Down
Loading