Abhishek Thakur commited on
Commit
0da9bfd
Β·
1 Parent(s): f3fe9b4

fix public/pvt lb

Browse files
pages/2_πŸ“_Leaderboard.py CHANGED
@@ -1,8 +1,12 @@
 
 
1
  import pandas as pd
2
  import streamlit as st
3
 
 
 
4
 
5
- def fetch_leaderboard():
6
  data_dict = {
7
  "Team Name": ["Team 1", "Team 2", "Team 3", "Team 4", "Team 5"],
8
  "Score": [0.9, 0.8, 0.7, 0.6, 0.5],
@@ -15,14 +19,26 @@ def fetch_leaderboard():
15
  "2021-01-01 00:00:00",
16
  ],
17
  }
18
- return pd.DataFrame(data_dict)
 
19
 
20
 
21
  def app():
22
  st.set_page_config(page_title="Leaderboard", page_icon="πŸ€—")
23
  st.markdown("## Leaderboard")
24
- lb = fetch_leaderboard()
25
- st.table(lb)
 
 
 
 
 
 
 
 
 
 
 
26
 
27
 
28
  if __name__ == "__main__":
 
1
+ from datetime import datetime
2
+
3
  import pandas as pd
4
  import streamlit as st
5
 
6
+ import config
7
+
8
 
9
+ def fetch_leaderboard(private=False):
10
  data_dict = {
11
  "Team Name": ["Team 1", "Team 2", "Team 3", "Team 4", "Team 5"],
12
  "Score": [0.9, 0.8, 0.7, 0.6, 0.5],
 
19
  "2021-01-01 00:00:00",
20
  ],
21
  }
22
+ lb = pd.DataFrame(data_dict)
23
+ st.table(lb)
24
 
25
 
26
  def app():
27
  st.set_page_config(page_title="Leaderboard", page_icon="πŸ€—")
28
  st.markdown("## Leaderboard")
29
+ public_lb, private_lb = st.tabs(["Public", "Private"])
30
+ current_date_time = datetime.now()
31
+
32
+ with public_lb:
33
+ st.header("Public Leaderboard")
34
+ fetch_leaderboard(private=False)
35
+
36
+ with private_lb:
37
+ if current_date_time >= config.END_DATE:
38
+ st.header("Private Leaderboard")
39
+ fetch_leaderboard(private=True)
40
+ else:
41
+ st.error("Private Leaderboard will be available after the competition ends")
42
 
43
 
44
  if __name__ == "__main__":
pages/4_⭐️_Submission History.py CHANGED
@@ -2,6 +2,7 @@ from datetime import datetime
2
 
3
  import pandas as pd
4
  import streamlit as st
 
5
 
6
  import config
7
  import utils
@@ -13,7 +14,11 @@ SUBMISSION_TEXT = """You can select upto 2 submissions for private leaderboard.
13
  def get_subs(user_info, private=False):
14
  # get user submissions
15
  user_id = user_info["id"]
16
- user_submissions = utils.fetch_submissions(user_id)
 
 
 
 
17
  submissions_df = pd.DataFrame(user_submissions)
18
  if not private:
19
  submissions_df = submissions_df.drop(columns=["private_score"])
@@ -24,7 +29,7 @@ def get_subs(user_info, private=False):
24
  submissions_df = submissions_df[
25
  ["date", "submission_id", "public_score", "private_score", "submission_comment", "selected", "status"]
26
  ]
27
- return submissions_df
28
 
29
 
30
  def app():
@@ -44,23 +49,12 @@ def app():
44
  st.error("Please verify your email on Hugging Face Hub")
45
  return
46
 
47
- public_lb, private_lb = st.tabs(["Public", "Private"])
48
  current_date_time = datetime.now()
49
- print(current_date_time)
50
- print(config.END_DATE)
51
- print(current_date_time >= config.END_DATE)
52
- with public_lb:
53
- st.header("Public Leaderboard")
54
- submission_df = get_subs(user_info, private=False)
55
- st.write(submission_df)
56
-
57
- with private_lb:
58
- if current_date_time >= config.END_DATE:
59
- st.header("Private Leaderboard")
60
- submission_df = get_subs(user_info, private=True)
61
- st.write(submission_df)
62
- else:
63
- st.error("Private Leaderboard will be available after the competition ends")
64
 
65
 
66
  if __name__ == "__main__":
 
2
 
3
  import pandas as pd
4
  import streamlit as st
5
+ from huggingface_hub.utils._errors import EntryNotFoundError
6
 
7
  import config
8
  import utils
 
14
  def get_subs(user_info, private=False):
15
  # get user submissions
16
  user_id = user_info["id"]
17
+ try:
18
+ user_submissions = utils.fetch_submissions(user_id)
19
+ except EntryNotFoundError:
20
+ st.error("No submissions found")
21
+ return
22
  submissions_df = pd.DataFrame(user_submissions)
23
  if not private:
24
  submissions_df = submissions_df.drop(columns=["private_score"])
 
29
  submissions_df = submissions_df[
30
  ["date", "submission_id", "public_score", "private_score", "submission_comment", "selected", "status"]
31
  ]
32
+ st.write(submissions_df)
33
 
34
 
35
  def app():
 
49
  st.error("Please verify your email on Hugging Face Hub")
50
  return
51
 
 
52
  current_date_time = datetime.now()
53
+ private = False
54
+ if current_date_time >= config.END_DATE:
55
+ private = True
56
+ st.header("Your Submissions")
57
+ get_subs(user_info, private=private)
 
 
 
 
 
 
 
 
 
 
58
 
59
 
60
  if __name__ == "__main__":