Update app.py
Browse files
app.py
CHANGED
|
@@ -94,7 +94,26 @@ async def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 94 |
|
| 95 |
username = profile.username if profile else "unknown"
|
| 96 |
submit_url = f"{DEFAULT_API_URL}/submit"
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
try:
|
| 99 |
response = requests.post(submit_url, json=submission_data, timeout=60)
|
| 100 |
response.raise_for_status()
|
|
@@ -108,6 +127,7 @@ async def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 108 |
)
|
| 109 |
results_df = pd.DataFrame(results_log)
|
| 110 |
return final_status, results_df
|
|
|
|
| 111 |
except Exception as e:
|
| 112 |
status_message = f"Submission Failed: {e}"
|
| 113 |
results_df = pd.DataFrame(results_log)
|
|
|
|
| 94 |
|
| 95 |
username = profile.username if profile else "unknown"
|
| 96 |
submit_url = f"{DEFAULT_API_URL}/submit"
|
| 97 |
+
cleaned_answers = []
|
| 98 |
+
for entry in answers_payload:
|
| 99 |
+
if isinstance(entry.get("task_id"), str) and isinstance(entry.get("model_answer"), str):
|
| 100 |
+
cleaned_answers.append(entry)
|
| 101 |
+
else:
|
| 102 |
+
print(f"[WARNING] Skipping invalid answer: {entry}")
|
| 103 |
+
|
| 104 |
+
# ✅ PREPARE SUBMISSION DATA
|
| 105 |
+
submission_data = {
|
| 106 |
+
"username": username.strip(),
|
| 107 |
+
"agent_code": agent_code,
|
| 108 |
+
"answers": cleaned_answers
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
# ✅ DEBUG PRINT
|
| 112 |
+
import json
|
| 113 |
+
print("[DEBUG] Submission Payload:")
|
| 114 |
+
print(json.dumps(submission_data, indent=2))
|
| 115 |
+
|
| 116 |
+
# ✅ SUBMIT
|
| 117 |
try:
|
| 118 |
response = requests.post(submit_url, json=submission_data, timeout=60)
|
| 119 |
response.raise_for_status()
|
|
|
|
| 127 |
)
|
| 128 |
results_df = pd.DataFrame(results_log)
|
| 129 |
return final_status, results_df
|
| 130 |
+
|
| 131 |
except Exception as e:
|
| 132 |
status_message = f"Submission Failed: {e}"
|
| 133 |
results_df = pd.DataFrame(results_log)
|