laverdes commited on
Commit
fa57368
·
verified ·
1 Parent(s): 81917a3

chore: dumping results_log to file

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -3,14 +3,14 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
 
 
6
 
7
- # (Keep Constants as is)
8
- # --- Constants ---
9
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
10
 
11
- # --- Basic Agent Definition ---
12
- # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
13
  class BasicAgent:
 
14
  def __init__(self):
15
  print("BasicAgent initialized.")
16
  def __call__(self, question: str) -> str:
@@ -19,13 +19,14 @@ class BasicAgent:
19
  print(f"Agent returning fixed answer: {fixed_answer}")
20
  return fixed_answer
21
 
 
22
  def run_and_submit_all( profile: gr.OAuthProfile | None):
23
  """
24
  Fetches all questions, runs the BasicAgent on them, submits all answers,
25
  and displays the results.
26
  """
27
- # --- Determine HF Space Runtime URL and Repo URL ---
28
- space_id = os.getenv("SPACE_ID") # Get the SPACE_ID for sending link to the code
29
 
30
  if profile:
31
  username= f"{profile.username}"
@@ -90,6 +91,9 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
90
  if not answers_payload:
91
  print("Agent did not produce any answers to submit.")
92
  return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
 
 
 
93
 
94
  # 4. Prepare Submission
95
  submission_data = {"username": username.strip(), "agent_code": agent_code, "answers": answers_payload}
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ import json
7
+
8
 
 
 
9
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
10
 
11
+
 
12
  class BasicAgent:
13
+ # BUILD OR LOAD HERE
14
  def __init__(self):
15
  print("BasicAgent initialized.")
16
  def __call__(self, question: str) -> str:
 
19
  print(f"Agent returning fixed answer: {fixed_answer}")
20
  return fixed_answer
21
 
22
+
23
  def run_and_submit_all( profile: gr.OAuthProfile | None):
24
  """
25
  Fetches all questions, runs the BasicAgent on them, submits all answers,
26
  and displays the results.
27
  """
28
+
29
+ space_id = os.getenv("SPACE_ID")
30
 
31
  if profile:
32
  username= f"{profile.username}"
 
91
  if not answers_payload:
92
  print("Agent did not produce any answers to submit.")
93
  return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
94
+ else:
95
+ with open("results_log.json", "w") as results_file:
96
+ json.dump(results_log, results_file)
97
 
98
  # 4. Prepare Submission
99
  submission_data = {"username": username.strip(), "agent_code": agent_code, "answers": answers_payload}