Skip to content

Commit

Permalink
Warning handling for downloading
Browse files Browse the repository at this point in the history
  • Loading branch information
Old-Shatterhand committed Feb 11, 2025
1 parent 7c510c9 commit e367437
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion glycowork/glycan_data/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from importlib import resources
from typing import Any, Dict, List, Union

import requests

with resources.files("glycowork.glycan_data").joinpath("glycan_motifs.csv").open(encoding = 'utf-8-sig') as f:
motif_list = pd.read_csv(f)

Expand Down Expand Up @@ -251,7 +253,14 @@ def download_model(file_id: str, # Google Drive file ID
"Download the model weights file from Google Drive"
file_id = file_id.split('/d/')[1].split('/view')[0]
url = f'https://drive.google.com/uc?id={file_id}'
urllib.request.urlretrieve(url, local_path)
response = requests.get(url, stream=True)
if response.status_code == 200:
with open(local_path, 'wb') as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
print("Download completed.")
else:
print(f"Download failed. Status code: {response.status_code}")
print("Download completed.")


Expand Down

0 comments on commit e367437

Please sign in to comment.