Abhishek Thakur commited on
Commit
df36232
·
1 Parent(s): 208ef1d
competitions/competitions.py CHANGED
@@ -96,7 +96,7 @@ def _fetch_leaderboard(private):
96
  return [
97
  gr.DataFrame.update(visible=False),
98
  gr.Markdown.update(
99
- visible=True, value="Private Leaderboard will be available after the competition ends"
100
  ),
101
  ]
102
  df = leaderboard.fetch(private=private)
 
96
  return [
97
  gr.DataFrame.update(visible=False),
98
  gr.Markdown.update(
99
+ visible=True, value=f"Private Leaderboard will be available on {competition_info.end_date} UTC."
100
  ),
101
  ]
102
  df = leaderboard.fetch(private=private)
competitions/create.py CHANGED
@@ -457,7 +457,7 @@ with gr.Blocks() as demo:
457
  end_date = gr.Textbox(
458
  max_lines=1,
459
  value="",
460
- label="End Date (YYYY-MM-DD)",
461
  )
462
  with gr.Box():
463
  with gr.Row():
 
457
  end_date = gr.Textbox(
458
  max_lines=1,
459
  value="",
460
+ label="End Date (YYYY-MM-DD), Private LB will be visible on this date",
461
  )
462
  with gr.Box():
463
  with gr.Row():
competitions/submissions.py CHANGED
@@ -101,6 +101,41 @@ class Submissions:
101
  return False
102
  return True
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  def _increment_submissions(self, user_id, submission_id, submission_comment):
105
  user_fname = hf_hub_download(
106
  repo_id=self.competition_id,
@@ -219,13 +254,6 @@ class Submissions:
219
  return user_info
220
 
221
  def _create_autotrain_project(self, submission_id, competition_id, user_id, competition_type):
222
-
223
- # task: Literal["competition"]
224
- # competition_id = Field("", title="Competition ID")
225
- # competition_type = Field("", title="Competition Type")
226
- # user_id = Field("", title="Competition User ID")
227
- # submission_id = Field("", title="Submission ID")
228
-
229
  payload = {
230
  "username": self.autotrain_username,
231
  "proj_name": submission_id,
 
101
  return False
102
  return True
103
 
104
+ def _submissions_today(self, user_info):
105
+ user_id = user_info["id"]
106
+ try:
107
+ user_fname = hf_hub_download(
108
+ repo_id=self.competition_id,
109
+ filename=f"submission_info/{user_id}.json",
110
+ use_auth_token=self.autotrain_token,
111
+ repo_type="dataset",
112
+ )
113
+ except EntryNotFoundError:
114
+ self._add_new_user(user_info)
115
+ user_fname = hf_hub_download(
116
+ repo_id=self.competition_id,
117
+ filename=f"submission_info/{user_id}.json",
118
+ use_auth_token=self.autotrain_token,
119
+ repo_type="dataset",
120
+ )
121
+ except Exception as e:
122
+ logger.error(e)
123
+ raise Exception("Hugging Face Hub is unreachable, please try again later.")
124
+
125
+ with open(user_fname, "r") as f:
126
+ user_submission_info = json.load(f)
127
+
128
+ todays_date = datetime.now().strftime("%Y-%m-%d")
129
+ if len(user_submission_info["submissions"]) == 0:
130
+ user_submission_info["submissions"] = []
131
+
132
+ # count the number of times user has submitted today
133
+ todays_submissions = 0
134
+ for sub in user_submission_info["submissions"]:
135
+ if sub["date"] == todays_date:
136
+ todays_submissions += 1
137
+ return todays_submissions
138
+
139
  def _increment_submissions(self, user_id, submission_id, submission_comment):
140
  user_fname = hf_hub_download(
141
  repo_id=self.competition_id,
 
254
  return user_info
255
 
256
  def _create_autotrain_project(self, submission_id, competition_id, user_id, competition_type):
 
 
 
 
 
 
 
257
  payload = {
258
  "username": self.autotrain_username,
259
  "proj_name": submission_id,