Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +29 -21
src/streamlit_app.py
CHANGED
@@ -1,41 +1,49 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
-
from evaluation import evaluate_submission
|
4 |
import os
|
5 |
import datetime
|
6 |
-
import sys
|
7 |
|
8 |
-
|
9 |
-
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
10 |
-
|
11 |
-
LEADERBOARD_FILE = os.path.join(os.path.dirname(__file__), "..", "leaderboard.csv")
|
12 |
|
13 |
st.title("π Hackathon Leaderboard")
|
14 |
|
15 |
-
|
|
|
|
|
16 |
|
17 |
-
if uploaded_file:
|
18 |
-
|
19 |
-
|
20 |
-
f.
|
|
|
|
|
|
|
21 |
|
22 |
-
|
23 |
-
score =
|
24 |
-
timestamp = datetime.datetime.now().isoformat()
|
25 |
-
entry = {"filename": uploaded_file.name, "score": score, "timestamp": timestamp}
|
26 |
|
27 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
if os.path.exists(LEADERBOARD_FILE):
|
29 |
df = pd.read_csv(LEADERBOARD_FILE)
|
30 |
df = pd.concat([df, pd.DataFrame([entry])], ignore_index=True)
|
31 |
else:
|
32 |
df = pd.DataFrame([entry])
|
33 |
-
|
34 |
-
|
|
|
35 |
|
36 |
# Show leaderboard
|
37 |
if os.path.exists(LEADERBOARD_FILE):
|
38 |
df = pd.read_csv(LEADERBOARD_FILE)
|
39 |
-
|
40 |
-
st.subheader("
|
41 |
-
st.dataframe(
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
|
|
3 |
import os
|
4 |
import datetime
|
|
|
5 |
|
6 |
+
LEADERBOARD_FILE = "leaderboard.csv"
|
|
|
|
|
|
|
7 |
|
8 |
st.title("π Hackathon Leaderboard")
|
9 |
|
10 |
+
# User submission
|
11 |
+
uploaded_file = st.file_uploader("Upload your solution (.py)", type=["py"])
|
12 |
+
username = st.text_input("Enter your team name")
|
13 |
|
14 |
+
if uploaded_file and username:
|
15 |
+
if st.button("Submit"):
|
16 |
+
# Save uploaded file (optional)
|
17 |
+
submission_path = f"submissions/{username}_{datetime.datetime.now().timestamp()}.py"
|
18 |
+
os.makedirs("submissions", exist_ok=True)
|
19 |
+
with open(submission_path, "wb") as f:
|
20 |
+
f.write(uploaded_file.read())
|
21 |
|
22 |
+
# TODO: Add your custom evaluation logic here
|
23 |
+
score = 42 # Dummy score
|
|
|
|
|
24 |
|
25 |
+
# Log entry
|
26 |
+
timestamp = datetime.datetime.now().isoformat()
|
27 |
+
entry = {
|
28 |
+
"username": username,
|
29 |
+
"timestamp": timestamp,
|
30 |
+
"score": score,
|
31 |
+
"file": os.path.basename(submission_path),
|
32 |
+
}
|
33 |
+
|
34 |
+
# Append to CSV
|
35 |
if os.path.exists(LEADERBOARD_FILE):
|
36 |
df = pd.read_csv(LEADERBOARD_FILE)
|
37 |
df = pd.concat([df, pd.DataFrame([entry])], ignore_index=True)
|
38 |
else:
|
39 |
df = pd.DataFrame([entry])
|
40 |
+
|
41 |
+
df.to_csv(LEADERBOARD_FILE, index=False)
|
42 |
+
st.success(f"Submission received! Score: {score}")
|
43 |
|
44 |
# Show leaderboard
|
45 |
if os.path.exists(LEADERBOARD_FILE):
|
46 |
df = pd.read_csv(LEADERBOARD_FILE)
|
47 |
+
df_sorted = df.sort_values(by="score", ascending=False)
|
48 |
+
st.subheader("Leaderboard")
|
49 |
+
st.dataframe(df_sorted)
|