Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +31 -28
src/streamlit_app.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
-
import altair as alt
|
2 |
-
import numpy as np
|
3 |
-
import pandas as pd
|
4 |
import streamlit as st
|
|
|
|
|
|
|
|
|
5 |
|
6 |
|
7 |
LEADERBOARD_FILE = "leaderboard.csv"
|
@@ -17,28 +18,30 @@ This is the time to put that knowledge to practice!
|
|
17 |
|
18 |
uploaded_file = st.file_uploader("Upload your submission (.py)", type=["py"])
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
st.
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
from evaluation import evaluate_submission
|
4 |
+
import os
|
5 |
+
import datetime
|
6 |
|
7 |
|
8 |
LEADERBOARD_FILE = "leaderboard.csv"
|
|
|
18 |
|
19 |
uploaded_file = st.file_uploader("Upload your submission (.py)", type=["py"])
|
20 |
|
21 |
+
if uploaded_file:
|
22 |
+
with open("submission_temp.py", "wb") as f:
|
23 |
+
f.write(uploaded_file.read())
|
24 |
+
|
25 |
+
# Here, you'd validate & evaluate
|
26 |
+
try:
|
27 |
+
score = evaluate_submission("submission_temp.py") # Implement in evaluation.py
|
28 |
+
timestamp = datetime.datetime.now().isoformat()
|
29 |
+
entry = {"filename": uploaded_file.name, "score": score, "timestamp": timestamp}
|
30 |
+
|
31 |
+
# Save to leaderboard
|
32 |
+
if os.path.exists(LEADERBOARD_FILE):
|
33 |
+
df = pd.read_csv(LEADERBOARD_FILE)
|
34 |
+
df = df.append(entry, ignore_index=True)
|
35 |
+
else:
|
36 |
+
df = pd.DataFrame([entry])
|
37 |
+
df.to_csv(LEADERBOARD_FILE, index=False)
|
38 |
+
st.success(f"Submission scored {score}!")
|
39 |
+
except Exception as e:
|
40 |
+
st.error(f"Error: {e}")
|
41 |
+
|
42 |
+
# Show leaderboard
|
43 |
+
if os.path.exists(LEADERBOARD_FILE):
|
44 |
+
df = pd.read_csv(LEADERBOARD_FILE)
|
45 |
+
df = df.sort_values(by="score", ascending=False)
|
46 |
+
st.subheader("🏅 Leaderboard")
|
47 |
+
st.dataframe(df)
|