File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525 MODELSCOPE_PARALLEL_DOWNLOAD_THRESHOLD_MB , TEMPORARY_FOLDER_NAME )
2626from modelscope .utils .constant import (DEFAULT_DATASET_REVISION ,
2727 DEFAULT_MODEL_REVISION ,
28+ INTRA_CLOUD_ACCELERATION ,
2829 REPO_TYPE_DATASET , REPO_TYPE_MODEL ,
2930 REPO_TYPE_SUPPORT )
3031from modelscope .utils .file_utils import (get_dataset_cache_root ,
@@ -194,9 +195,22 @@ def _repo_file_download(
194195 " online, set 'local_files_only' to False." )
195196
196197 _api = HubApi ()
198+
197199 headers = {
198- 'user-agent' : ModelScopeConfig .get_user_agent (user_agent = user_agent , )
200+ 'user-agent' : ModelScopeConfig .get_user_agent (user_agent = user_agent , ),
201+ 'snapshot-identifier' : str (uuid .uuid4 ()),
199202 }
203+
204+ if INTRA_CLOUD_ACCELERATION == 'true' :
205+ region_id : str = (
206+ os .getenv ('INTRA_CLOUD_ACCELERATION_REGION' )
207+ or _api ._get_internal_acceleration_domain ())
208+ if region_id :
209+ logger .info (
210+ f'Intra-cloud acceleration enabled for downloading from { repo_id } '
211+ )
212+ headers ['x-aliyun-region-id' ] = region_id
213+
200214 if cookies is None :
201215 cookies = ModelScopeConfig .get_cookies ()
202216 repo_files = []
You can’t perform that action at this time.
0 commit comments