Update app.py
Browse files
app.py
CHANGED
|
@@ -171,43 +171,33 @@ def evaluate_single_case(input_data):
|
|
| 171 |
return {"status": "Exception", "error": "Input item must be a dictionary"}
|
| 172 |
|
| 173 |
language = input_data.get('language')
|
| 174 |
-
|
| 175 |
|
| 176 |
-
if
|
| 177 |
return {"status": "Exception", "error": "No code provided"}
|
| 178 |
|
| 179 |
# Use a retry mechanism for all languages for better reliability
|
| 180 |
max_retries = 2 # One retry for all languages
|
| 181 |
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
|
|
|
| 185 |
|
| 186 |
-
#
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
time.sleep(0.3)
|
| 195 |
-
|
| 196 |
-
status_list.append(result["status"])
|
| 197 |
-
stderr_list.append(result["stderr"])
|
| 198 |
-
|
| 199 |
-
processed_completions = input_data.pop('processed_completions', [])
|
| 200 |
-
completions = input_data.pop('completions', [])
|
| 201 |
|
| 202 |
-
meta_data =
|
| 203 |
-
|
| 204 |
-
'processed_completion': p_comp,
|
| 205 |
-
'completion': comp,
|
| 206 |
'status': status,
|
| 207 |
'stderr': stderr
|
| 208 |
}
|
| 209 |
-
for p_comp, comp, status, stderr in zip(processed_completions, completions, status_list, stderr_list)
|
| 210 |
-
]
|
| 211 |
|
| 212 |
input_data['meta_data'] = meta_data
|
| 213 |
return input_data
|
|
|
|
| 171 |
return {"status": "Exception", "error": "Input item must be a dictionary"}
|
| 172 |
|
| 173 |
language = input_data.get('language')
|
| 174 |
+
code = input_data.get('code', "")
|
| 175 |
|
| 176 |
+
if code == "":
|
| 177 |
return {"status": "Exception", "error": "No code provided"}
|
| 178 |
|
| 179 |
# Use a retry mechanism for all languages for better reliability
|
| 180 |
max_retries = 2 # One retry for all languages
|
| 181 |
|
| 182 |
+
# Try up to max_retries times for all test cases
|
| 183 |
+
status, stderr = "", ""
|
| 184 |
+
for attempt in range(max_retries):
|
| 185 |
+
result = evaluate_code(code, language)
|
| 186 |
|
| 187 |
+
# If success or last attempt, return/record the result
|
| 188 |
+
if result["status"] == "OK":
|
| 189 |
+
break
|
| 190 |
+
# For retries, briefly wait to allow resources to stabilize
|
| 191 |
+
time.sleep(0.3)
|
| 192 |
+
|
| 193 |
+
status = result["status"]
|
| 194 |
+
stderr = result["stderr"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
|
| 196 |
+
meta_data = {
|
| 197 |
+
'code': code,
|
|
|
|
|
|
|
| 198 |
'status': status,
|
| 199 |
'stderr': stderr
|
| 200 |
}
|
|
|
|
|
|
|
| 201 |
|
| 202 |
input_data['meta_data'] = meta_data
|
| 203 |
return input_data
|