File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4545)
4646from packaging import version
4747from requests import HTTPError
48+ from requests .exceptions import ConnectionError
4849
4950from .. import __version__
5051from .constants import (
@@ -407,13 +408,18 @@ def _get_checkpoint_shard_files(
407408 local = False
408409 try :
409410 model_files_info = model_info (pretrained_model_name_or_path , revision = revision , token = token )
410- except HTTPError :
411+ except ConnectionError as e :
411412 if local_files_only :
412413 temp_dir = snapshot_download (
413414 repo_id = pretrained_model_name_or_path , cache_dir = cache_dir , local_files_only = local_files_only
414415 )
415416 model_files_info = _get_filepaths_for_folder (temp_dir )
416417 local = True
418+ else :
419+ raise EnvironmentError (
420+ f"We couldn't connect to '{ HUGGINGFACE_CO_RESOLVE_ENDPOINT } ' to load { pretrained_model_name_or_path } . You should try"
421+ " again after checking your internet connection."
422+ ) from e
417423 for shard_file in original_shard_filenames :
418424 if local :
419425 shard_file_present = any (shard_file in k for k in model_files_info )
You can’t perform that action at this time.
0 commit comments