<commit_before>module KeplerProcessor
  class MultifileTaskBase < TaskBase

    attr_accessor :input_data

    def initialize(*args)
      super
      @runners = []
    end

    def execute!
      begin
        check_input_file_count
        get_input_files
        execute_all_runners
        check_consistent_kic_number
        sort_runners_by_season
        yield if block_given?
      rescue KeplerProcessor::FileExistsError
        LOGGER.info "Your output file (#{full_output_filename}) already exists, please remove it first (or something)."
      rescue => e
        LOGGER.error e.message
        LOGGER.error e.backtrace.join("\n")
      end
    end

    private
      def check_input_file_count
        raise(RuntimeError, "Two or more input files required") if @options[:input_paths].count < 2
      end

      def get_input_files
        @options[:input_paths].each do |input_path|
          @runners << InputFileProcessorBase.new(input_path, @options)
        end
      end

      def execute_all_runners
        @runners.each &:execute!
      end

      def check_consistent_kic_number
        raise(RuntimeError, "All files must be for the same star") if @runners.map { |r| r.attributes[:kic_number] }.uniq.count > 1
      end

      def sort_runners_by_season
        @runners.sort! { |a,b| a.attributes[:season] <=> b.attributes[:season] }
      end
  end
end<commit_msg>Additional to two commits ago<commit_after>module KeplerProcessor
  class MultifileTaskBase < TaskBase

    attr_accessor :input_data

    def initialize(*args)
      super
      @runners = []
    end

    def execute!(processor = InputFileProcessorBase)
      begin
        @processor = processor
        check_input_file_count
        get_input_files
        execute_all_runners
        yield if block_given?
      rescue KeplerProcessor::FileExistsError
        LOGGER.info "Your output file (#{full_output_filename}) already exists, please remove it first (or something)."
      rescue => e
        LOGGER.error e.message
        LOGGER.error e.backtrace.join("\n")
      end
    end

    private
      def check_input_file_count
        raise(RuntimeError, "Two or more input files required") if @options[:input_paths].count < 2
      end

      def get_input_files
        @options[:input_paths].each do |input_path|
          @runners << @processor.new(input_path, @options)
        end
      end

      def execute_all_runners
        @runners.each &:execute!
      end
  end
end
{'fraction_non_alphanumeric': 0.0747172859450727, 'fraction_numerical': 0.0012116316639741518, 'mean_word_length': 2.5035360678925036, 'pattern_counts': {'":': 0, '<': 12, '<?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': '4218808', 'n_tokens_mistral': 736, 'n_tokens_neox': 716, 'n_words': 183}