QiaoXin999 commited on
Commit
24bb2cc
·
verified ·
1 Parent(s): 2147246

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -3
app.py CHANGED
@@ -7,7 +7,7 @@ import spaces
7
  import json
8
  import torch
9
  import re
10
-
11
  from pathlib import Path
12
  from typing import Literal, TypedDict
13
 
@@ -54,7 +54,7 @@ def zero_gpu_check():
54
  # Persistent Hugging Face Cache
55
  # ============================================================
56
 
57
- CACHE_VERSION = "v2"
58
 
59
  CACHE_FILE_NAME = "gaia_answer_cache.json"
60
 
@@ -1623,7 +1623,45 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
1623
  # 5. Submit
1624
  print(f"Submitting {len(answers_payload)} answers to: {submit_url}")
1625
  try:
1626
- response = requests.post(submit_url, json=submission_data, timeout=60)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1627
  response.raise_for_status()
1628
  result_data = response.json()
1629
  final_status = (
 
7
  import json
8
  import torch
9
  import re
10
+ import time
11
  from pathlib import Path
12
  from typing import Literal, TypedDict
13
 
 
54
  # Persistent Hugging Face Cache
55
  # ============================================================
56
 
57
+ CACHE_VERSION = "v3"
58
 
59
  CACHE_FILE_NAME = "gaia_answer_cache.json"
60
 
 
1623
  # 5. Submit
1624
  print(f"Submitting {len(answers_payload)} answers to: {submit_url}")
1625
  try:
1626
+ response = None
1627
+
1628
+ for attempt in range(3):
1629
+
1630
+ try:
1631
+ response = requests.post(
1632
+ submit_url,
1633
+ json=submission_data,
1634
+ timeout=90,
1635
+ )
1636
+
1637
+ # Success or normal client error
1638
+ if response.status_code < 500:
1639
+ break
1640
+
1641
+ print(
1642
+ f"Scoring server returned "
1643
+ f"{response.status_code}. "
1644
+ f"Retrying..."
1645
+ )
1646
+
1647
+ except requests.exceptions.RequestException as error:
1648
+ print(
1649
+ f"Submission attempt failed: "
1650
+ f"{error}"
1651
+ )
1652
+
1653
+ # 2 sec, then 5 sec
1654
+ if attempt == 0:
1655
+ time.sleep(2)
1656
+ elif attempt == 1:
1657
+ time.sleep(5)
1658
+
1659
+
1660
+ if response is None:
1661
+ raise RuntimeError(
1662
+ "Could not reach scoring server."
1663
+ )
1664
+
1665
  response.raise_for_status()
1666
  result_data = response.json()
1667
  final_status = (