Skip to content

Commit 855e952

Browse files
committed
连接失败兜底
1 parent df76819 commit 855e952

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

fastdeploy/utils.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,15 @@ def retrive_model_from_server(model_name_or_path, revision="master"):
511511
aistudio_download(repo_id=repo_id, revision=revision, local_dir=local_path)
512512
model_name_or_path = local_path
513513
except Exception:
514-
raise Exception(
515-
f"The {revision} of {model_name_or_path} is not exist. Please check the model name or revision."
516-
)
514+
if os.path.exists(model_name_or_path):
515+
llm_logger.error(
516+
"Failed to connect to aistudio, but detected that the model directory exists. Attempting to start."
517+
)
518+
return model_name_or_path
519+
else:
520+
raise Exception(
521+
f"The {revision} of {model_name_or_path} is not exist. Please check the model name or revision."
522+
)
517523
elif model_source == "MODELSCOPE":
518524
try:
519525
from modelscope.hub.snapshot_download import (
@@ -528,9 +534,15 @@ def retrive_model_from_server(model_name_or_path, revision="master"):
528534
modelscope_download(repo_id=repo_id, revision=revision, local_dir=local_path)
529535
model_name_or_path = local_path
530536
except Exception:
531-
raise Exception(
532-
f"The {revision} of {model_name_or_path} is not exist. Please check the model name or revision."
533-
)
537+
if os.path.exists(model_name_or_path):
538+
llm_logger.error(
539+
"Failed to connect to modelscope, but detected that the model directory exists. Attempting to start."
540+
)
541+
return model_name_or_path
542+
else:
543+
raise Exception(
544+
f"The {revision} of {model_name_or_path} is not exist. Please check the model name or revision."
545+
)
534546
elif model_source == "HUGGINGFACE":
535547
try:
536548
from huggingface_hub._snapshot_download import (

0 commit comments

Comments
 (0)