Mike Jay commited on
Commit
8772acd
·
1 Parent(s): 8850f30

shows status and data frame stub

Browse files
Files changed (1) hide show
  1. app.py +27 -12
app.py CHANGED
@@ -2,6 +2,7 @@
2
 
3
  import os
4
  import gradio as gr
 
5
 
6
 
7
  def run_and_submit_all(profile: gr.OAuthProfile | None):
@@ -12,12 +13,21 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
12
  else:
13
  print("User not logged in.")
14
  return "Please Login to Hugging Face with the button.", None
15
- return "Status", None
 
 
 
 
 
 
 
 
16
 
17
 
18
  # --- Build Gradio Interface using Blocks ---
19
  with gr.Blocks() as demo:
20
  gr.Markdown("# Basic Agent Evaluation Runner")
 
21
  gr.Markdown(
22
  """
23
  **Instructions:**
@@ -32,25 +42,27 @@ with gr.Blocks() as demo:
32
  This space provides a basic setup and is intentionally sub-optimal to encourage you to develop your own, more robust solution. For instance for the delay process of the submit button, a solution could be to cache the answers and submit in a seperate action or even to answer the questions in async.
33
  """
34
  )
 
35
 
36
  gr.LoginButton()
37
 
38
  run_button = gr.Button("Run Evaluation & Submit All Answers")
39
 
40
- status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
 
 
41
  # Removed max_rows=10 from DataFrame constructor
42
  results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
43
 
44
- run_button.click(
45
- fn=run_and_submit_all,
46
- outputs=[status_output, results_table]
47
  )
48
 
49
  if __name__ == "__main__":
50
- print("\n" + "-"*30 + " App Starting " + "-"*30)
51
  # Check for SPACE_HOST and SPACE_ID at startup for information
52
  space_host_startup = os.getenv("SPACE_HOST")
53
- space_id_startup = os.getenv("SPACE_ID") # Get SPACE_ID at startup
54
 
55
  if space_host_startup:
56
  print(f"✅ SPACE_HOST found: {space_host_startup}")
@@ -58,15 +70,18 @@ if __name__ == "__main__":
58
  else:
59
  print("ℹ️ SPACE_HOST environment variable not found (running locally?).")
60
 
61
- if space_id_startup: # Print repo URLs if SPACE_ID is found
62
  print(f"✅ SPACE_ID found: {space_id_startup}")
63
  print(f" Repo URL: https://huggingface.co/spaces/{space_id_startup}")
64
- print(f" Repo Tree URL: https://huggingface.co/spaces/{space_id_startup}/tree/main")
 
 
65
  else:
66
- print("ℹ️ SPACE_ID environment variable not found (running locally?). Repo URL cannot be determined.")
 
 
67
 
68
- print("-"*(60 + len(" App Starting ")) + "\n")
69
 
70
  print("Launching Gradio Interface for Basic Agent Evaluation...")
71
  demo.launch(debug=True, share=False)
72
-
 
2
 
3
  import os
4
  import gradio as gr
5
+ import pandas as pd
6
 
7
 
8
  def run_and_submit_all(profile: gr.OAuthProfile | None):
 
13
  else:
14
  print("User not logged in.")
15
  return "Please Login to Hugging Face with the button.", None
16
+ return "Status", pd.DataFrame(
17
+ [
18
+ {
19
+ "Task ID": "task_id",
20
+ "Question": "question_text",
21
+ "Submitted Answer": "submitted_answer",
22
+ }
23
+ ]
24
+ )
25
 
26
 
27
  # --- Build Gradio Interface using Blocks ---
28
  with gr.Blocks() as demo:
29
  gr.Markdown("# Basic Agent Evaluation Runner")
30
+ # pylint: disable=line-too-long
31
  gr.Markdown(
32
  """
33
  **Instructions:**
 
42
  This space provides a basic setup and is intentionally sub-optimal to encourage you to develop your own, more robust solution. For instance for the delay process of the submit button, a solution could be to cache the answers and submit in a seperate action or even to answer the questions in async.
43
  """
44
  )
45
+ # pylint: enable=line-too-long
46
 
47
  gr.LoginButton()
48
 
49
  run_button = gr.Button("Run Evaluation & Submit All Answers")
50
 
51
+ status_output = gr.Textbox(
52
+ label="Run Status / Submission Result", lines=5, interactive=False
53
+ )
54
  # Removed max_rows=10 from DataFrame constructor
55
  results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
56
 
57
+ run_button.click( # pylint: disable=no-member
58
+ fn=run_and_submit_all, outputs=[status_output, results_table]
 
59
  )
60
 
61
  if __name__ == "__main__":
62
+ print("\n" + "-" * 30 + " App Starting " + "-" * 30)
63
  # Check for SPACE_HOST and SPACE_ID at startup for information
64
  space_host_startup = os.getenv("SPACE_HOST")
65
+ space_id_startup = os.getenv("SPACE_ID") # Get SPACE_ID at startup
66
 
67
  if space_host_startup:
68
  print(f"✅ SPACE_HOST found: {space_host_startup}")
 
70
  else:
71
  print("ℹ️ SPACE_HOST environment variable not found (running locally?).")
72
 
73
+ if space_id_startup: # Print repo URLs if SPACE_ID is found
74
  print(f"✅ SPACE_ID found: {space_id_startup}")
75
  print(f" Repo URL: https://huggingface.co/spaces/{space_id_startup}")
76
+ print(
77
+ f" Repo Tree URL: https://huggingface.co/spaces/{space_id_startup}/tree/main"
78
+ )
79
  else:
80
+ print(
81
+ "ℹ️ SPACE_ID environment variable not found (running locally?). Repo URL cannot be determined." # pylint: disable=line-too-long
82
+ ) # pylint: disable=line-too-long
83
 
84
+ print("-" * (60 + len(" App Starting ")) + "\n")
85
 
86
  print("Launching Gradio Interface for Basic Agent Evaluation...")
87
  demo.launch(debug=True, share=False)