tuan3335 commited on
Commit
085f277
·
1 Parent(s): a46949a

🔧 Refactor app.py: remove login button and simplify run function

Browse files
Files changed (1) hide show
  1. app.py +4 -13
app.py CHANGED
@@ -34,14 +34,9 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
34
  and displays the results.
35
  """
36
  # Determine HF Space Runtime URL and Repo URL
37
- space_id = os.getenv("SPACE_ID")
38
-
39
- if profile:
40
- username = profile.username
41
- print(f"User logged in: {username}")
42
- else:
43
- print("User not logged in.")
44
- return "Please Login to Hugging Face with the button.", None
45
 
46
  api_url = DEFAULT_API_URL
47
  questions_url = f"{api_url}/questions"
@@ -114,19 +109,15 @@ with gr.Blocks() as demo:
114
  """
115
  **Instructions:**
116
 
117
- 1. Log in with your Hugging Face account using the button below.
118
- 2. Click 'Run Evaluation & Submit All Answers' to fetch, run, and submit.
119
  """
120
  )
121
-
122
- login_btn = gr.LoginButton()
123
  run_button = gr.Button("Run Evaluation & Submit All Answers")
124
  status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
125
  results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
126
 
127
  run_button.click(
128
  fn=run_and_submit_all,
129
- inputs=[login_btn],
130
  outputs=[status_output, results_table]
131
  )
132
 
 
34
  and displays the results.
35
  """
36
  # Determine HF Space Runtime URL and Repo URL
37
+ space_id = os.getenv("SPACE_ID", "unknown_space")
38
+ username = os.getenv("HF_USER", "anonymous")
39
+ print(f"Running as user: {username}")
 
 
 
 
 
40
 
41
  api_url = DEFAULT_API_URL
42
  questions_url = f"{api_url}/questions"
 
109
  """
110
  **Instructions:**
111
 
112
+ Click 'Run Evaluation & Submit All Answers' to fetch, run the agent, and submit.
 
113
  """
114
  )
 
 
115
  run_button = gr.Button("Run Evaluation & Submit All Answers")
116
  status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
117
  results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
118
 
119
  run_button.click(
120
  fn=run_and_submit_all,
 
121
  outputs=[status_output, results_table]
122
  )
123