Skip to content

Commit

Permalink
add exception handling; add new error message for ValueError exception
Browse files Browse the repository at this point in the history
  • Loading branch information
vpchung committed May 8, 2024
1 parent b4ed90e commit aa69eca
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions score.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,31 @@ def main():

gold_file = extract_gs_file(args.goldstandard_folder)

scores = {"auc_roc": None, "auprc": None}
status = "INVALID"
if res.get("validation_status") == "VALIDATED":
pred = pd.read_csv(
args.predictions_file,
usecols=PREDICTION_COLS,
dtype=PREDICTION_COLS
)
gold = pd.read_csv(
gold_file,
usecols=GOLDSTANDARD_COLS,
dtype=GOLDSTANDARD_COLS
)
scores = score(gold, "disease", pred, "disease_probability")
status = "SCORED"
try:
pred = pd.read_csv(
args.predictions_file,
usecols=PREDICTION_COLS,
dtype=PREDICTION_COLS
)
gold = pd.read_csv(
gold_file,
usecols=GOLDSTANDARD_COLS,
dtype=GOLDSTANDARD_COLS
)
scores = score(gold, "disease", pred, "disease_probability")
status = "SCORED"
errors = ""
except ValueError:
errors = "An error was encountered during scoring; submission not evaluated."
else:
scores = {"auc_roc": None, "auprc": None}
status = "INVALID"
errors = "Submission could not be evaluated due to validation errors."

res |= {
"score_status": status,
"score_errors": (
""
if status == "SCORED"
else "Submission could not be evaluated due to validation errors."
),
"score_errors": errors,
**scores,
}
with open(args.output, "w", encoding="utf-8") as out:
Expand Down

0 comments on commit aa69eca

Please sign in to comment.