handle MaxRetryError

This commit is contained in:
Qing 2024-01-08 23:43:20 +08:00
parent 7c1f83e71d
commit 6f4ce66793
2 changed files with 9 additions and 1 deletions

View File

@ -984,5 +984,13 @@ def handle_from_pretrained_exceptions(func, **kwargs):
if "RevisionNotFoundError: 404 Client Error." in previous_traceback:
logger.info("revision=fp16 not found, try revision=main")
return func(**{**kwargs, "variant": None, "revision": "main"})
elif "Max retries exceeded" in previous_traceback:
logger.exception(
"Fetching model from HuggingFace failed. "
"If this is your first time downloading the model, you may need to set up proxy in terminal."
"If the model has already been downloaded, you can add --local-files-only when starting."
)
exit(-1)
raise e
except Exception as e:
raise e

View File

@ -39,7 +39,7 @@ class ModelManager:
logger.info(f"Loading model: {name}")
if name not in self.available_models:
raise NotImplementedError(
f"Unsupported model: {name}. Available models: {self.available_models.keys()}"
f"Unsupported model: {name}. Available models: {list(self.available_models.keys())}"
)
model_info = self.available_models[name]