<commit_before>class AssociateProversWithOntologyVersions < ActiveRecord::Migration
  def self.up
    OntologyVersion.find_each do |ontology_version|
      retry_provers_retrieval(ontology_version, 3)
    end
  end

  def self.down
    OntologyVersion.find_each do |ontology_version|
      ontology_version.provers = []
      ontology_version.save!
    end
  end

  protected

  def self.retry_provers_retrieval(ontology_version, max_attempts)
    begin
      ontology_version.retrieve_available_provers
    rescue Net::ReadTimeout
      if max_attempts > 0
        puts "Timeout, trying again: OntologyVersion #{ontology_version.id}"
        retry_provers_retrieval(ontology_version, max_attempts - 1)
      else
        puts "Timeout, limit reached: OntologyVersion #{ontology_version.id}"
      end
    rescue ::StandardError => e
      puts "Errored at OntologyVersion #{ontology_version.id}"
    end
  end
end<commit_msg>Remove redundant begin.<commit_after>class AssociateProversWithOntologyVersions < ActiveRecord::Migration
  def self.up
    OntologyVersion.find_each do |ontology_version|
      retry_provers_retrieval(ontology_version, 3)
    end
  end

  def self.down
    OntologyVersion.find_each do |ontology_version|
      ontology_version.provers = []
      ontology_version.save!
    end
  end

  protected

  def self.retry_provers_retrieval(ontology_version, max_attempts)
    ontology_version.retrieve_available_provers
  rescue Net::ReadTimeout
    if max_attempts > 0
      puts "Timeout, trying again: OntologyVersion #{ontology_version.id}"
      retry_provers_retrieval(ontology_version, max_attempts - 1)
    else
      puts "Timeout, limit reached: OntologyVersion #{ontology_version.id}"
    end
  rescue ::StandardError => e
    puts "Errored at OntologyVersion #{ontology_version.id}"
  end
end
{'fraction_non_alphanumeric': 0.06743421052631579, 'fraction_numerical': 0.003289473684210526, 'mean_word_length': 3.9324324324324325, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '5711865', 'n_tokens_mistral': 581, 'n_tokens_neox': 578, 'n_words': 119}