Spaces:
Sleeping
Sleeping
Ajout debug dans app
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ import json
|
|
| 11 |
# --- Constants ---
|
| 12 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 13 |
|
| 14 |
-
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 15 |
"""
|
| 16 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
| 17 |
and displays the results.
|
|
@@ -65,7 +65,17 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 65 |
results_log = []
|
| 66 |
answers_payload = []
|
| 67 |
print(f"Running agent on {len(questions_data)} questions...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
for item in questions_data:
|
|
|
|
|
|
|
|
|
|
| 69 |
task_id = item.get("task_id")
|
| 70 |
question_text = item.get("question")
|
| 71 |
if not task_id or question_text is None:
|
|
@@ -157,6 +167,7 @@ with gr.Blocks() as demo:
|
|
| 157 |
gr.LoginButton()
|
| 158 |
|
| 159 |
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
|
|
|
| 160 |
|
| 161 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
| 162 |
# Removed max_rows=10 from DataFrame constructor
|
|
@@ -164,6 +175,12 @@ with gr.Blocks() as demo:
|
|
| 164 |
|
| 165 |
run_button.click(
|
| 166 |
fn=run_and_submit_all,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
outputs=[status_output, results_table]
|
| 168 |
)
|
| 169 |
|
|
|
|
| 11 |
# --- Constants ---
|
| 12 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 13 |
|
| 14 |
+
def run_and_submit_all( profile: gr.OAuthProfile | None, question_limit: int | None = None):
|
| 15 |
"""
|
| 16 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
| 17 |
and displays the results.
|
|
|
|
| 65 |
results_log = []
|
| 66 |
answers_payload = []
|
| 67 |
print(f"Running agent on {len(questions_data)} questions...")
|
| 68 |
+
limit = None
|
| 69 |
+
if question_limit is not None:
|
| 70 |
+
try:
|
| 71 |
+
limit = max(1, int(question_limit))
|
| 72 |
+
except:
|
| 73 |
+
print("Invalid question limit")
|
| 74 |
+
count = 0
|
| 75 |
for item in questions_data:
|
| 76 |
+
if limit is not None and count >= limit:
|
| 77 |
+
break
|
| 78 |
+
count += 1
|
| 79 |
task_id = item.get("task_id")
|
| 80 |
question_text = item.get("question")
|
| 81 |
if not task_id or question_text is None:
|
|
|
|
| 167 |
gr.LoginButton()
|
| 168 |
|
| 169 |
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
| 170 |
+
run_button_check = gr.Button("Run only the first question to check that everything works")
|
| 171 |
|
| 172 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
| 173 |
# Removed max_rows=10 from DataFrame constructor
|
|
|
|
| 175 |
|
| 176 |
run_button.click(
|
| 177 |
fn=run_and_submit_all,
|
| 178 |
+
inputs=[gr.State(20)],
|
| 179 |
+
outputs=[status_output, results_table]
|
| 180 |
+
)
|
| 181 |
+
run_button_check.click(
|
| 182 |
+
fn=run_and_submit_all,
|
| 183 |
+
intputs=[gr.State(1)],
|
| 184 |
outputs=[status_output, results_table]
|
| 185 |
)
|
| 186 |
|