[Feature] multi source download (#3125)
Deploy GitHub Pages / deploy (push) Has been cancelled

* multi-source download

* multi-source download

* huggingface download revision

* requirement

* style

* add revision arg

* test

* pre-commit

* Change default download

* change requirements.txt

* modify English Documentation

* documentation

* modify model download path

* add requirements

* error optimization

* 连接失败兜底

* 连接失败兜底

* 连接失败兜底

* unit test

* unit test

* unit test

* test

* test
This commit is contained in:
Yzc216
2025-08-07 00:40:27 +08:00
committed by GitHub
parent 9408e667a5
commit d9e3f88f9e
4 changed files with 57 additions and 18 deletions
+15 -3
View File
@@ -532,7 +532,15 @@ def retrive_model_from_server(model_name_or_path, revision="master"):
aistudio_download(repo_id=repo_id, revision=revision, local_dir=local_path)
model_name_or_path = local_path
except Exception:
raise Exception(f"The setting model_name_or_path:{model_name_or_path} is not exist.")
if os.path.exists(local_path):
llm_logger.error(
f"Failed to connect to aistudio, but detected that the model directory {local_path} exists. Attempting to start."
)
return local_path
else:
raise Exception(
f"The {revision} of {model_name_or_path} is not exist. Please check the model name or revision."
)
elif model_source == "MODELSCOPE":
try:
from modelscope.hub.snapshot_download import (
@@ -547,7 +555,9 @@ def retrive_model_from_server(model_name_or_path, revision="master"):
modelscope_download(repo_id=repo_id, revision=revision, local_dir=local_path)
model_name_or_path = local_path
except Exception:
raise Exception(f"The setting model_name_or_path:{model_name_or_path} is not exist.")
raise Exception(
f"The {revision} of {model_name_or_path} is not exist. Please check the model name or revision."
)
elif model_source == "HUGGINGFACE":
try:
from huggingface_hub._snapshot_download import (
@@ -565,7 +575,9 @@ def retrive_model_from_server(model_name_or_path, revision="master"):
huggingface_download(repo_id=repo_id, revision=revision, local_dir=local_path)
model_name_or_path = local_path
except Exception:
raise Exception(f"The setting model_name_or_path:{model_name_or_path} is not exist.")
raise Exception(
f"The {revision} of {model_name_or_path} is not exist. Please check the model name or revision."
)
else:
raise ValueError(
f"Unsupported model source: {model_source}, please choose one of ['MODELSCOPE', 'AISTUDIO', 'HUGGINGFACE']"