Skip to content

Commit 6037dd5

Browse files
authored
[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
1 parent 9423c57 commit 6037dd5

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

fastdeploy/utils.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -531,16 +531,16 @@ def retrive_model_from_server(model_name_or_path, revision="master"):
531531
local_path = f"{local_path}/{repo_id}"
532532
aistudio_download(repo_id=repo_id, revision=revision, local_dir=local_path)
533533
model_name_or_path = local_path
534-
except Exception:
534+
except requests.exceptions.ConnectTimeout:
535535
if os.path.exists(local_path):
536536
llm_logger.error(
537537
f"Failed to connect to aistudio, but detected that the model directory {local_path} exists. Attempting to start."
538538
)
539539
return local_path
540-
else:
541-
raise Exception(
542-
f"The {revision} of {model_name_or_path} is not exist. Please check the model name or revision."
543-
)
540+
except Exception:
541+
raise Exception(
542+
f"The {revision} of {model_name_or_path} is not exist. Please check the model name or revision."
543+
)
544544
elif model_source == "MODELSCOPE":
545545
try:
546546
from modelscope.hub.snapshot_download import (
@@ -554,6 +554,12 @@ def retrive_model_from_server(model_name_or_path, revision="master"):
554554
local_path = f"{local_path}/{repo_id}"
555555
modelscope_download(repo_id=repo_id, revision=revision, local_dir=local_path)
556556
model_name_or_path = local_path
557+
except requests.exceptions.ConnectTimeout:
558+
if os.path.exists(local_path):
559+
llm_logger.error(
560+
f"Failed to connect to modelscope, but detected that the model directory {local_path} exists. Attempting to start."
561+
)
562+
return local_path
557563
except Exception:
558564
raise Exception(
559565
f"The {revision} of {model_name_or_path} is not exist. Please check the model name or revision."

test/utils/test_download.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,6 @@ def test_retrive_model_from_huggingface_server_model_not_exist(self):
5050

5151
os.environ.clear()
5252

53-
def test_retrive_model_from_aistudio_server_(self):
54-
"""
55-
Test case for retrieving a model from AI Studio server.
56-
"""
57-
os.environ["FD_MODEL_SOURCE"] = "AISTUDIO"
58-
os.environ["FD_MODEL_CACHE"] = "./models"
59-
60-
model_name_or_path = "baidu/ERNIE-4.5-0.3B-PT"
61-
revision = "aaa"
62-
expected_path = "./models/PaddlePaddle/ERNIE-4.5-0.3B-PT"
63-
result = retrive_model_from_server(model_name_or_path, revision)
64-
self.assertEqual(expected_path, result)
65-
66-
os.environ.clear()
67-
6853

6954
if __name__ == "__main__":
7055
unittest.main()

0 commit comments

Comments
 (0)