<commit_before>class Grader
  include HTTParty

  def grade(submission_id)
    key = get_key(submission_id)
    if key
      response = call_grader(submission_id,key)
      evaluate_response(submission_id,response)
    else
      Submission.update(submission_id, grading_status: 'failed', grading_message: 'Files were not received by server.')
      raise "Grader called for submission #{submission_id} but key cannot be found"
    end
  end


  def get_key(submission_id)
    s = Submission.find(submission_id)
    key = s.submission_files.first.submission_file_s3_key
  end


  def call_grader(submission_id,key)
    begin
      response = HTTParty.get("http://54.184.7.125/api/v1/plantvillage_evaluation?submission_id=#{submission_id}&submission_key=#{key}", timeout: 1200)
    rescue
      Submission.update(submission_id, grading_status: 'failed', grading_message: 'Grading process system error.')
    end
  end
<commit_msg>report grader exceptions to admin page<commit_after>class Grader
  include HTTParty

  def grade(submission_id)
    key = get_key(submission_id)
    if key
      response = call_grader(submission_id,key)
      evaluate_response(submission_id,response)
    else
      Submission.update(submission_id, grading_status: 'failed', grading_message: 'Files were not received by server.')
      raise "Grader called for submission #{submission_id} but key cannot be found"
    end
  end


  def get_key(submission_id)
    s = Submission.find(submission_id)
    key = s.submission_files.first.submission_file_s3_key
  end


  def call_grader(submission_id,key)
    begin
      response = HTTParty.get("http://54.184.7.125/api/v1/plantvillage_evaluation?submission_id=#{submission_id}&submission_key=#{key}", timeout: 1200)
    rescue => e
      Submission.update(submission_id, grading_status: 'failed', grading_message: 'Grading process system error.')
      raise e
    end
  end

{'fraction_non_alphanumeric': 0.08937960042060988, 'fraction_numerical': 0.015772870662460567, 'mean_word_length': 4.199453551912568, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5682828', 'n_tokens_mistral': 651, 'n_tokens_neox': 614, 'n_words': 134}