fix: handle connection errors when checking user whoami (#3529)

This commit is contained in:
Wing Lian
2026-03-22 09:11:17 -04:00
committed by GitHub
parent fc3b3d1d4e
commit 5b2e3f00ce

View File

@@ -3,6 +3,7 @@
import os import os
from pathlib import Path from pathlib import Path
import httpcore
from accelerate.commands.config import config_args from accelerate.commands.config import config_args
from huggingface_hub import HfApi from huggingface_hub import HfApi
from huggingface_hub.utils import LocalTokenNotFoundError from huggingface_hub.utils import LocalTokenNotFoundError
@@ -47,7 +48,7 @@ def check_user_token() -> bool:
"Error verifying HuggingFace token. Remember to log in using `hf auth login` and get your access token from https://huggingface.co/settings/tokens if you want to use gated models or datasets." "Error verifying HuggingFace token. Remember to log in using `hf auth login` and get your access token from https://huggingface.co/settings/tokens if you want to use gated models or datasets."
) )
return False return False
except HTTPError: except (HTTPError, httpcore.ConnectError):
LOG.warning( LOG.warning(
"Error accessing HuggingFace. This may be due to a network issue or rate limiting." "Error accessing HuggingFace. This may be due to a network issue or rate limiting."
) )