File size: 1,490 Bytes
d22a7f8
475174a
 
 
 
d22a7f8
8fb7a79
 
 
 
 
d22a7f8
8fb7a79
d22a7f8
e740ec1
 
d22a7f8
 
8fb7a79
 
475174a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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)