<commit_before>require 'redis'

Rails.application.config.after_initialize do
  begin
    Redis.current.ping

    I18n.backend = I18n::Backend::Chain.new(
      I18n::Backend::KeyValue.new(Redis.current),
      I18n.backend
    )

    Snippets::Snippet.cache_all if Snippets::Snippet.table_exists?

  rescue Redis::CannotConnectError => ex
    raise ex unless Rails.env.development? || Rails.env.test?
  end
end<commit_msg>Prevent redis failure if no redis connection details present<commit_after>require 'redis'

Rails.application.config.after_initialize do
  begin
    Redis.current.ping

    I18n.backend = I18n::Backend::Chain.new(
      I18n::Backend::KeyValue.new(Redis.current),
      I18n.backend
    )

    Snippets::Snippet.cache_all if Snippets::Snippet.table_exists?

  rescue Redis::CannotConnectError => ex
    unless Rails.env.development? || Rails.env.test? ||
           (ENV['REDIS_URL'].nil? && ENV['REDIS_PROVIDER'].nil?)
      raise ex
    end
  end
end
{'fraction_non_alphanumeric': 0.1171634121274409, 'fraction_numerical': 0.01644398766700925, 'mean_word_length': 3.7512195121951217, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3721784', 'n_tokens_mistral': 345, 'n_tokens_neox': 326, 'n_words': 56}