com3dian commited on
Commit
f970fd2
Β·
verified Β·
1 Parent(s): d99a261

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +5 -22
src/streamlit_app.py CHANGED
@@ -6,6 +6,7 @@ import dill as pickle
6
  import inspect
7
 
8
  from google_sheet import *
 
9
 
10
  st.title("πŸ† Hackathon Leaderboard")
11
 
@@ -13,7 +14,7 @@ st.title("πŸ† Hackathon Leaderboard")
13
  # Submission Form
14
  # ========================
15
 
16
- uploaded_file = st.file_uploader("Upload your model/class (.pkl)", type=["pkl"])
17
 
18
  def is_valid_model(obj):
19
  """
@@ -31,29 +32,11 @@ if uploaded_file and st.button("Submit"):
31
  with open(submission_path, "wb") as f:
32
  f.write(uploaded_file.read())
33
 
34
- team = "fail"
35
-
36
- # Load and evaluate model
37
  try:
38
- with open(submission_path, "rb") as f:
39
- model = pickle.load(f)
40
-
41
- if is_valid_model(model):
42
- team = model.get_team()
43
- score = 100 # Example valid score
44
- st.success("Valid model uploaded. βœ…")
45
- else:
46
- team = "fail"
47
- score = 0
48
- st.error("Uploaded object does not implement a `predict` method. ❌")
49
-
50
  except Exception as e:
51
- score = 0
52
- st.error(f"Failed to load or validate pickle file: {e}")
53
-
54
- # Append result to leaderboard
55
- append_score(timestamp, score, submission_filename)
56
- st.success(f"Submission received! Score: {score}; Team {team}")
57
 
58
  # ========================
59
  # Always Show Leaderboard
 
6
  import inspect
7
 
8
  from google_sheet import *
9
+ from google_drive import upload_to_drive
10
 
11
  st.title("πŸ† Hackathon Leaderboard")
12
 
 
14
  # Submission Form
15
  # ========================
16
 
17
+ uploaded_file = st.file_uploader("Upload your submission (.zip)", type=["zip"])
18
 
19
  def is_valid_model(obj):
20
  """
 
32
  with open(submission_path, "wb") as f:
33
  f.write(uploaded_file.read())
34
 
 
 
 
35
  try:
36
+ drive_file_id = upload_to_drive(submission_path, submission_filename)
37
+ st.success(f"Uploaded to Google Drive βœ… [File ID: {drive_file_id}]")
 
 
 
 
 
 
 
 
 
 
38
  except Exception as e:
39
+ st.warning(f"Failed to upload to Google Drive: {e}")
 
 
 
 
 
40
 
41
  # ========================
42
  # Always Show Leaderboard