<commit_before>require 'redis'
require 'oj'

namespace :events do

  # add lib to the default include path
  unless $:.include?(File.dirname(__FILE__) + '/../lib/')
    $: << File.dirname(__FILE__) + '/../lib'
  end

  require 'flapjack/configuration'
  require 'flapjack/data/event'
  require 'flapjack/data/entity_check'

  FLAPJACK_ENV = ENV['FLAPJACK_ENV'] || 'test'
  config_file = File.join('etc', 'flapjack_config.yaml')

  config = Flapjack::Configuration.new
  config.load( config_file )

  @config_env = config.all
  @redis_config = config.for_redis

  if @config_env.nil? || @config_env.empty?
    puts "No config data for environment '#{FLAPJACK_ENV}' found in '#{config_file}'"
    exit(false)
  end

  redis = Redis.new(@redis_config)

  desc "nukes the redis db, generates the events, runs and shuts down flapjack, generates perftools reports"
  task :clean_run_benchmark => [:reset_redis, :benchmark, :shutdown, :run_flapjack, :perftools_reports]

  desc "reset the redis database"
  task :reset_redis do
    raise "I'm not going to let you reset your production redis db, sorry about that." if FLAPJACK_ENV.downcase == "production"
    puts "db size before: #{redis.dbsize}"
    redis.flushdb
    puts "db size after: #{redis.dbsize}"
  end

  desc "add a shutdown event to the events queue"
  task :shutdown do
    redis.lpush('events', Oj.dump('type'    => 'shutdown',
                                  'state'   => ''))
  end
<commit_msg>fix path to config for events rake tasks<commit_after>require 'redis'
require 'oj'

namespace :events do

  # add lib to the default include path
  unless $:.include?(File.dirname(__FILE__) + '/../lib/')
    $: << File.dirname(__FILE__) + '/../lib'
  end

  require 'flapjack/configuration'
  require 'flapjack/data/event'
  require 'flapjack/data/entity_check'

  FLAPJACK_ENV = ENV['FLAPJACK_ENV'] || 'test'
  config_file = File.join('tasks', 'support', 'flapjack_config_benchmark.yaml')

  config = Flapjack::Configuration.new
  config.load( config_file )

  @config_env = config.all
  @redis_config = config.for_redis

  if @config_env.nil? || @config_env.empty?
    puts "No config data for environment '#{FLAPJACK_ENV}' found in '#{config_file}'"
    exit(false)
  end

  redis = Redis.new(@redis_config)

  desc "nukes the redis db, generates the events, runs and shuts down flapjack, generates perftools reports"
  task :clean_run_benchmark => [:reset_redis, :benchmark, :shutdown, :run_flapjack, :perftools_reports]

  desc "reset the redis database"
  task :reset_redis do
    raise "I'm not going to let you reset your production redis db, sorry about that." if FLAPJACK_ENV.downcase == "production"
    puts "db size before: #{redis.dbsize}"
    redis.flushdb
    puts "db size after: #{redis.dbsize}"
  end

  desc "add a shutdown event to the events queue"
  task :shutdown do
    redis.lpush('events', Oj.dump('type'    => 'shutdown',
                                  'state'   => ''))
  end

{'fraction_non_alphanumeric': 0.12373567093728928, 'fraction_numerical': 0.0, 'mean_word_length': 3.643192488262911, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6493503', 'n_tokens_mistral': 1019, 'n_tokens_neox': 1000, 'n_words': 278}