Abhishek Thakur commited on
Commit
ac74837
·
1 Parent(s): 55624b4

fix my submissions for multi metrics

Browse files
competitions/competitions.py CHANGED
@@ -14,7 +14,6 @@ from .text import (
14
  SUBMISSION_SUCCESS,
15
  SUBMISSION_TEXT,
16
  )
17
- from .utils import make_clickable_user
18
 
19
 
20
  leaderboard = Leaderboard(
@@ -46,25 +45,36 @@ def _new_submission(user_token, submission_file):
46
 
47
 
48
  def _my_submissions(user_token):
49
- df = submissions.my_submissions(user_token)
50
  if len(df) == 0:
51
  return [
52
  gr.Markdown.update(visible=True, value=NO_SUBMISSIONS),
53
  gr.DataFrame.update(visible=False),
 
 
 
54
  gr.TextArea.update(visible=False),
55
  gr.Button.update(visible=False),
56
  ]
57
  selected_submission_ids = df[df["selected"] == True]["submission_id"].values.tolist()
 
 
58
  if len(selected_submission_ids) > 0:
59
  return [
60
  gr.Markdown.update(visible=True),
61
  gr.DataFrame.update(visible=True, value=df),
 
 
 
62
  gr.TextArea.update(visible=True, value="\n".join(selected_submission_ids), interactive=True),
63
  gr.Button.update(visible=True),
64
  ]
65
  return [
66
  gr.Markdown.update(visible=False),
67
  gr.DataFrame.update(visible=True, value=df),
 
 
 
68
  gr.TextArea.update(visible=True, interactive=True),
69
  gr.Button.update(visible=True),
70
  ]
@@ -84,6 +94,7 @@ def _update_selected_submissions(user_token, submission_ids):
84
  return [
85
  gr.Markdown.update(visible=True, value="You can no longer select submissions after the deadline."),
86
  gr.DataFrame.update(visible=False),
 
87
  gr.TextArea.update(visible=False),
88
  gr.Button.update(visible=False),
89
  ]
@@ -148,7 +159,8 @@ with gr.Blocks(css=".tabitem {padding: 25px}") as demo:
148
  max_lines=1, value="", label="Please enter your Hugging Face token (read only)", type="password"
149
  )
150
  output_text = gr.Markdown(visible=True, show_label=False)
151
- output_df = gr.DataFrame(visible=False)
 
152
  selected_submissions = gr.TextArea(
153
  visible=False,
154
  label="Selected Submissions (one submission id per line)",
@@ -160,12 +172,12 @@ with gr.Blocks(css=".tabitem {padding: 25px}") as demo:
160
  my_subs_button.click(
161
  fn=_my_submissions,
162
  inputs=[user_token],
163
- outputs=[output_text, output_df, selected_submissions, update_selected_submissions],
164
  )
165
  update_selected_submissions.click(
166
  fn=_update_selected_submissions,
167
  inputs=[user_token, selected_submissions],
168
- outputs=[output_text, output_df, selected_submissions, update_selected_submissions],
169
  )
170
 
171
  fetch_lb_partial = partial(_fetch_leaderboard, private=False)
 
14
  SUBMISSION_SUCCESS,
15
  SUBMISSION_TEXT,
16
  )
 
17
 
18
 
19
  leaderboard = Leaderboard(
 
45
 
46
 
47
  def _my_submissions(user_token):
48
+ df, failed_df = submissions.my_submissions(user_token)
49
  if len(df) == 0:
50
  return [
51
  gr.Markdown.update(visible=True, value=NO_SUBMISSIONS),
52
  gr.DataFrame.update(visible=False),
53
+ gr.DataFrame.update(
54
+ visible=True if len(failed_df) > 0 else False, value=failed_df if len(failed_df) > 0 else None
55
+ ),
56
  gr.TextArea.update(visible=False),
57
  gr.Button.update(visible=False),
58
  ]
59
  selected_submission_ids = df[df["selected"] == True]["submission_id"].values.tolist()
60
+ failed_selected_submission_ids = failed_df[failed_df["selected"] == True]["submission_id"].values.tolist()
61
+ selected_submission_ids.extend(failed_selected_submission_ids)
62
  if len(selected_submission_ids) > 0:
63
  return [
64
  gr.Markdown.update(visible=True),
65
  gr.DataFrame.update(visible=True, value=df),
66
+ gr.DataFrame.update(
67
+ visible=True if len(failed_df) > 0 else False, value=failed_df if len(failed_df) > 0 else None
68
+ ),
69
  gr.TextArea.update(visible=True, value="\n".join(selected_submission_ids), interactive=True),
70
  gr.Button.update(visible=True),
71
  ]
72
  return [
73
  gr.Markdown.update(visible=False),
74
  gr.DataFrame.update(visible=True, value=df),
75
+ gr.DataFrame.update(
76
+ visible=True if len(failed_df) > 0 else False, value=failed_df if len(failed_df) > 0 else None
77
+ ),
78
  gr.TextArea.update(visible=True, interactive=True),
79
  gr.Button.update(visible=True),
80
  ]
 
94
  return [
95
  gr.Markdown.update(visible=True, value="You can no longer select submissions after the deadline."),
96
  gr.DataFrame.update(visible=False),
97
+ gr.DataFrame.update(visible=False),
98
  gr.TextArea.update(visible=False),
99
  gr.Button.update(visible=False),
100
  ]
 
159
  max_lines=1, value="", label="Please enter your Hugging Face token (read only)", type="password"
160
  )
