SD_Hackathon / src /streamlit_app.py
com3dian's picture
Update src/streamlit_app.py
475174a verified
raw
history blame
1.49 kB
import streamlit as st
import pandas as pd
from evaluation import evaluate_submission
import os
import datetime
LEADERBOARD_FILE = "leaderboard.csv"
st.title("πŸ† Hackathon Leaderboard")
"""
**Welcome to the exercises of reinforcement learning!**
In this exercise we will train two popular deep reinforcement learning agents that you have learned through your courses.
This is the time to put that knowledge to practice!
"""
uploaded_file = st.file_uploader("Upload your submission (.py)", type=["py"])
if uploaded_file:
with open("submission_temp.py", "wb") as f:
f.write(uploaded_file.read())
# Here, you'd validate & evaluate
try:
score = evaluate_submission("submission_temp.py") # Implement in evaluation.py
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 = df.append(entry, ignore_index=True)
else:
df = pd.DataFrame([entry])
df.to_csv(LEADERBOARD_FILE, index=False)
st.success(f"Submission scored {score}!")
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)