Alvinn-aai commited on
Commit
a992256
·
1 Parent(s): 7722634

improve ui, error handling

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -90,22 +90,21 @@ def add_solution_cbk(
90
  if profile is None or token is None:
91
  return styled_error("Please sign in with Hugging Face before submitting.")
92
 
93
- # Display handle and display name (good for the UI)
94
  handle = profile.username
95
  logger.info(f"User handle: {handle}")
96
  display_name = profile.name or handle
97
  logger.info(f"Displaying name: {display_name}")
98
 
99
- # Optional: verify handle/orgs via Hub API
100
- info = whoami(token.token) # {'name': 'user', 'orgs': [{'name': 'org1'}, ...], ...}
101
- logger.info(f"User info: {info}")
102
-
103
- # Stable account id (for dedup, enforcement, joins)
104
  claims = fetch_sub_claim(token) or {}
105
  logger.info(f"Claims: {claims}")
106
  stable_id = claims.get("sub")
107
  logger.info(f"User stable ID: {stable_id}")
108
 
 
 
 
109
  try:
110
  # Validating the submission file.
111
  if len(submission_path) == 0:
@@ -218,7 +217,6 @@ with blocks:
218
  submit_panel = gr.Group(visible=False)
219
  with submit_panel:
220
  with gr.Row():
221
- status_line = gr.Markdown() # "Signed in as @user"
222
  with gr.Column():
223
  system_name_textbox = gr.Textbox(label=AutoEvalColumn.system.name)
224
  org_textbox = gr.Textbox(label=AutoEvalColumn.organization.name)
 
90
  if profile is None or token is None:
91
  return styled_error("Please sign in with Hugging Face before submitting.")
92
 
93
+ # Display handle and display name (may change over time)
94
  handle = profile.username
95
  logger.info(f"User handle: {handle}")
96
  display_name = profile.name or handle
97
  logger.info(f"Displaying name: {display_name}")
98
 
99
+ # Stable account id
 
 
 
 
100
  claims = fetch_sub_claim(token) or {}
101
  logger.info(f"Claims: {claims}")
102
  stable_id = claims.get("sub")
103
  logger.info(f"User stable ID: {stable_id}")
104
 
105
+ if not stable_id:
106
+ return styled_error("Could not retrieve your stable user ID. Please try signing in again.")
107
+
108
  try:
109
  # Validating the submission file.
110
  if len(submission_path) == 0:
 
217
  submit_panel = gr.Group(visible=False)
218
  with submit_panel:
219
  with gr.Row():
 
220
  with gr.Column():
221
  system_name_textbox = gr.Textbox(label=AutoEvalColumn.system.name)
222
  org_textbox = gr.Textbox(label=AutoEvalColumn.organization.name)