Skip to content

Commit 0403856

Browse files
committed
Added header to Zenodo downloads
1 parent e00f873 commit 0403856

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/decoupler/_download.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from tqdm import tqdm
77

88
from decoupler._log import _log
9+
from importlib.metadata import version
910

1011
URL_DBS = "https://omnipathdb.org/annotations?databases="
1112
URL_INT = "https://omnipathdb.org/interactions/?genesymbols=1&"
@@ -17,10 +18,12 @@ def _download_chunks(
1718
) -> io.BytesIO:
1819
assert isinstance(url, str), "url must be str"
1920
# Download with progress bar
20-
m = f"Downloading {url}"
21-
_log(m, level="info", verbose=verbose)
2221
chunks = []
23-
with requests.get(url, stream=True) as r:
22+
__version__ = version("decoupler")
23+
headers = {
24+
'User-Agent': f'decoupler/{__version__} (https://github.com/scverse/decoupler)'
25+
}
26+
with requests.get(url, stream=True, headers=headers) as r:
2427
r.raise_for_status()
2528
with tqdm(unit="B", unit_scale=True, desc="Progress", disable=not verbose) as pbar:
2629
for chunk in r.iter_content(chunk_size=8192):
@@ -29,8 +32,6 @@ def _download_chunks(
2932
pbar.update(len(chunk))
3033
# Read into bytes
3134
data = io.BytesIO(b"".join(chunks))
32-
m = "Download finished"
33-
_log(m, level="info", verbose=verbose)
3435
return data
3536

3637

0 commit comments

Comments
 (0)