Spaces:
Configuration error
Configuration error
oremaz
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,20 +31,23 @@ class BasicAgent:
|
|
| 31 |
except Exception as e:
|
| 32 |
return e
|
| 33 |
|
| 34 |
-
async def run_and_submit_all( profile
|
| 35 |
"""
|
| 36 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
| 37 |
and displays the results.
|
| 38 |
"""
|
| 39 |
# --- Determine HF Space Runtime URL and Repo URL ---
|
| 40 |
-
space_id = os.getenv("SPACE_ID") # Get the SPACE_ID for sending link to the code
|
| 41 |
|
| 42 |
-
if profile:
|
| 43 |
-
username= f"{profile.username}"
|
| 44 |
-
print(f"User logged in: {username}")
|
| 45 |
-
else:
|
| 46 |
-
print("User not logged in.")
|
| 47 |
-
return "Please Login to Hugging Face with the button.", None
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
api_url = DEFAULT_API_URL
|
| 50 |
questions_url = f"{api_url}/questions"
|
|
@@ -57,7 +60,7 @@ async def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 57 |
print(f"Error instantiating agent: {e}")
|
| 58 |
return f"Error initializing agent: {e}", None
|
| 59 |
# In the case of an app running as a hugging Face space, this link points toward your codebase ( usefull for others so please keep it public)
|
| 60 |
-
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
| 61 |
print(agent_code)
|
| 62 |
|
| 63 |
# 2. Fetch Questions
|
|
@@ -170,7 +173,7 @@ with gr.Blocks() as demo:
|
|
| 170 |
"""
|
| 171 |
)
|
| 172 |
|
| 173 |
-
gr.LoginButton()
|
| 174 |
|
| 175 |
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
| 176 |
|
|
@@ -186,23 +189,23 @@ with gr.Blocks() as demo:
|
|
| 186 |
if __name__ == "__main__":
|
| 187 |
print("\n" + "-"*30 + " App Starting " + "-"*30)
|
| 188 |
# Check for SPACE_HOST and SPACE_ID at startup for information
|
| 189 |
-
space_host_startup = os.getenv("SPACE_HOST")
|
| 190 |
-
space_id_startup = os.getenv("SPACE_ID") # Get SPACE_ID at startup
|
| 191 |
-
|
| 192 |
-
if space_host_startup:
|
| 193 |
-
print(f"✅ SPACE_HOST found: {space_host_startup}")
|
| 194 |
-
print(f" Runtime URL should be: https://{space_host_startup}.hf.space")
|
| 195 |
-
else:
|
| 196 |
-
print("ℹ️ SPACE_HOST environment variable not found (running locally?).")
|
| 197 |
-
|
| 198 |
-
if space_id_startup: # Print repo URLs if SPACE_ID is found
|
| 199 |
-
print(f"✅ SPACE_ID found: {space_id_startup}")
|
| 200 |
-
print(f" Repo URL: https://huggingface.co/spaces/{space_id_startup}")
|
| 201 |
-
print(f" Repo Tree URL: https://huggingface.co/spaces/{space_id_startup}/tree/main")
|
| 202 |
-
else:
|
| 203 |
-
print("ℹ️ SPACE_ID environment variable not found (running locally?). Repo URL cannot be determined.")
|
| 204 |
|
| 205 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
| 206 |
|
| 207 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
| 208 |
-
demo.launch(debug=True, share=
|
|
|
|
| 31 |
except Exception as e:
|
| 32 |
return e
|
| 33 |
|
| 34 |
+
async def run_and_submit_all( profile= None):
|
| 35 |
"""
|
| 36 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
| 37 |
and displays the results.
|
| 38 |
"""
|
| 39 |
# --- Determine HF Space Runtime URL and Repo URL ---
|
| 40 |
+
#space_id = os.getenv("SPACE_ID") # Get the SPACE_ID for sending link to the code
|
| 41 |
|
| 42 |
+
#if profile:
|
| 43 |
+
#username= f"{profile.username}"
|
| 44 |
+
#print(f"User logged in: {username}")
|
| 45 |
+
#else:
|
| 46 |
+
#print("User not logged in.")
|
| 47 |
+
#return "Please Login to Hugging Face with the button.", None
|
| 48 |
+
|
| 49 |
+
username = "kaggle_user"
|
| 50 |
+
print(f"Running as: {username}")
|
| 51 |
|
| 52 |
api_url = DEFAULT_API_URL
|
| 53 |
questions_url = f"{api_url}/questions"
|
|
|
|
| 60 |
print(f"Error instantiating agent: {e}")
|
| 61 |
return f"Error initializing agent: {e}", None
|
| 62 |
# In the case of an app running as a hugging Face space, this link points toward your codebase ( usefull for others so please keep it public)
|
| 63 |
+
#agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
| 64 |
print(agent_code)
|
| 65 |
|
| 66 |
# 2. Fetch Questions
|
|
|
|
| 173 |
"""
|
| 174 |
)
|
| 175 |
|
| 176 |
+
#gr.LoginButton()
|
| 177 |
|
| 178 |
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
| 179 |
|
|
|
|
| 189 |
if __name__ == "__main__":
|
| 190 |
print("\n" + "-"*30 + " App Starting " + "-"*30)
|
| 191 |
# Check for SPACE_HOST and SPACE_ID at startup for information
|
| 192 |
+
#space_host_startup = os.getenv("SPACE_HOST")
|
| 193 |
+
#space_id_startup = os.getenv("SPACE_ID") # Get SPACE_ID at startup
|
| 194 |
+
|
| 195 |
+
#if space_host_startup:
|
| 196 |
+
#print(f"✅ SPACE_HOST found: {space_host_startup}")
|
| 197 |
+
#print(f" Runtime URL should be: https://{space_host_startup}.hf.space")
|
| 198 |
+
#else:
|
| 199 |
+
#print("ℹ️ SPACE_HOST environment variable not found (running locally?).")
|
| 200 |
+
|
| 201 |
+
#if space_id_startup: # Print repo URLs if SPACE_ID is found
|
| 202 |
+
#print(f"✅ SPACE_ID found: {space_id_startup}")
|
| 203 |
+
#print(f" Repo URL: https://huggingface.co/spaces/{space_id_startup}")
|
| 204 |
+
#print(f" Repo Tree URL: https://huggingface.co/spaces/{space_id_startup}/tree/main")
|
| 205 |
+
#else:
|
| 206 |
+
#print("ℹ️ SPACE_ID environment variable not found (running locally?). Repo URL cannot be determined.")
|
| 207 |
|
| 208 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
| 209 |
|
| 210 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
| 211 |
+
demo.launch(debug=True, share=True)
|