Unverified Commit 013a7dbe authored by Nicolas Patry's avatar Nicolas Patry Committed by GitHub
Browse files

Making the impossible to connect error actually report the right URL. (#16446)

parent ad0cba08
...@@ -31,6 +31,7 @@ from . import __version__ ...@@ -31,6 +31,7 @@ from . import __version__
from .dynamic_module_utils import custom_object_save from .dynamic_module_utils import custom_object_save
from .utils import ( from .utils import (
CONFIG_NAME, CONFIG_NAME,
HUGGINGFACE_CO_RESOLVE_ENDPOINT,
EntryNotFoundError, EntryNotFoundError,
PushToHubMixin, PushToHubMixin,
RepositoryNotFoundError, RepositoryNotFoundError,
...@@ -626,7 +627,7 @@ class PretrainedConfig(PushToHubMixin): ...@@ -626,7 +627,7 @@ class PretrainedConfig(PushToHubMixin):
) )
except ValueError: except ValueError:
raise EnvironmentError( raise EnvironmentError(
"We couldn't connect to 'https://huggingface.co/' to load this model, couldn't find it in the cached " f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load this model, couldn't find it in the cached "
f"files and it looks like {pretrained_model_name_or_path} is not the path to a directory containing a " f"files and it looks like {pretrained_model_name_or_path} is not the path to a directory containing a "
"{configuration_file} file.\nCheckout your internet connection or see how to run the library in " "{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'." "offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'."
......
...@@ -29,6 +29,7 @@ from requests import HTTPError ...@@ -29,6 +29,7 @@ from requests import HTTPError
from .dynamic_module_utils import custom_object_save from .dynamic_module_utils import custom_object_save
from .utils import ( from .utils import (
FEATURE_EXTRACTOR_NAME, FEATURE_EXTRACTOR_NAME,
HUGGINGFACE_CO_RESOLVE_ENDPOINT,
EntryNotFoundError, EntryNotFoundError,
PushToHubMixin, PushToHubMixin,
RepositoryNotFoundError, RepositoryNotFoundError,
...@@ -433,7 +434,7 @@ class FeatureExtractionMixin(PushToHubMixin): ...@@ -433,7 +434,7 @@ class FeatureExtractionMixin(PushToHubMixin):
) )
except ValueError: except ValueError:
raise EnvironmentError( raise EnvironmentError(
"We couldn't connect to 'https://huggingface.co/' to load this model, couldn't find it in the cached " f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load this model, couldn't find it in the cached "
f"files and it looks like {pretrained_model_name_or_path} is not the path to a directory containing a " f"files and it looks like {pretrained_model_name_or_path} is not the path to a directory containing a "
f"{FEATURE_EXTRACTOR_NAME} file.\nCheckout your internet connection or see how to run the library in " 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'." "offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'."
......
...@@ -34,6 +34,7 @@ from .generation_flax_utils import FlaxGenerationMixin ...@@ -34,6 +34,7 @@ from .generation_flax_utils import FlaxGenerationMixin
from .modeling_flax_pytorch_utils import load_pytorch_checkpoint_in_flax_state_dict from .modeling_flax_pytorch_utils import load_pytorch_checkpoint_in_flax_state_dict
from .utils import ( from .utils import (
FLAX_WEIGHTS_NAME, FLAX_WEIGHTS_NAME,
HUGGINGFACE_CO_RESOLVE_ENDPOINT,
WEIGHTS_NAME, WEIGHTS_NAME,
EntryNotFoundError, EntryNotFoundError,
PushToHubMixin, PushToHubMixin,
...@@ -530,7 +531,7 @@ class FlaxPreTrainedModel(PushToHubMixin, FlaxGenerationMixin): ...@@ -530,7 +531,7 @@ class FlaxPreTrainedModel(PushToHubMixin, FlaxGenerationMixin):
) )
except ValueError: except ValueError:
raise EnvironmentError( raise EnvironmentError(
"We couldn't connect to 'https://huggingface.co/' to load this model, couldn't find it in the cached " f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load this model, couldn't find it in the cached "
f"files and it looks like {pretrained_model_name_or_path} is not the path to a directory " f"files and it looks like {pretrained_model_name_or_path} is not the path to a directory "
f"containing a file named {FLAX_WEIGHTS_NAME} or {WEIGHTS_NAME}.\n" f"containing a file named {FLAX_WEIGHTS_NAME} or {WEIGHTS_NAME}.\n"
"Checkout your internet connection or see how to run the library in offline mode at " "Checkout your internet connection or see how to run the library in offline mode at "
......
...@@ -43,6 +43,7 @@ from .tf_utils import shape_list ...@@ -43,6 +43,7 @@ from .tf_utils import shape_list
from .tokenization_utils_base import BatchEncoding from .tokenization_utils_base import BatchEncoding
from .utils import ( from .utils import (
DUMMY_INPUTS, DUMMY_INPUTS,
HUGGINGFACE_CO_RESOLVE_ENDPOINT,
TF2_WEIGHTS_NAME, TF2_WEIGHTS_NAME,
WEIGHTS_NAME, WEIGHTS_NAME,
EntryNotFoundError, EntryNotFoundError,
...@@ -1685,7 +1686,7 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu ...@@ -1685,7 +1686,7 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
) )
except ValueError: except ValueError:
raise EnvironmentError( raise EnvironmentError(
"We couldn't connect to 'https://huggingface.co/' to load this model, couldn't find it in the cached " f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load this model, couldn't find it in the cached "
f"files and it looks like {pretrained_model_name_or_path} is not the path to a directory " f"files and it looks like {pretrained_model_name_or_path} is not the path to a directory "
f"containing a file named {TF2_WEIGHTS_NAME} or {WEIGHTS_NAME}.\n" f"containing a file named {TF2_WEIGHTS_NAME} or {WEIGHTS_NAME}.\n"
"Checkout your internet connection or see how to run the library in offline mode at " "Checkout your internet connection or see how to run the library in offline mode at "
......
...@@ -40,6 +40,7 @@ from .generation_utils import GenerationMixin ...@@ -40,6 +40,7 @@ from .generation_utils import GenerationMixin
from .utils import ( from .utils import (
DUMMY_INPUTS, DUMMY_INPUTS,
FLAX_WEIGHTS_NAME, FLAX_WEIGHTS_NAME,
HUGGINGFACE_CO_RESOLVE_ENDPOINT,
TF2_WEIGHTS_NAME, TF2_WEIGHTS_NAME,
TF_WEIGHTS_NAME, TF_WEIGHTS_NAME,
WEIGHTS_INDEX_NAME, WEIGHTS_INDEX_NAME,
...@@ -331,7 +332,7 @@ def get_checkpoint_shard_files( ...@@ -331,7 +332,7 @@ def get_checkpoint_shard_files(
) )
except HTTPError: except HTTPError:
raise EnvironmentError( raise EnvironmentError(
f"We couldn't connect to 'https://huggingface.co/' to load {shard_filename}. You should try again " f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load {shard_filename}. You should try again "
"after checking your internet connection." "after checking your internet connection."
) )
...@@ -1749,7 +1750,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix ...@@ -1749,7 +1750,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
) )
except ValueError: except ValueError:
raise EnvironmentError( raise EnvironmentError(
"We couldn't connect to 'https://huggingface.co/' to load this model, couldn't find it in the cached " f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load this model, couldn't find it in the cached "
f"files and it looks like {pretrained_model_name_or_path} is not the path to a directory " f"files and it looks like {pretrained_model_name_or_path} is not the path to a directory "
f"containing a file named {WEIGHTS_NAME}, {TF2_WEIGHTS_NAME}, {TF_WEIGHTS_NAME} or " f"containing a file named {WEIGHTS_NAME}, {TF2_WEIGHTS_NAME}, {TF_WEIGHTS_NAME} or "
f"{FLAX_WEIGHTS_NAME}.\n" f"{FLAX_WEIGHTS_NAME}.\n"
......
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