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 for fixing HTTP Error 403 #551

Open
wants to merge 4 commits into
base: branch-25.02
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions python/cuvs_bench/cuvs_bench/get_dataset/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import os
import subprocess
import sys
from urllib.request import urlretrieve
import urllib.request


def get_dataset_path(name, ann_bench_data_path):
Expand All @@ -29,7 +29,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
2 changes: 1 addition & 1 deletion python/cuvs_bench/cuvs_bench/run/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def gather_algorithm_configs(
algos_conf_fs = [
os.path.join(scripts_path, "../config", "algos", f)
for f in algos_conf_fs
if ".json" not in f and "constraint" not in f and ".py" not in f
if f.endswith(".yaml")
]

if configuration:
Expand Down
Loading