<commit_before>#!/usr/bin/env ruby

require 'drb'
require 'thread'
require 'socket'
require 'memoize'

module Buffet
  # The Buffet::Master class runs worker on all of the host machines 
  # (including itself), and then distributes the tests to the workers.
  # The workers request more tests after they finish their current tests.
  class Master 
    extend Memoize

    # This will initialize the server.
    def initialize(working_dir, hosts, status) 
      @ip = Socket.gethostname.split('.').first # For druby
      @port = 8990 # For druby
      @hosts = hosts # All host machines
      @stats = {:examples => 0, :failures => 0} # Failures and total test #.
      @lock = Mutex.new # Lock objects touched by several threads to avoid race.
      @failure_list = [] # Details of the failure we have.
      @working_dir = working_dir # Directory we clone and run tests in.
      @status = status #RFCTR: Use status

      Dir.chdir(@working_dir) do
        @files = Dir["spec/**/*_spec.rb"].sort #This is specific to rspec.
      end
    end

    def next_file
      @lock.synchronize do
        @files_to_run.shift
      end
    end

    # These two methods are called on passes and fails, respectively.

    def example_passed(location)
      @lock.synchronize do
        @stats[:examples] += 1
        update_status
      end
    end

    #TODO: Kwargs?
    def example_failed(location, header, backtrace)
      @lock.synchronize do
        @stats[:examples] += 1
        @stats[:failures] += 1
<commit_msg>Add test_count setting to settings.yml.<commit_after>#!/usr/bin/env ruby

require 'drb'
require 'thread'
require 'socket'
require 'memoize'

module Buffet
  # The Buffet::Master class runs worker on all of the host machines 
  # (including itself), and then distributes the tests to the workers.
  # The workers request more tests after they finish their current tests.
  class Master 
    extend Memoize

    # This will initialize the server.
    def initialize(working_dir, hosts, status) 
      #TODO: Move ip into Settings.
      @ip = Socket.gethostname.split('.').first # For druby
      @port = Settings.get["port"] + 1 # For druby
      @hosts = hosts # All host machines
      @stats = {:examples => 0, :failures => 0} # Failures and total test #.
      @lock = Mutex.new # Lock objects touched by several threads to avoid race.
      @failure_list = [] # Details of the failure we have.
      @working_dir = working_dir # Directory we clone and run tests in.
      @status = status

      # Get all tests.
      Dir.chdir(@working_dir) do
        @files = Dir["spec/**/*_spec.rb"].sort #This is specific to rspec.
        @files = @files[0..Settings.get['test_count'] - 1] if Settings.get['test_count']
      end
    end

    def next_file
      @lock.synchronize do
        @files_to_run.shift
      end
    end

    # These two methods are called on passes and fails, respectively.

    def example_passed(location)
      @lock.synchronize do
        @stats[:examples] += 1
        update_status
      end
    end

    #TODO: Kwargs?
    def example_failed(location, header, backtrace)
      @lock.synchronize do
        @stats[:examples] += 1
        @stats[:failures] += 1

{'fraction_non_alphanumeric': 0.09590752889721962, 'fraction_numerical': 0.005310840362386754, 'mean_word_length': 2.6386363636363637, 'pattern_counts': {'":': 0, '<': 3, '<?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': '768706', 'n_tokens_mistral': 988, 'n_tokens_neox': 939, 'n_words': 335}