Madhavan Iyengar commited on
Commit
7351c4b
·
1 Parent(s): 6c7a8ff

add basic error handling

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -35,6 +35,22 @@ from src.submission.submit import add_new_eval
35
  from src.submission.evaluate import calculate_metrics
36
 
37
  def handle_new_eval_submission(model_name, model_zip, model_link=None):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  extraction_path = EVAL_RESULTS_PATH_BACKEND
39
 
40
  if not os.path.exists(extraction_path):
 
35
  from src.submission.evaluate import calculate_metrics
36
 
37
  def handle_new_eval_submission(model_name, model_zip, model_link=None):
38
+
39
+ if not model_name:
40
+ return "Please enter a model name."
41
+
42
+ # check if the model name is already in the leaderboard
43
+ if model_name in leaderboard_df[AutoEvalColumn.model.name].values:
44
+ return "Model name already exists in the leaderboard. Please choose a different name."
45
+
46
+ # check if the zip file is actually a zip file
47
+ if model_zip is None or not zipfile.is_zipfile(model_zip):
48
+ return "Please upload a valid zip file."
49
+
50
+ # check if the model name is only one word
51
+ if len(model_name.split()) > 1:
52
+ return "Model name should be a single word with hyphens."
53
+
54
  extraction_path = EVAL_RESULTS_PATH_BACKEND
55
 
56
  if not os.path.exists(extraction_path):