161
  output_text = gr.Markdown(visible=True, show_label=False)
162
+ output_df = gr.DataFrame(visible=False, label="Succesful Submissions")
163
+ failed_df = gr.DataFrame(visible=False, label="Failed Submissions")
164
  selected_submissions = gr.TextArea(
165
  visible=False,
166
  label="Selected Submissions (one submission id per line)",
 
172
  my_subs_button.click(
173
  fn=_my_submissions,
174
  inputs=[user_token],
175
+ outputs=[output_text, output_df, failed_df, selected_submissions, update_selected_submissions],
176
  )
177
  update_selected_submissions.click(
178
  fn=_update_selected_submissions,
179
  inputs=[user_token, selected_submissions],
180
+ outputs=[output_text, output_df, failed_df, selected_submissions, update_selected_submissions],
181
  )
182
 
183
  fetch_lb_partial = partial(_fetch_leaderboard, private=False)
competitions/create.py CHANGED
@@ -65,7 +65,6 @@ def create_competition(
65
  solution_file,
66
  is_public,
67
  ):
68
-
69
  # verify sample submission and solution
70
  try:
71
  verify_sample_and_solution(sample_submission_file, solution_file, eval_metric)
 
65
  solution_file,
66
  is_public,
67
  ):
 
68
  # verify sample submission and solution
69
  try:
70
  verify_sample_and_solution(sample_submission_file, solution_file, eval_metric)
competitions/submissions.py CHANGED
@@ -237,35 +237,55 @@ class Submissions:
237
  raise NoSubmissionError("No submissions found ")
238
 
239
  submissions_df = pd.DataFrame(user_submissions)
240
- logger.info(submissions_df)
241
  if not private:
242
  submissions_df = submissions_df.drop(columns=["private_score"])
243
  submissions_df = submissions_df[self.public_sub_columns]
244
  else:
245
  submissions_df = submissions_df[self.private_sub_columns]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
 
247
  if not private:
248
- first_submission = submissions_df.iloc[0]
249
  if isinstance(first_submission["public_score"], dict):
250
  # split the public score dict into columns
251
- temp_scores_df = submissions_df["public_score"].apply(pd.Series)
252
  temp_scores_df = temp_scores_df.rename(columns=lambda x: "public_" + str(x))
253
- submissions_df = pd.concat(
254
  [
255
- submissions_df.drop(["public_score"], axis=1),
256
  temp_scores_df,
257
  ],
258
  axis=1,
259
  )
260
  else:
261
- first_submission = submissions_df.iloc[0]
262
  if isinstance(first_submission["private_score"], dict):
263
  # split the public score dict into columns
264
- temp_scores_df = submissions_df["private_score"].apply(pd.Series)
265
  temp_scores_df = temp_scores_df.rename(columns=lambda x: "private_" + str(x))
