Spaces:
Sleeping
Sleeping
Update app.py - leaderboard
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import gradio as gr
|
|
| 2 |
import pandas as pd
|
| 3 |
import os
|
| 4 |
import shutil
|
|
|
|
| 5 |
|
| 6 |
# Function to load leaderboard data from a CSV file
|
| 7 |
def load_leaderboard_data(csv_file_path):
|
|
@@ -13,43 +14,43 @@ def load_leaderboard_data(csv_file_path):
|
|
| 13 |
return pd.DataFrame() # Return an empty DataFrame in case of error
|
| 14 |
|
| 15 |
# Function to process uploaded JSON file
|
| 16 |
-
def process_json_file(
|
|
|
|
|
|
|
| 17 |
try:
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
# For demonstration, we'll just return the data as a dictionary
|
| 22 |
-
return data.to_dict()
|
| 23 |
except Exception as e:
|
| 24 |
-
return
|
| 25 |
-
|
| 26 |
-
# Load the leaderboard data
|
| 27 |
-
leaderboard1 = load_leaderboard_data("leaderboard_swe.csv")
|
| 28 |
-
leaderboard2 = load_leaderboard_data("leaderboard_gaia.csv")
|
| 29 |
|
| 30 |
# Function to save the uploaded JSON file
|
| 31 |
-
def save_json_file(
|
| 32 |
-
if
|
| 33 |
return "No file uploaded."
|
| 34 |
|
| 35 |
# Define the directory to save uploaded files
|
| 36 |
save_dir = "uploaded_jsons"
|
| 37 |
os.makedirs(save_dir, exist_ok=True)
|
| 38 |
|
| 39 |
-
#
|
| 40 |
-
original_filename = os.path.basename(
|
| 41 |
|
| 42 |
# Define the path to save the file
|
| 43 |
save_path = os.path.join(save_dir, original_filename)
|
| 44 |
|
| 45 |
-
#
|
| 46 |
-
shutil.
|
| 47 |
|
| 48 |
return f"File saved to {save_path}"
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
# Create the Gradio interface
|
| 51 |
with gr.Blocks() as demo:
|
| 52 |
-
gr.Markdown("# 🥇
|
| 53 |
with gr.Row():
|
| 54 |
with gr.Column():
|
| 55 |
gr.Markdown("## TRAIL-SWE Leaderboard")
|
|
@@ -58,21 +59,31 @@ with gr.Blocks() as demo:
|
|
| 58 |
gr.Markdown("## TRAIL-GAIA Leaderboard")
|
| 59 |
gr.Dataframe(leaderboard2)
|
| 60 |
|
| 61 |
-
"""
|
| 62 |
-
gr.Markdown("# Submit Here")
|
| 63 |
-
with gr.Row():
|
| 64 |
-
json_input = gr.File(label="Upload JSON File", type="filepath")
|
| 65 |
-
json_output = gr.JSON(label="Processed Output")
|
| 66 |
-
submit_button = gr.Button("Submit")
|
| 67 |
-
submit_button.click(process_json_file, inputs=json_input, outputs=json_output)
|
| 68 |
-
"""
|
| 69 |
with gr.Blocks() as submit_page:
|
| 70 |
gr.Markdown("## Submit Your JSON File Here")
|
| 71 |
-
file_input = gr.File(label="Upload JSON File",
|
|
|
|
| 72 |
submit_button = gr.Button("Submit", interactive=True)
|
| 73 |
-
output = gr.Textbox("")
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
if __name__ == "__main__":
|
| 78 |
demo.launch()
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
import os
|
| 4 |
import shutil
|
| 5 |
+
import json
|
| 6 |
|
| 7 |
# Function to load leaderboard data from a CSV file
|
| 8 |
def load_leaderboard_data(csv_file_path):
|
|
|
|
| 14 |
return pd.DataFrame() # Return an empty DataFrame in case of error
|
| 15 |
|
| 16 |
# Function to process uploaded JSON file
|
| 17 |
+
def process_json_file(file):
|
| 18 |
+
if file is None:
|
| 19 |
+
return None, "Please upload a JSON file."
|
| 20 |
try:
|
| 21 |
+
with open(file.name, 'r') as f:
|
| 22 |
+
data = json.load(f)
|
| 23 |
+
return data, None
|
|
|
|
|
|
|
| 24 |
except Exception as e:
|
| 25 |
+
return None, f"Error reading JSON file: {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
# Function to save the uploaded JSON file
|
| 28 |
+
def save_json_file(file):
|
| 29 |
+
if file is None:
|
| 30 |
return "No file uploaded."
|
| 31 |
|
| 32 |
# Define the directory to save uploaded files
|
| 33 |
save_dir = "uploaded_jsons"
|
| 34 |
os.makedirs(save_dir, exist_ok=True)
|
| 35 |
|
| 36 |
+
# Get the original filename
|
| 37 |
+
original_filename = os.path.basename(file.name)
|
| 38 |
|
| 39 |
# Define the path to save the file
|
| 40 |
save_path = os.path.join(save_dir, original_filename)
|
| 41 |
|
| 42 |
+
# Copy the uploaded file to the save directory
|
| 43 |
+
shutil.copy2(file.name, save_path)
|
| 44 |
|
| 45 |
return f"File saved to {save_path}"
|
| 46 |
|
| 47 |
+
# Load the leaderboard data
|
| 48 |
+
leaderboard1 = load_leaderboard_data("leaderboard_swe.csv")
|
| 49 |
+
leaderboard2 = load_leaderboard_data("leaderboard_gaia.csv")
|
| 50 |
+
|
| 51 |
# Create the Gradio interface
|
| 52 |
with gr.Blocks() as demo:
|
| 53 |
+
gr.Markdown("# 🥇 TRAIL: Trace Reasoning and Agentic Issue Localization Leaderboard")
|
| 54 |
with gr.Row():
|
| 55 |
with gr.Column():
|
| 56 |
gr.Markdown("## TRAIL-SWE Leaderboard")
|
|
|
|
| 59 |
gr.Markdown("## TRAIL-GAIA Leaderboard")
|
| 60 |
gr.Dataframe(leaderboard2)
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
with gr.Blocks() as submit_page:
|
| 63 |
gr.Markdown("## Submit Your JSON File Here")
|
| 64 |
+
file_input = gr.File(label="Upload JSON File", file_types=['.json'])
|
| 65 |
+
json_preview = gr.JSON(label="JSON Preview")
|
| 66 |
submit_button = gr.Button("Submit", interactive=True)
|
| 67 |
+
output = gr.Textbox(label="Status")
|
| 68 |
+
|
| 69 |
+
def handle_submission(file):
|
| 70 |
+
if file is None:
|
| 71 |
+
return None, "Please upload a JSON file."
|
| 72 |
+
try:
|
| 73 |
+
# Process and preview the JSON
|
| 74 |
+
with open(file.name, 'r') as f:
|
| 75 |
+
data = json.load(f)
|
| 76 |
+
# Save the file
|
| 77 |
+
save_result = save_json_file(file)
|
| 78 |
+
return data, save_result
|
| 79 |
+
except Exception as e:
|
| 80 |
+
return None, f"Error: {str(e)}"
|
| 81 |
+
|
| 82 |
+
submit_button.click(
|
| 83 |
+
fn=handle_submission,
|
| 84 |
+
inputs=[file_input],
|
| 85 |
+
outputs=[json_preview, output]
|
| 86 |
+
)
|
| 87 |
|
| 88 |
if __name__ == "__main__":
|
| 89 |
demo.launch()
|