Fix KeyError when HuggingFace user profile fields are missing (#20)
Handle optional fullname and email fields in user profile gracefully using .get() method with fallback values to prevent KeyError when uploading models to HuggingFace. This fixes an issue where users without a public email or fullname set in their HuggingFace profile would encounter an error during the upload process. Co-authored-by: ricyoung <riyoung@gmail.com>
This commit is contained in:
committed by
GitHub
parent
c8b6663b93
commit
13bb7b24d6
+3
-1
@@ -421,8 +421,10 @@ def run():
|
||||
continue
|
||||
|
||||
user = huggingface_hub.whoami(token)
|
||||
fullname = user.get('fullname', user.get('name', 'Unknown'))
|
||||
email = user.get('email', 'Not provided')
|
||||
print(
|
||||
f"Logged in as [bold]{user['fullname']} ({user['email']})[/]"
|
||||
f"Logged in as [bold]{fullname} ({email})[/]"
|
||||
)
|
||||
|
||||
repo_id = questionary.text(
|
||||
|
||||
Reference in New Issue
Block a user