From b293095bd0c7240b89438abbd667468e1329abf7 Mon Sep 17 00:00:00 2001 From: "mulin.lyh" Date: Fri, 2 Dec 2022 19:41:59 +0800 Subject: [PATCH] [to #46522320]fix: fix download file timeout too short Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/10961023 * [to #46522320]fix: fix download file timeout too short --- modelscope/hub/constants.py | 1 + modelscope/hub/file_download.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modelscope/hub/constants.py b/modelscope/hub/constants.py index 9d5881e8..7f3cae0c 100644 --- a/modelscope/hub/constants.py +++ b/modelscope/hub/constants.py @@ -15,6 +15,7 @@ REQUESTS_API_HTTP_METHOD = ['get', 'head', 'post', 'put', 'patch', 'delete'] API_HTTP_CLIENT_TIMEOUT = 60 API_RESPONSE_FIELD_DATA = 'Data' API_FILE_DOWNLOAD_RETRY_TIMES = 5 +API_FILE_DOWNLOAD_TIMEOUT = 60 * 5 API_FILE_DOWNLOAD_CHUNK_SIZE = 4096 API_RESPONSE_FIELD_GIT_ACCESS_TOKEN = 'AccessToken' API_RESPONSE_FIELD_USERNAME = 'Username' diff --git a/modelscope/hub/file_download.py b/modelscope/hub/file_download.py index dd062516..b52ba2a2 100644 --- a/modelscope/hub/file_download.py +++ b/modelscope/hub/file_download.py @@ -15,7 +15,8 @@ from tqdm import tqdm from modelscope import __version__ from modelscope.hub.api import HubApi, ModelScopeConfig from modelscope.hub.constants import (API_FILE_DOWNLOAD_CHUNK_SIZE, - API_FILE_DOWNLOAD_RETRY_TIMES, FILE_HASH) + API_FILE_DOWNLOAD_RETRY_TIMES, + API_FILE_DOWNLOAD_TIMEOUT, FILE_HASH) from modelscope.utils.constant import DEFAULT_MODEL_REVISION from modelscope.utils.logger import get_logger from .errors import FileDownloadError, NotExistError @@ -220,7 +221,7 @@ def http_get_file( stream=True, headers=get_headers, cookies=cookies, - timeout=5) + timeout=API_FILE_DOWNLOAD_TIMEOUT) r.raise_for_status() content_length = r.headers.get('Content-Length') total = int(