266
- submissions_df = pd.concat(
267
  [
268
- submissions_df.drop(["private_score"], axis=1),
269
  temp_scores_df,
270
  ],
271
  axis=1,
@@ -273,17 +293,16 @@ class Submissions:
273
 
274
  if isinstance(first_submission["public_score"], dict):
275
  # split the public score dict into columns
276
- temp_scores_df = submissions_df["public_score"].apply(pd.Series)
277
  temp_scores_df = temp_scores_df.rename(columns=lambda x: "public_" + str(x))
278
- submissions_df = pd.concat(
279
  [
280
- submissions_df.drop(["public_score"], axis=1),
281
  temp_scores_df,
282
  ],
283
  axis=1,
284
  )
285
-
286
- return submissions_df
287
 
288
  def _get_user_info(self, user_token):
289
  user_info = user_authentication(token=user_token)
@@ -358,8 +377,8 @@ class Submissions:
358
  private = False
359
  if current_date_time >= self.end_date:
360
  private = True
361
- subs = self._get_user_subs(user_info, private=private)
362
- return subs
363
 
364
  def new_submission(self, user_token, uploaded_file):
365
  # verify token
 
237
  raise NoSubmissionError("No submissions found ")
238
 
239
  submissions_df = pd.DataFrame(user_submissions)
240
+
241
  if not private:
242
  submissions_df = submissions_df.drop(columns=["private_score"])
243
  submissions_df = submissions_df[self.public_sub_columns]
244
  else:
245
  submissions_df = submissions_df[self.private_sub_columns]
246
+ if not private:
247
+ failed_submissions = submissions_df[
248
+ (submissions_df["status"].isin(["failed", "error"])) | (submissions_df["public_score"] == -1)
249
+ ]
250
+ successful_submissions = submissions_df[
251
+ ~submissions_df["status"].isin(["failed", "error"]) & (submissions_df["public_score"] != -1)
252
+ ]
253
+ else:
254
+ failed_submissions = submissions_df[
255
+ (submissions_df["status"].isin(["failed", "error"]))
256
+ | (submissions_df["private_score"] == -1)
257
+ | (submissions_df["public_score"] == -1)
258
+ ]
259
+ successful_submissions = submissions_df[
260
+ ~submissions_df["status"].isin(["failed", "error"])
261
+ & (submissions_df["private_score"] != -1)
262
+ & (submissions_df["public_score"] != -1)
263
+ ]
264
+ failed_submissions = failed_submissions.reset_index(drop=True)
265
+ successful_submissions = successful_submissions.reset_index(drop=True)
266
 
267
  if not private:
268
+ first_submission = successful_submissions.iloc[0]
269
  if isinstance(first_submission["public_score"], dict):
270
  # split the public score dict into columns
271
+ temp_scores_df = successful_submissions["public_score"].apply(pd.Series)
272
  temp_scores_df = temp_scores_df.rename(columns=lambda x: "public_" + str(x))
273
+ successful_submissions = pd.concat(
274
  [
275
+ successful_submissions.drop(["public_score"], axis=1),
276
  temp_scores_df,
277
  ],
278
  axis=1,
279
  )
280
  else:
281
+ first_submission = successful_submissions.iloc[0]
282
  if isinstance(first_submission["private_score"], dict):
283
  # split the public score dict into columns
284
+ temp_scores_df = successful_submissions["private_score"].apply(pd.Series)
285
  temp_scores_df = temp_scores_df.rename(columns=lambda x: "private_" + str(x))
286
+ successful_submissions = pd.concat(
287
  [
288
+ successful_submissions.drop(["private_score"], axis=1),
289
  temp_scores_df,
290
  ],
291
  axis=1,
 
293
 
294
  if isinstance(first_submission["public_score"], dict):
295
  # split the public score dict into columns
296
+ temp_scores_df = successful_submissions["public_score"].apply(pd.Series)
297
  temp_scores_df = temp_scores_df.rename(columns=lambda x: "public_" + str(x))
298
+ successful_submissions = pd.concat(
299
  [
300
+ successful_submissions.drop(["public_score"], axis=1),
301
  temp_scores_df,
302
  ],
303
  axis=1,
304
  )
305
+ return successful_submissions, failed_submissions
 
306
 
307
  def _get_user_info(self, user_token):
308
  user_info = user_authentication(token=user_token)
 
377
  private = False
378
  if current_date_time >= self.end_date:
379
  private = True
380
+ success_subs, failed_subs = self._get_user_subs(user_info, private=private)
381
+ return success_subs, failed_subs
382
 
383
  def new_submission(self, user_token, uploaded_file):
384
  # verify token
requirements.txt CHANGED
@@ -1,6 +1,6 @@
1
  gradio==3.24.1
2
  joblib==1.2.0
3
  loguru>=0.6.0
4
- pandas==1.5.0
5
  huggingface_hub>=0.10.1
6
  tabulate==0.9.0
 
1
  gradio==3.24.1
2
  joblib==1.2.0
3
  loguru>=0.6.0
4
+ pandas>=2.0.1
5
  huggingface_hub>=0.10.1
6
  tabulate==0.9.0