hmacdope commited on
Commit
cf48806
Β·
1 Parent(s): 6aa16f4

add some more descriptive errors

Browse files
Files changed (1) hide show
  1. evaluate.py +6 -6
evaluate.py CHANGED
@@ -127,14 +127,14 @@ def submit_data(predictions_file: str,
127
  try:
128
  results_df = pd.read_csv(file_path)
129
  except Exception as e:
130
- return f"❌ Error reading results file: {str(e)}"
131
 
132
  if results_df.empty:
133
- return gr.Error("The uploaded file is empty.")
134
 
135
  missing = set(ENDPOINTS) - set(results_df.columns)
136
  if missing:
137
- return gr.Error(f"The uploaded file must contain all endpoint predictions {ENDPOINTS} as columns.")
138
 
139
  # Save participant record
140
  try:
@@ -150,8 +150,8 @@ def submit_data(predictions_file: str,
150
  consent_publication=paper_checkbox
151
  )
152
  except ValidationError as e:
153
- return f"❌ Error in participant information: {str(e)}"
154
-
155
  # Build destination filename in the dataset
156
  ts = datetime.datetime.now(datetime.timezone.utc).isoformat(timespec="seconds") # should keep default time so can be deserialized correctly
157
  try:
@@ -163,7 +163,7 @@ def submit_data(predictions_file: str,
163
  participant=participant_record
164
  )
165
  except ValidationError as e:
166
- return f"❌ Error in metadata information: {str(e)}"
167
 
168
  safe_user = _safeify_username(user_state)
169
  destination_csv = f"submissions/{safe_user}_{ts}.csv"
 
127
  try:
128
  results_df = pd.read_csv(file_path)
129
  except Exception as e:
130
+ raise gr.Error(f"❌ Error reading results file: {str(e)}")
131
 
132
  if results_df.empty:
133
+ raise gr.Error("The uploaded file is empty.")
134
 
135
  missing = set(ENDPOINTS) - set(results_df.columns)
136
  if missing:
137
+ raise gr.Error(f"The uploaded file must contain all endpoint predictions {ENDPOINTS} as columns, missing: {missing}")
138
 
139
  # Save participant record
140
  try:
 
150
  consent_publication=paper_checkbox
151
  )
152
  except ValidationError as e:
153
+ raise gr.Error(f"❌ Error in participant information: {str(e)}")
154
+
155
  # Build destination filename in the dataset
156
  ts = datetime.datetime.now(datetime.timezone.utc).isoformat(timespec="seconds") # should keep default time so can be deserialized correctly
157
  try:
 
163
  participant=participant_record
164
  )
165
  except ValidationError as e:
166
+ raise gr.Error(f"❌ Error in metadata information: {str(e)}")
167
 
168
  safe_user = _safeify_username(user_state)
169
  destination_csv = f"submissions/{safe_user}_{ts}.csv"