Spaces:
Running
Running
File size: 2,863 Bytes
eae65f4 0380c4f 5f85cf4 a44fe3a eae65f4 0380c4f a44fe3a 0380c4f a44fe3a 0380c4f a44fe3a 0380c4f a44fe3a 0380c4f 5f85cf4 0380c4f 14f7252 a44fe3a eae65f4 0380c4f a44fe3a 0380c4f a44fe3a 0380c4f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
import gradio as gr
import pandas as pd
import os
import shutil
import json
from zipfile import ZipFile
# Function to load leaderboard data from a CSV file
def load_leaderboard_data(csv_file_path):
try:
df = pd.read_csv(csv_file_path)
return df
except Exception as e:
print(f"Error loading CSV file: {e}")
return pd.DataFrame()
def save_zip_and_extract_json(zip_path):
if not zip_path:
return "Please upload a ZIP file."
try:
# 1) Determine Space name and persistent base dir
cwd = os.getcwd()
space_name = os.path.basename(cwd)
base_dir = os.path.join("data", space_name, "uploaded_jsons")
os.makedirs(base_dir, exist_ok=True)
# 2) Copy the zip into base_dir
zip_dest = os.path.join(base_dir, os.path.basename(zip_path))
shutil.copy(zip_path, zip_dest)
# 3) Extract only .json files
extracted = []
with ZipFile(zip_dest, 'r') as archive:
for member in archive.namelist():
if member.lower().endswith(".json"):
archive.extract(member, path=base_dir)
extracted.append(member)
if not extracted:
return "No JSON files found in the ZIP."
return f"Extracted JSON files:\n" + "\n".join(extracted)
except Exception as e:
return f"Error processing ZIP file: {str(e)}"
# Load the leaderboard data
leaderboard1 = load_leaderboard_data("leaderboard_swe.csv")
leaderboard2 = load_leaderboard_data("leaderboard_gaia.csv")
# Create the Gradio interface
with gr.Blocks() as demo:
gr.Markdown("# 🏆 TRAIL: Trace Reasoning and Agentic Issue Localization Leaderboard")
with gr.Row():
with gr.Column():
gr.Markdown("## TRAIL-SWE Leaderboard")
gr.Dataframe(leaderboard1)
with gr.Column():
gr.Markdown("## TRAIL-GAIA Leaderboard")
gr.Dataframe(leaderboard2)
with gr.Row():
gr.Markdown("## Submit Your ZIP of JSONs")
with gr.Row():
with gr.Column():
file_input = gr.File(
label="Upload ZIP File",
file_types=['.zip']
)
submit_button = gr.Button("Submit", interactive=True)
output = gr.Textbox(label="Status")
def process_upload(file):
if file is None:
return "Please upload a ZIP file."
try:
return save_zip_and_extract_json(file.name)
except Exception as e:
return f"Error: {str(e)}"
submit_button.click(
fn=process_upload,
inputs=file_input,
outputs=output
)
if __name__ == "__main__":
demo.launch()
|