Update app.py
Browse files
app.py
CHANGED
|
@@ -374,15 +374,46 @@ def submit_answers(base_api_url: str, username: str, agent_code_url: str, answer
|
|
| 374 |
# --- Gradio Interface Main Function ---
|
| 375 |
GLOBAL_CHUCK_AGENT: Optional[ChuckAgent] = None
|
| 376 |
|
| 377 |
-
|
|
|
|
|
|
|
| 378 |
global GLOBAL_CHUCK_AGENT
|
| 379 |
-
logger.info(f"run_and_submit_all_evaluation called. Profile: {profile.username if profile else 'None'}")
|
| 380 |
|
| 381 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 382 |
logger.warning("User not logged in for evaluation.")
|
| 383 |
return "Please Login to Hugging Face with the button to run the evaluation.", pd.DataFrame()
|
| 384 |
|
| 385 |
username = profile.username
|
|
|
|
| 386 |
logger.info(f"User logged in: {username}")
|
| 387 |
|
| 388 |
_, agent_code_url = get_space_id_agent_code_url()
|
|
|
|
| 374 |
# --- Gradio Interface Main Function ---
|
| 375 |
GLOBAL_CHUCK_AGENT: Optional[ChuckAgent] = None
|
| 376 |
|
| 377 |
+
# MODIFIED: Added *args to catch unexpected additional arguments
|
| 378 |
+
# and ensure 'profile' is keyword-or-positional
|
| 379 |
+
def run_and_submit_all_evaluation(profile: Optional[gr.OAuthProfile] = None, *args) -> Tuple[str, pd.DataFrame]:
|
| 380 |
global GLOBAL_CHUCK_AGENT
|
|
|
|
| 381 |
|
| 382 |
+
# Log what was actually received
|
| 383 |
+
logger.info(f"run_and_submit_all_evaluation received profile: {type(profile)}")
|
| 384 |
+
if args:
|
| 385 |
+
logger.warning(f"run_and_submit_all_evaluation received unexpected additional args: {args}")
|
| 386 |
+
|
| 387 |
+
# The actual profile data should come from the named 'profile' argument
|
| 388 |
+
# due to the 'inputs=[login_button]' mapping.
|
| 389 |
+
# If 'profile' is None here but args contains something, it's an issue.
|
| 390 |
+
|
| 391 |
+
if not isinstance(profile, gr.OAuthProfile) and profile is not None:
|
| 392 |
+
# This can happen if Gradio passes something unexpected as the first argument.
|
| 393 |
+
# We could try to see if the profile is in args, but it should be the named parameter.
|
| 394 |
+
logger.warning(f"Profile argument is not of type gr.OAuthProfile or None. Received: {profile}")
|
| 395 |
+
# Attempt to find the profile in args if it was misplaced
|
| 396 |
+
found_profile_in_args = False
|
| 397 |
+
for arg in args:
|
| 398 |
+
if isinstance(arg, gr.OAuthProfile):
|
| 399 |
+
profile = arg
|
| 400 |
+
found_profile_in_args = True
|
| 401 |
+
logger.info(f"Found gr.OAuthProfile in *args: {profile.username if profile else 'None (from args)'}")
|
| 402 |
+
break
|
| 403 |
+
if not found_profile_in_args and profile is None: # if profile was not None but wrong type, it will still fail below
|
| 404 |
+
logger.error("Could not identify a valid gr.OAuthProfile object.")
|
| 405 |
+
return "Login error: Could not identify user profile.", pd.DataFrame()
|
| 406 |
+
|
| 407 |
+
|
| 408 |
+
logger.info(f"Effective profile for processing: {profile.username if profile else 'None'}")
|
| 409 |
+
|
| 410 |
+
|
| 411 |
+
if not profile: # This check remains important
|
| 412 |
logger.warning("User not logged in for evaluation.")
|
| 413 |
return "Please Login to Hugging Face with the button to run the evaluation.", pd.DataFrame()
|
| 414 |
|
| 415 |
username = profile.username
|
| 416 |
+
# ... rest of your function code ...
|
| 417 |
logger.info(f"User logged in: {username}")
|
| 418 |
|
| 419 |
_, agent_code_url = get_space_id_agent_code_url()
|