Shiyu Zhao commited on
Commit
df4f503
·
1 Parent(s): d30ceda

Update space

Browse files
Files changed (1) hide show
  1. app.py +42 -45
app.py CHANGED
@@ -423,62 +423,58 @@ def format_evaluation_results(results):
423
  # Function to send a submission confirmation with evaluation results and metadata, CCing the sender
424
  def send_submission_confirmation(meta_data, eval_results):
425
  """
426
- Sends an email notification confirming submission and including evaluation results and metadata,
427
- with an option to CC the sender.
428
-
429
- Args:
430
- meta_data (dict): Submission metadata to be included in the email.
431
- eval_results (dict): Dictionary of evaluation results to include in the email.
432
-
433
- Returns:
434
- None
435
  """
436
- emails_to_send = get_emails_from_metadata(meta_data)
437
- send_from = 'stark-qa@cs.stanford.edu'
438
- recipients_str = ', '.join(emails_to_send)
439
-
440
- # Create the email container
441
- msg = MIMEMultipart('alternative')
442
- msg['Subject'] = 'STaRK Leaderboard Submission - Evaluation Results'
443
- msg['From'] = send_from
444
- msg['To'] = recipients_str
445
- msg['Cc'] = send_from # CC the sender only for success notification
446
-
447
- # Format the evaluation results and metadata table
448
- formatted_results = format_evaluation_results(eval_results)
449
- metadata_table = format_metadata_as_table(meta_data)
450
 
451
- # Email body content with evaluation results and metadata table
452
- body = f"""
453
- <p>Dear STaRK Leaderboard Participant,</p>
 
 
454
 
455
- <p>Thank you for your submission to the STaRK leaderboard. We are pleased to inform you that the evaluation has been completed. Below are the results of your submission:</p>
 
456
 
457
- <pre>{formatted_results}</pre>
 
458
 
459
- <p>Submitted Metadata:</p>
460
- {metadata_table}
461
 
462
- <p>Your submission will be reviewed. Once approved, the results will be updated on the leaderboard within the next 48 business hours. If there are problems in the metadata that you submitted, one of our team members will reach out to you.</p>
463
 
464
- <p>If you would like to withdraw your submission, simply reply to this email with "withdrawn."</p>
 
465
 
466
- <p>We appreciate your participation and look forward to sharing your results on our leaderboard.</p>
 
467
 
468
- <p>Best regards,<br>The STaRK QA Team</p>
469
- """
470
 
471
- msg.attach(MIMEText(body, 'html'))
472
 
473
- # Send the email
474
- try:
475
- with smtplib.SMTP('localhost') as server:
476
- server.sendmail(send_from, emails_to_send + [send_from], msg.as_string()) # Include sender in recipients for CC
477
- print("Submission confirmation sent successfully.")
 
 
 
 
 
 
 
478
  except Exception as e:
479
- print(f"Failed to send submission confirmation: {e}")
480
-
481
-
 
482
  def process_submission(
483
  method_name, team_name, dataset, split, contact_email,
484
  code_repo, csv_file, model_description, hardware, paper_link
@@ -586,7 +582,7 @@ def process_submission(
586
  submission_data = {
587
  **meta_data,
588
  "results": processed_results,
589
- "status": "pending_review",
590
  "submission_date": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
591
  "csv_path": csv_path_in_repo
592
  }
@@ -611,6 +607,7 @@ def process_submission(
611
  # Send confirmation email and update leaderboard
612
  send_submission_confirmation(meta_data, processed_results)
613
  update_leaderboard_data(submission_data)
 
614
 
615
  return f"""
616
  Submission successful!
 
423
  # Function to send a submission confirmation with evaluation results and metadata, CCing the sender
424
  def send_submission_confirmation(meta_data, eval_results):
425
  """
426
+ Sends an email notification confirming submission and including evaluation results.
427
+ Modified to handle SMTP connection properly.
 
 
 
 
 
 
 
428
  """
429
+ try:
430
+ emails_to_send = get_emails_from_metadata(meta_data)
431
+ send_from = 'stark-qa@cs.stanford.edu'
432
+ recipients_str = ', '.join(emails_to_send)
 
 
 
 
 
 
 
 
 
 
433
 
434
+ msg = MIMEMultipart('alternative')
435
+ msg['Subject'] = 'STaRK Leaderboard Submission - Evaluation Results'
436
+ msg['From'] = send_from
437
+ msg['To'] = recipients_str
438
+ msg['Cc'] = send_from
439
 
440
+ formatted_results = format_evaluation_results(eval_results)
441
+ metadata_table = format_metadata_as_table(meta_data)
442
 
443
+ body = f"""
444
+ <p>Dear STaRK Leaderboard Participant,</p>
445
 
446
+ <p>Thank you for your submission to the STaRK leaderboard. Below are the results of your submission:</p>
 
447
 
448
+ <pre>{formatted_results}</pre>
449
 
450
+ <p>Submitted Metadata:</p>
451
+ {metadata_table}
452
 
453
+ <p>Your results have been added to the leaderboard. If you would like to withdraw your submission,
454
+ please reply to this email with "withdrawn."</p>
455
 
456
+ <p>Best regards,<br>The STaRK QA Team</p>
457
+ """
458
 
459
+ msg.attach(MIMEText(body, 'html'))
460
 
461
+ # Modified SMTP connection handling
462
+ try:
463
+ # First try localhost
464
+ with smtplib.SMTP('localhost') as server:
465
+ server.send_message(msg)
466
+ except:
467
+ # If localhost fails, try connecting to a remote SMTP server
468
+ with smtplib.SMTP('smtp.stanford.edu', 587) as server:
469
+ server.starttls()
470
+ server.send_message(msg)
471
+
472
+ print(f"Submission confirmation sent successfully to {recipients_str}")
473
  except Exception as e:
474
+ print(f"Warning: Failed to send email notification: {str(e)}")
475
+ # Continue with submission even if email fails
476
+ pass
477
+
478
  def process_submission(
479
  method_name, team_name, dataset, split, contact_email,
480
  code_repo, csv_file, model_description, hardware, paper_link
 
582
  submission_data = {
583
  **meta_data,
584
  "results": processed_results,
585
+ "status": "approved", #pending_review
586
  "submission_date": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
587
  "csv_path": csv_path_in_repo
588
  }
 
607
  # Send confirmation email and update leaderboard
608
  send_submission_confirmation(meta_data, processed_results)
609
  update_leaderboard_data(submission_data)
610
+ demo.update()
611
 
612
  return f"""
613
  Submission successful!