def download_var_cloud(data_name):
if not isinstance(data_name, str):
print("data_name must be a string")
return
user_hash = settings.API_KEY
url = 'http://%s/api/save/getDownloadUrl' % settings.CATALEARN_URL
r = requests.post(url, data={
'type': 'variable',
'user_hash': user_hash,
'file_name': data_name
})
if r.status_code != 200:
raise RuntimeError(r.text)
presigned_url = r.content
# Now send the post request to the catalearn server
res = requests.get(presigned_url, stream=True)
raw = io.BytesIO()
download_progress(res, raw, data_name)
result = dill.loads(raw.getvalue())
return result
评论列表
文章目录