[BUGFIX] catch subclass first for try...except (#18672)

Signed-off-by: Andy Xie <andy.xning@gmail.com>
This commit is contained in:
Ning Xie 2025-05-25 13:34:24 +08:00 committed by GitHub
parent 63934543a0
commit 44073a7ac3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -319,6 +319,7 @@ def download_safetensors_index_file_from_hf(
Args:
model_name_or_path (str): The model name or path.
index_file (str): The safetensors index file name
cache_dir (Optional[str]): The cache directory to store the model
weights. If None, will use HF defaults.
revision (Optional[str]): The revision of the model.
@ -337,10 +338,10 @@ def download_safetensors_index_file_from_hf(
)
# If file not found on remote or locally, we should not fail since
# only some models will have index_file.
except huggingface_hub.utils.EntryNotFoundError:
logger.info("No %s found in remote.", index_file)
except huggingface_hub.utils.LocalEntryNotFoundError:
logger.info("No %s found in local cache.", index_file)
except huggingface_hub.utils.EntryNotFoundError:
logger.info("No %s found in remote.", index_file)
# For models like Mistral-7B-v0.3, there are both sharded