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__
from .dynamic_module_utils import custom_object_save
from .utils import (
CONFIG_NAME,
HUGGINGFACE_CO_RESOLVE_ENDPOINT,
EntryNotFoundError,
PushToHubMixin,
RepositoryNotFoundError,
......@@ -626,7 +627,7 @@ class PretrainedConfig(PushToHubMixin):
)
except ValueError:
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 "
"{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'."
......
......@@ -29,6 +29,7 @@ from requests import HTTPError
from .dynamic_module_utils import custom_object_save
from .utils import (
FEATURE_EXTRACTOR_NAME,
HUGGINGFACE_CO_RESOLVE_ENDPOINT,
EntryNotFoundError,
PushToHubMixin,
RepositoryNotFoundError,
......@@ -433,7 +434,7 @@ class FeatureExtractionMixin(PushToHubMixin):
)
except ValueError:
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"{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'."
......
......@@ -34,6 +34,7 @@ from .generation_flax_utils import FlaxGenerationMixin
from .modeling_flax_pytorch_utils import load_pytorch_checkpoint_in_flax_state_dict
from .utils import (
FLAX_WEIGHTS_NAME,
HUGGINGFACE_CO_RESOLVE_ENDPOINT,
WEIGHTS_NAME,
EntryNotFoundError,
PushToHubMixin,
......@@ -530,7 +531,7 @@ class FlaxPreTrainedModel(PushToHubMixin, FlaxGenerationMixin):
)
except ValueError:
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"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 "
......
......@@ -43,6 +43,7 @@ from .tf_utils import shape_list
from .tokenization_utils_base import BatchEncoding
from .utils import (
DUMMY_INPUTS,
HUGGINGFACE_CO_RESOLVE_ENDPOINT,
TF2_WEIGHTS_NAME,
WEIGHTS_NAME,
EntryNotFoundError,
......@@ -1685,7 +1686,7 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
)
except ValueError:
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"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 "
......
......@@ -40,6 +40,7 @@ from .generation_utils import GenerationMixin
from .utils import (
DUMMY_INPUTS,
FLAX_WEIGHTS_NAME,
HUGGINGFACE_CO_RESOLVE_ENDPOINT,
TF2_WEIGHTS_NAME,
TF_WEIGHTS_NAME,
WEIGHTS_INDEX_NAME,
......@@ -331,7 +332,7 @@ def get_checkpoint_shard_files(
)
except HTTPError:
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."
)
......@@ -1749,7 +1750,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
)
except ValueError:
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"containing a file named {WEIGHTS_NAME}, {TF2_WEIGHTS_NAME}, {TF_WEIGHTS_NAME} or "
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