diff --git a/src/transformers/configuration_utils.py b/src/transformers/configuration_utils.py index 580de6b91ee5..89bd03c4f23b 100755 --- a/src/transformers/configuration_utils.py +++ b/src/transformers/configuration_utils.py @@ -602,36 +602,31 @@ def _get_config_dict( user_agent=user_agent, ) - except RepositoryNotFoundError as err: - logger.error(err) + except RepositoryNotFoundError: raise EnvironmentError( 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 token having " "permission to this repo with `use_auth_token` or log in with `huggingface-cli login` and pass " "`use_auth_token=True`." ) - except RevisionNotFoundError as err: - logger.error(err) + except RevisionNotFoundError: raise EnvironmentError( f"{revision} is not a valid git identifier (branch name, tag name or commit id) that exists for this " f"model name. Check the model page at 'https://huggingface.co/{pretrained_model_name_or_path}' for " "available revisions." ) - except EntryNotFoundError as err: - logger.error(err) + except EntryNotFoundError: raise EnvironmentError( f"{pretrained_model_name_or_path} does not appear to have a file named {configuration_file}." ) - except HTTPError as err: - logger.error(err) + except HTTPError: raise EnvironmentError( "We couldn't connect to 'https://huggingface.co/' to load this model and it looks like " f"{pretrained_model_name_or_path} is not the path to a directory conaining a {configuration_file} " "file.\nCheckout your internet connection or see how to run the library in offline mode at " "'https://huggingface.co/docs/transformers/installation#offline-mode'." ) - except EnvironmentError as err: - logger.error(err) + except EnvironmentError: raise EnvironmentError( f"Can't load config 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. " diff --git a/src/transformers/feature_extraction_utils.py b/src/transformers/feature_extraction_utils.py index b65b7cfcd916..0fe8814609bf 100644 --- a/src/transformers/feature_extraction_utils.py +++ b/src/transformers/feature_extraction_utils.py @@ -380,36 +380,31 @@ def get_feature_extractor_dict( user_agent=user_agent, ) - except RepositoryNotFoundError as err: - logger.error(err) + except RepositoryNotFoundError: raise EnvironmentError( 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 token having " "permission to this repo with `use_auth_token` or log in with `huggingface-cli login` and pass " "`use_auth_token=True`." ) - except RevisionNotFoundError as err: - logger.error(err) + except RevisionNotFoundError: raise EnvironmentError( f"{revision} is not a valid git identifier (branch name, tag name or commit id) that exists for this " f"model name. Check the model page at 'https://huggingface.co/{pretrained_model_name_or_path}' for " "available revisions." ) - except EntryNotFoundError as err: - logger.error(err) + except EntryNotFoundError: raise EnvironmentError( f"{pretrained_model_name_or_path} does not appear to have a file named {FEATURE_EXTRACTOR_NAME}." ) - except HTTPError as err: - logger.error(err) + except HTTPError: raise EnvironmentError( "We couldn't connect to 'https://huggingface.co/' to load this model and it looks like " f"{pretrained_model_name_or_path} is not the path to a directory conaining a " f"{FEATURE_EXTRACTOR_NAME} file.\nCheckout your internet connection or see how to run the library in " "offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'." ) - except EnvironmentError as err: - logger.error(err) + except EnvironmentError: raise EnvironmentError( f"Can't load feature extractor 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. " diff --git a/src/transformers/file_utils.py b/src/transformers/file_utils.py index abc26cada9bd..0dc19cb7f5f0 100644 --- a/src/transformers/file_utils.py +++ b/src/transformers/file_utils.py @@ -2300,16 +2300,14 @@ def get_file_from_repo( use_auth_token=use_auth_token, ) - except RepositoryNotFoundError as err: - logger.error(err) + except RepositoryNotFoundError: raise EnvironmentError( f"{path_or_repo} 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 token having permission to this repo with `use_auth_token` or log in with " "`huggingface-cli login` and pass `use_auth_token=True`." ) - except RevisionNotFoundError as err: - logger.error(err) + except RevisionNotFoundError: raise EnvironmentError( 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 " diff --git a/src/transformers/modeling_flax_utils.py b/src/transformers/modeling_flax_utils.py index 969fd6daf22c..1d7c82421043 100644 --- a/src/transformers/modeling_flax_utils.py +++ b/src/transformers/modeling_flax_utils.py @@ -492,23 +492,20 @@ def from_pretrained( user_agent=user_agent, ) - except RepositoryNotFoundError as err: - logger.error(err) + except RepositoryNotFoundError: raise EnvironmentError( 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 " "token having permission to this repo with `use_auth_token` or log in with `huggingface-cli " "login` and pass `use_auth_token=True`." ) - except RevisionNotFoundError as err: - logger.error(err) + except RevisionNotFoundError: raise EnvironmentError( 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 " f"'https://huggingface.co/{pretrained_model_name_or_path}' for available revisions." ) - except EntryNotFoundError as err: - logger.error(err) + except EntryNotFoundError: if filename == FLAX_WEIGHTS_NAME: has_file_kwargs = {"revision": revision, "proxies": proxies, "use_auth_token": use_auth_token} if has_file(pretrained_model_name_or_path, WEIGHTS_NAME, **has_file_kwargs): @@ -518,7 +515,6 @@ def from_pretrained( "those weights." ) else: - logger.error(err) raise EnvironmentError( f"{pretrained_model_name_or_path} does not appear to have a file named {FLAX_WEIGHTS_NAME} " f"or {WEIGHTS_NAME}." @@ -527,8 +523,7 @@ def from_pretrained( raise EnvironmentError( f"{pretrained_model_name_or_path} does not appear to have a file named {filename}." ) - except HTTPError as err: - logger.error(err) + except HTTPError: raise EnvironmentError( "We couldn't connect to 'https://huggingface.co/' to load this model and it looks like " f"{pretrained_model_name_or_path} is not the path to a directory conaining a a file named " @@ -536,8 +531,7 @@ def from_pretrained( "Checkout your internet connection or see how to run the library in offline mode at " "'https://huggingface.co/docs/transformers/installation#offline-mode'." ) - except EnvironmentError as err: - logger.error(err) + except EnvironmentError: raise EnvironmentError( 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. " diff --git a/src/transformers/modeling_tf_utils.py b/src/transformers/modeling_tf_utils.py index 5e37a1818df8..08ef3536369d 100644 --- a/src/transformers/modeling_tf_utils.py +++ b/src/transformers/modeling_tf_utils.py @@ -1583,23 +1583,20 @@ def from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs): user_agent=user_agent, ) - except RepositoryNotFoundError as err: - logger.error(err) + except RepositoryNotFoundError: raise EnvironmentError( 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 " "token having permission to this repo with `use_auth_token` or log in with `huggingface-cli " "login` and pass `use_auth_token=True`." ) - except RevisionNotFoundError as err: - logger.error(err) + except RevisionNotFoundError: raise EnvironmentError( 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 " f"'https://huggingface.co/{pretrained_model_name_or_path}' for available revisions." ) - except EntryNotFoundError as err: - logger.error(err) + except EntryNotFoundError: if filename == TF2_WEIGHTS_NAME: has_file_kwargs = { "revision": revision, @@ -1614,7 +1611,6 @@ def from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs): "those weights." ) else: - logger.error(err) raise EnvironmentError( f"{pretrained_model_name_or_path} does not appear to have a file named {TF2_WEIGHTS_NAME} " f"or {WEIGHTS_NAME}." @@ -1623,8 +1619,7 @@ def from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs): raise EnvironmentError( f"{pretrained_model_name_or_path} does not appear to have a file named {filename}." ) - except HTTPError as err: - logger.error(err) + except HTTPError: raise EnvironmentError( "We couldn't connect to 'https://huggingface.co/' to load this model and it looks like " f"{pretrained_model_name_or_path} is not the path to a directory conaining a a file named " @@ -1632,8 +1627,7 @@ def from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs): "Checkout your internet connection or see how to run the library in offline mode at " "'https://huggingface.co/docs/transformers/installation#offline-mode'." ) - except EnvironmentError as err: - logger.error(err) + except EnvironmentError: raise EnvironmentError( 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. " diff --git a/src/transformers/modeling_utils.py b/src/transformers/modeling_utils.py index bc93e0616bb4..10a313065b4b 100644 --- a/src/transformers/modeling_utils.py +++ b/src/transformers/modeling_utils.py @@ -1366,23 +1366,20 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P user_agent=user_agent, ) - except RepositoryNotFoundError as err: - logger.error(err) + except RepositoryNotFoundError: raise EnvironmentError( 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 " "token having permission to this repo with `use_auth_token` or log in with `huggingface-cli " "login` and pass `use_auth_token=True`." ) - except RevisionNotFoundError as err: - logger.error(err) + except RevisionNotFoundError: raise EnvironmentError( 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 " f"'https://huggingface.co/{pretrained_model_name_or_path}' for available revisions." ) - except EntryNotFoundError as err: - logger.error(err) + except EntryNotFoundError: if filename == WEIGHTS_NAME: has_file_kwargs = { "revision": revision, @@ -1403,7 +1400,6 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P "weights." ) else: - logger.error(err) raise EnvironmentError( f"{pretrained_model_name_or_path} does not appear to have a file named {WEIGHTS_NAME}, " f"{TF2_WEIGHTS_NAME}, {TF_WEIGHTS_NAME} or {FLAX_WEIGHTS_NAME}." @@ -1412,8 +1408,7 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P raise EnvironmentError( f"{pretrained_model_name_or_path} does not appear to have a file named {filename}." ) - except HTTPError as err: - logger.error(err) + except HTTPError: raise EnvironmentError( "We couldn't connect to 'https://huggingface.co/' to load this model and it looks like " f"{pretrained_model_name_or_path} is not the path to a directory conaining a a file named " @@ -1421,8 +1416,7 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P "Checkout your internet connection or see how to run the library in offline mode at " "'https://huggingface.co/docs/transformers/installation#offline-mode'." ) - except EnvironmentError as err: - logger.error(err) + except EnvironmentError: raise EnvironmentError( 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. " diff --git a/src/transformers/tokenization_utils_base.py b/src/transformers/tokenization_utils_base.py index 27ed8b8984a7..0f3f14c575b6 100644 --- a/src/transformers/tokenization_utils_base.py +++ b/src/transformers/tokenization_utils_base.py @@ -1738,16 +1738,14 @@ def from_pretrained(cls, pretrained_model_name_or_path: Union[str, os.PathLike], else: raise error - except RepositoryNotFoundError as err: - logger.error(err) + except RepositoryNotFoundError: raise EnvironmentError( 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 token having permission to this repo with `use_auth_token` or log in with " "`huggingface-cli login` and pass `use_auth_token=True`." ) - except RevisionNotFoundError as err: - logger.error(err) + except RevisionNotFoundError: raise EnvironmentError( 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 "