<commit_before>require 'automat'
require 'time'
require 'wait'

module Automat::RDS
  class Snapshot < Automat::Base
    add_option :database,
               :name,
               :environment,
               :prune,
               :wait_for_completion

    if ENV['MAX_SNAPSHOTS'].nil?
      raise ParameterError, "MAX_SNAPSHOTS environment variable not defined"
    else
      MAX_SNAPSHOTS = ENV['MAX_SNAPSHOTS']
    end

    def initialize(options=nil)
      @prune = true
      @wait_for_completion = false
      super
      @wait = Wait.new({
        delay: 30,
        attempts: 20, # 20 x 30s == 10m
        debug: true,
        rescuer:  WaitRescuer.new(),
        logger:   @logger
      })
    end

    include Automat::Mixins::Utils

    def find_db
      db = nil
      if !database.nil?
        db = rds.db_instances[database]
      elsif !environment.nil?
        db = find_db_by_environment(environment)<commit_msg>moved MAX_SNAPSHOTS check code into initializer so that it doesn't bomb when non-RDS functions are being used.<commit_after>require 'automat'
require 'time'
require 'wait'

module Automat::RDS
  class Snapshot < Automat::Base
    add_option :database,
               :name,
               :environment,
               :prune,
               :wait_for_completion

    def initialize(options=nil)
      @prune = true
      @wait_for_completion = false
      super
      @wait = Wait.new({
        delay: 30,
        attempts: 20, # 20 x 30s == 10m
        debug: true,
        rescuer:  WaitRescuer.new(),
        logger:   @logger
      })

      if ENV['MAX_SNAPSHOTS'].nil?
        raise ParameterError, "MAX_SNAPSHOTS environment variable not defined"
      else
        MAX_SNAPSHOTS = ENV['MAX_SNAPSHOTS']
      end
    end

    include Automat::Mixins::Utils

    def find_db
      db = nil
      if !database.nil?
        db = rds.db_instances[database]
      elsif !environment.nil?
        db = find_db_by_environment(environment)
{'fraction_non_alphanumeric': 0.08786185881157949, 'fraction_numerical': 0.01015744032503809, 'mean_word_length': 2.11216429699842, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5187664', 'n_tokens_mistral': 644, 'n_tokens_neox': 622, 'n_words': 151}