com3dian commited on
Commit
475174a
·
verified ·
1 Parent(s): 3b45c71

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. 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
- num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
21
- num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
22
-
23
- indices = np.linspace(0, 1, num_points)
24
- theta = 2 * np.pi * num_turns * indices
25
- radius = indices
26
-
27
- x = radius * np.cos(theta)
28
- y = radius * np.sin(theta)
29
-
30
- df = pd.DataFrame({
31
- "x": x,
32
- "y": y,
33
- "idx": indices,
34
- "rand": np.random.randn(num_points),
35
- })
36
-
37
- st.altair_chart(alt.Chart(df, height=700, width=700)
38
- .mark_point(filled=True)
39
- .encode(
40
- x=alt.X("x", axis=None),
41
- y=alt.Y("y", axis=None),
42
- color=alt.Color("idx", legend=None, scale=alt.Scale()),
43
- size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
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)