Spaces:
Sleeping
Sleeping
Remove retry logic
Browse files
app.py
CHANGED
|
@@ -134,36 +134,17 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 134 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
| 135 |
print(agent_code)
|
| 136 |
|
| 137 |
-
# 2. Fetch Questions
|
| 138 |
-
import time
|
| 139 |
print(f"Fetching questions from: {questions_url}")
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
response.raise_for_status()
|
| 150 |
-
questions_data = response.json()
|
| 151 |
-
break
|
| 152 |
-
except requests.exceptions.HTTPError as e:
|
| 153 |
-
if e.response.status_code == 429:
|
| 154 |
-
wait = 30 * (attempt + 1)
|
| 155 |
-
print(f"Rate limited (429). Waiting {wait}s before retry {attempt+1}/5...")
|
| 156 |
-
time.sleep(wait)
|
| 157 |
-
else:
|
| 158 |
-
return f"Error fetching questions: {e}", None
|
| 159 |
-
except Exception as e:
|
| 160 |
-
return f"Error fetching questions: {e}", None
|
| 161 |
-
|
| 162 |
-
if questions_data is None:
|
| 163 |
-
return "Error: Still rate limited after multiple retries. Please wait a few minutes and try again.", None
|
| 164 |
-
if not questions_data:
|
| 165 |
-
return "Fetched questions list is empty or invalid format.", None
|
| 166 |
-
print(f"Fetched {len(questions_data)} questions.")
|
| 167 |
|
| 168 |
# 3. Run Agent
|
| 169 |
results_log = []
|
|
|
|
| 134 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
| 135 |
print(agent_code)
|
| 136 |
|
| 137 |
+
# 2. Fetch Questions
|
|
|
|
| 138 |
print(f"Fetching questions from: {questions_url}")
|
| 139 |
+
try:
|
| 140 |
+
response = requests.get(questions_url, timeout=15)
|
| 141 |
+
response.raise_for_status()
|
| 142 |
+
questions_data = response.json()
|
| 143 |
+
if not questions_data:
|
| 144 |
+
return "Fetched questions list is empty or invalid format.", None
|
| 145 |
+
print(f"Fetched {len(questions_data)} questions.")
|
| 146 |
+
except Exception as e:
|
| 147 |
+
return f"Error fetching questions: {e}", None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
|
| 149 |
# 3. Run Agent
|
| 150 |
results_log = []
|