Clémentine commited on
Commit
627001e
1 Parent(s): f31b62e

Added better test messages for failures

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -97,16 +97,19 @@ def add_new_eval(
97
  )
98
 
99
  # Compute score
100
- file_path = path_to_file.name
101
  scores = {"all": 0, 1: 0, 2: 0, 3: 0}
102
  num_questions = {"all": 0, 1: 0, 2: 0, 3: 0}
103
  with open(f"scored/{organisation}_{model}.jsonl", "w") as scored_file:
104
  with open(file_path, 'r') as f:
105
- for line in f:
106
- task = json.loads(line)
 
 
 
107
 
108
  if "model_answer" not in task:
109
- raise Exception("No model_answer key in the file provided")
110
  answer = task["model_answer"]
111
  task_id = task["task_id"]
112
  try:
 
97
  )
98
 
99
  # Compute score
100
+ file_path = path_to_file.name
101
  scores = {"all": 0, 1: 0, 2: 0, 3: 0}
102
  num_questions = {"all": 0, 1: 0, 2: 0, 3: 0}
103
  with open(f"scored/{organisation}_{model}.jsonl", "w") as scored_file:
104
  with open(file_path, 'r') as f:
105
+ for ix, line in enumerate(f):
106
+ try:
107
+ task = json.loads(line)
108
+ except Exception:
109
+ return format_error(f"Line {ix} is incorrectly formatted. Please fix it and resubmit your file.")
110
 
111
  if "model_answer" not in task:
112
+ raise format_error(f"Line {ix} contains no model_answer key. Please fix it and resubmit your file.")
113
  answer = task["model_answer"]
114
  task_id = task["task_id"]
115
  try: