SD_Hackathon / src /streamlit_app.py
com3dian's picture
Update src/streamlit_app.py
781e264 verified
raw
history blame
1.36 kB
import streamlit as st
import pandas as pd
from evaluation import evaluate_submission
import os
import datetime
import sys
# Make sure current directory includes parent of 'source'
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
LEADERBOARD_FILE = os.path.join(os.path.dirname(__file__), "..", "leaderboard.csv")
st.title("πŸ† Hackathon Leaderboard")
uploaded_file = st.file_uploader("Upload your submission (.py)")
if uploaded_file:
temp_path = os.path.join(os.path.dirname(__file__), "submission_temp.py")
with open(temp_path, "wb") as f:
f.write(uploaded_file.read())
try:
score = evaluate_submission(temp_path) # Implement this
timestamp = datetime.datetime.now().isoformat()
entry = {"filename": uploaded_file.name, "score": score, "timestamp": timestamp}
# Save to leaderboard
if os.path.exists(LEADERBOARD_FILE):
df = pd.read_csv(LEADERBOARD_FILE)
df = pd.concat([df, pd.DataFrame([entry])], ignore_index=True)
else:
df = pd.DataFrame([entry])
except Exception as e:
st.error(f"Error: {e}")
# Show leaderboard
if os.path.exists(LEADERBOARD_FILE):
df = pd.read_csv(LEADERBOARD_FILE)
df = df.sort_values(by="score", ascending=False)
st.subheader("πŸ… Leaderboard")
st.dataframe(df)