yoshizen commited on
Commit
f90ebe6
·
verified ·
1 Parent(s): 7c24851

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -31
app.py CHANGED
@@ -235,25 +235,37 @@ class EvaluationRunner:
235
 
236
  return results_log, answers_payload
237
 
238
- def _submit_answers(self,
239
- username: str,
240
- agent_code_url: str,
241
- answers_payload: List[Dict[str, Any]]) -> str:
242
- """Submit answers to the evaluation server."""
243
- submission_data = {
244
- "username": username.strip(),
245
- "agent_code": agent_code_url,
246
- "answers": answers_payload
247
- }
248
-
249
- status_update = f"Agent finished. Submitting {len(answers_payload)} answers for user '{username}'..."
250
- print(status_update)
 
 
251
 
252
- try:
253
- response = requests.post(self.submit_url, json=submission_data, timeout=60)
254
- response.raise_for_status()
255
- result_data = response.json()
256
-
 
 
 
 
 
 
 
 
 
 
257
  final_status = (
258
  f"Submission Successful!\n"
259
  f"User: {result_data.get('username')}\n"
@@ -261,19 +273,18 @@ class EvaluationRunner:
261
  f"Correct Answers: {result_data.get('correct_answers', 'N/A')}\n"
262
  f"Total Questions: {result_data.get('total_questions', 'N/A')}\n"
263
  )
264
- print(final_status)
265
- return final_status
266
-
267
- except requests.exceptions.RequestException as e:
268
- error_msg = f"Error submitting answers: {e}"
269
- print(error_msg)
270
- return error_msg
271
-
272
- except Exception as e:
273
- error_msg = f"An unexpected error occurred during submission: {e}"
274
- print(error_msg)
275
- return error_msg
276
-
277
 
278
  def run_and_submit_all(profile: gr.OAuthProfile | None, *args):
279
  """
 
235
 
236
  return results_log, answers_payload
237
 
238
+ def _submit_answers(self, username: str, agent_code_url: str, answers_payload: List[Dict[str, Any]]) -> str:
239
+ """Submit answers to the evaluation server."""
240
+ submission_data = {
241
+ "username": username.strip(),
242
+ "agent_code": agent_code_url,
243
+ "answers": answers_payload
244
+ }
245
+
246
+ status_update = f"Agent finished. Submitting {len(answers_payload)} answers for user '{username}'..."
247
+ print(status_update)
248
+
249
+ try:
250
+ response = requests.post(self.submit_url, json=submission_data, timeout=60)
251
+ response.raise_for_status()
252
+ result_data = response.json()
253
 
254
+ # Проверка наличия результатов оценки
255
+ if all(result_data.get(key, "N/A") == "N/A" for key in ["overall_score", "correct_answers", "total_questions"]):
256
+ # Если все значения N/A, добавляем информацию о возможной проблеме
257
+ final_status = (
258
+ f"Submission Successful!\n"
259
+ f"User: {result_data.get('username')}\n"
260
+ f"Overall Score: {result_data.get('overall_score', 'N/A')}\n"
261
+ f"Correct Answers: {result_data.get('correct_answers', 'N/A')}\n"
262
+ f"Total Questions: {result_data.get('total_questions', 'N/A')}\n\n"
263
+ f"Note: Results show N/A. This might be due to:\n"
264
+ f"1. Temporary delay in processing\n"
265
+ f"2. API evaluation service issue\n"
266
+ f"Please try again in a few minutes or check the course forum for updates."
267
+ )
268
+ else:
269
  final_status = (
270
  f"Submission Successful!\n"
271
  f"User: {result_data.get('username')}\n"
 
273
  f"Correct Answers: {result_data.get('correct_answers', 'N/A')}\n"
274
  f"Total Questions: {result_data.get('total_questions', 'N/A')}\n"
275
  )
276
+ print(final_status)
277
+ return final_status
278
+
279
+ except requests.exceptions.RequestException as e:
280
+ error_msg = f"Error submitting answers: {e}"
281
+ print(error_msg)
282
+ return error_msg
283
+
284
+ except Exception as e:
285
+ error_msg = f"An unexpected error occurred during submission: {e}"
286
+ print(error_msg)
287
+ return error_msg
 
288
 
289
  def run_and_submit_all(profile: gr.OAuthProfile | None, *args):
290
  """