Unverified Commit 49979753 authored by Lucain's avatar Lucain Committed by GitHub
Browse files

Always raise from previous error (#8751)

parent a3904d7e
...@@ -358,42 +358,42 @@ def _get_model_file( ...@@ -358,42 +358,42 @@ def _get_model_file(
) )
return model_file return model_file
except RepositoryNotFoundError: except RepositoryNotFoundError as e:
raise EnvironmentError( raise EnvironmentError(
f"{pretrained_model_name_or_path} is not a local folder and is not a valid model identifier " f"{pretrained_model_name_or_path} is not a local folder and is not a valid model identifier "
"listed on 'https://huggingface.co/models'\nIf this is a private repository, make sure to pass a " "listed on 'https://huggingface.co/models'\nIf this is a private repository, make sure to pass a "
"token having permission to this repo with `token` or log in with `huggingface-cli " "token having permission to this repo with `token` or log in with `huggingface-cli "
"login`." "login`."
) ) from e
except RevisionNotFoundError: except RevisionNotFoundError as e:
raise EnvironmentError( raise EnvironmentError(
f"{revision} is not a valid git identifier (branch name, tag name or commit id) that exists for " f"{revision} is not a valid git identifier (branch name, tag name or commit id) that exists for "
"this model name. Check the model page at " "this model name. Check the model page at "
f"'https://huggingface.co/{pretrained_model_name_or_path}' for available revisions." f"'https://huggingface.co/{pretrained_model_name_or_path}' for available revisions."
) ) from e
except EntryNotFoundError: except EntryNotFoundError as e:
raise EnvironmentError( raise EnvironmentError(
f"{pretrained_model_name_or_path} does not appear to have a file named {weights_name}." f"{pretrained_model_name_or_path} does not appear to have a file named {weights_name}."
) ) from e
except HTTPError as err: except HTTPError as e:
raise EnvironmentError( raise EnvironmentError(
f"There was a specific connection error when trying to load {pretrained_model_name_or_path}:\n{err}" f"There was a specific connection error when trying to load {pretrained_model_name_or_path}:\n{e}"
) ) from e
except ValueError: except ValueError as e:
raise EnvironmentError( raise EnvironmentError(
f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load this model, couldn't find it" f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load this model, couldn't find it"
f" in the cached files and it looks like {pretrained_model_name_or_path} is not the path to a" f" in the cached files and it looks like {pretrained_model_name_or_path} is not the path to a"
f" directory containing a file named {weights_name} or" f" directory containing a file named {weights_name} or"
" \nCheckout your internet connection or see how to run the library in" " \nCheckout your internet connection or see how to run the library in"
" offline mode at 'https://huggingface.co/docs/diffusers/installation#offline-mode'." " offline mode at 'https://huggingface.co/docs/diffusers/installation#offline-mode'."
) ) from e
except EnvironmentError: except EnvironmentError as e:
raise EnvironmentError( raise EnvironmentError(
f"Can't load the model for '{pretrained_model_name_or_path}'. If you were trying to load it from " f"Can't load the model for '{pretrained_model_name_or_path}'. If you were trying to load it from "
"'https://huggingface.co/models', make sure you don't have a local directory with the same name. " "'https://huggingface.co/models', make sure you don't have a local directory with the same name. "
f"Otherwise, make sure '{pretrained_model_name_or_path}' is the correct path to a directory " f"Otherwise, make sure '{pretrained_model_name_or_path}' is the correct path to a directory "
f"containing a file named {weights_name}" f"containing a file named {weights_name}"
) ) from e
# Adapted from # Adapted from
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment