mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 17:17:14 +08:00
[fix] multi source download (#3259)
* 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 * 兜底修改 * Trigger CI
This commit is contained in:
@@ -531,16 +531,16 @@ def retrive_model_from_server(model_name_or_path, revision="master"):
|
|||||||
local_path = f"{local_path}/{repo_id}"
|
local_path = f"{local_path}/{repo_id}"
|
||||||
aistudio_download(repo_id=repo_id, revision=revision, local_dir=local_path)
|
aistudio_download(repo_id=repo_id, revision=revision, local_dir=local_path)
|
||||||
model_name_or_path = local_path
|
model_name_or_path = local_path
|
||||||
except Exception:
|
except requests.exceptions.ConnectTimeout:
|
||||||
if os.path.exists(local_path):
|
if os.path.exists(local_path):
|
||||||
llm_logger.error(
|
llm_logger.error(
|
||||||
f"Failed to connect to aistudio, but detected that the model directory {local_path} exists. Attempting to start."
|
f"Failed to connect to aistudio, but detected that the model directory {local_path} exists. Attempting to start."
|
||||||
)
|
)
|
||||||
return local_path
|
return local_path
|
||||||
else:
|
except Exception:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
f"The {revision} of {model_name_or_path} is not exist. Please check the model name or revision."
|
f"The {revision} of {model_name_or_path} is not exist. Please check the model name or revision."
|
||||||
)
|
)
|
||||||
elif model_source == "MODELSCOPE":
|
elif model_source == "MODELSCOPE":
|
||||||
try:
|
try:
|
||||||
from modelscope.hub.snapshot_download import (
|
from modelscope.hub.snapshot_download import (
|
||||||
@@ -554,6 +554,12 @@ def retrive_model_from_server(model_name_or_path, revision="master"):
|
|||||||
local_path = f"{local_path}/{repo_id}"
|
local_path = f"{local_path}/{repo_id}"
|
||||||
modelscope_download(repo_id=repo_id, revision=revision, local_dir=local_path)
|
modelscope_download(repo_id=repo_id, revision=revision, local_dir=local_path)
|
||||||
model_name_or_path = local_path
|
model_name_or_path = local_path
|
||||||
|
except requests.exceptions.ConnectTimeout:
|
||||||
|
if os.path.exists(local_path):
|
||||||
|
llm_logger.error(
|
||||||
|
f"Failed to connect to modelscope, but detected that the model directory {local_path} exists. Attempting to start."
|
||||||
|
)
|
||||||
|
return local_path
|
||||||
except Exception:
|
except Exception:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
f"The {revision} of {model_name_or_path} is not exist. Please check the model name or revision."
|
f"The {revision} of {model_name_or_path} is not exist. Please check the model name or revision."
|
||||||
|
@@ -50,21 +50,6 @@ class TestAistudioDownload(unittest.TestCase):
|
|||||||
|
|
||||||
os.environ.clear()
|
os.environ.clear()
|
||||||
|
|
||||||
def test_retrive_model_from_aistudio_server_(self):
|
|
||||||
"""
|
|
||||||
Test case for retrieving a model from AI Studio server.
|
|
||||||
"""
|
|
||||||
os.environ["FD_MODEL_SOURCE"] = "AISTUDIO"
|
|
||||||
os.environ["FD_MODEL_CACHE"] = "./models"
|
|
||||||
|
|
||||||
model_name_or_path = "baidu/ERNIE-4.5-0.3B-PT"
|
|
||||||
revision = "aaa"
|
|
||||||
expected_path = "./models/PaddlePaddle/ERNIE-4.5-0.3B-PT"
|
|
||||||
result = retrive_model_from_server(model_name_or_path, revision)
|
|
||||||
self.assertEqual(expected_path, result)
|
|
||||||
|
|
||||||
os.environ.clear()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Reference in New Issue
Block a user