|  | 
| 30 | 30 |     ModelCardData, | 
| 31 | 31 |     create_repo, | 
| 32 | 32 |     hf_hub_download, | 
| 33 |  | -    model_info, | 
| 34 | 33 |     snapshot_download, | 
| 35 | 34 |     upload_folder, | 
| 36 | 35 | ) | 
| @@ -403,28 +402,19 @@ def _get_checkpoint_shard_files( | 
| 403 | 402 |         allow_patterns = [os.path.join(subfolder, p) for p in allow_patterns] | 
| 404 | 403 | 
 | 
| 405 | 404 |     ignore_patterns = ["*.json", "*.md"] | 
| 406 |  | -    # `model_info` call must guarded with the above condition. | 
| 407 |  | -    local = False | 
| 408 |  | -    if local_files_only: | 
|  | 405 | +    try: | 
| 409 | 406 |         temp_dir = snapshot_download( | 
| 410 | 407 |             repo_id=pretrained_model_name_or_path, cache_dir=cache_dir, local_files_only=local_files_only | 
| 411 | 408 |         ) | 
| 412 |  | -        model_files_info = _get_filepaths_for_folder(temp_dir) | 
| 413 |  | -        local = True | 
| 414 |  | -    else: | 
| 415 |  | -        try: | 
| 416 |  | -            model_files_info = model_info(pretrained_model_name_or_path, revision=revision, token=token) | 
| 417 |  | -        except ConnectionError as e: | 
| 418 |  | -            raise EnvironmentError( | 
| 419 |  | -                f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load {pretrained_model_name_or_path}. You should try" | 
| 420 |  | -                " again after checking your internet connection." | 
| 421 |  | -            ) from e | 
|  | 409 | +    except ConnectionError as e: | 
|  | 410 | +        raise EnvironmentError( | 
|  | 411 | +            f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load {pretrained_model_name_or_path}. You should try" | 
|  | 412 | +            " again after checking your internet connection." | 
|  | 413 | +        ) from e | 
| 422 | 414 | 
 | 
|  | 415 | +    model_files_info = _get_filepaths_for_folder(temp_dir) | 
| 423 | 416 |     for shard_file in original_shard_filenames: | 
| 424 |  | -        if local: | 
| 425 |  | -            shard_file_present = any(shard_file in k for k in model_files_info) | 
| 426 |  | -        else: | 
| 427 |  | -            shard_file_present = any(shard_file in k.rfilename for k in model_files_info.siblings) | 
|  | 417 | +        shard_file_present = any(shard_file in k for k in model_files_info) | 
| 428 | 418 |         if not shard_file_present: | 
| 429 | 419 |             raise EnvironmentError( | 
| 430 | 420 |                 f"{shards_path} does not appear to have a file named {shard_file} which is " | 
|  | 
0 commit comments