<commit_before>module Specjour
  class Manager
    require 'dnssd'
    include DRbUndumped

    attr_accessor :project_name, :specs_to_run, :dispatcher_uri, :worker_size, :bonjour_service, :batch_size

    def initialize(worker_size = 1, batch_size = 25)
      @worker_size = worker_size
      @batch_size = 25
    end

    def project_path=(name)
      @project_path = name
    end

    def project_path
      @project_path ||= File.join("/tmp", project_name)
    end

    def dispatch
      bonjour_service.stop
      pids = []
      (1..worker_size).each do |index|
        pids << fork do
          exec("specjour --batch-size #{batch_size} --do-work #{project_path},#{dispatcher_uri},#{index},#{specs_to_run[index - 1].join(' ')}")
          Kernel.exit!
        end
      end
      at_exit { Process.kill('KILL', *pids) rescue nil }
      Process.waitall
      bonjour_announce
    end

    def start
      drb_start
      bonjour_announce
      Signal.trap('INT') { puts; puts "Shutting down manager..."; exit }
      DRb.thread.join
    end
<commit_msg>Run all the passed in specs, not the first one<commit_after>module Specjour
  class Manager
    require 'dnssd'
    include DRbUndumped

    attr_accessor :project_name, :specs_to_run, :dispatcher_uri, :worker_size, :bonjour_service, :batch_size

    def initialize(worker_size = 1, batch_size = 25)
      @worker_size = worker_size
      @batch_size = 25
    end

    def project_path=(name)
      @project_path = name
    end

    def project_path
      @project_path ||= File.join("/tmp", project_name)
    end

    def dispatch
      bonjour_service.stop
      pids = []
      (1..worker_size).each do |index|
        pids << fork do
          exec("specjour --batch-size #{batch_size} --do-work #{project_path},#{dispatcher_uri},#{index},#{specs_to_run[index - 1].join(',')}")
          Kernel.exit!
        end
      end
      at_exit { Process.kill('KILL', *pids) rescue nil }
      Process.waitall
      bonjour_announce
    end

    def start
      drb_start
      bonjour_announce
      Signal.trap('INT') { puts; puts "Shutting down manager..."; exit }
      DRb.thread.join
    end

{'fraction_non_alphanumeric': 0.11044083526682134, 'fraction_numerical': 0.0064965197215777265, 'mean_word_length': 2.5402298850574714, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1842299', 'n_tokens_mistral': 728, 'n_tokens_neox': 702, 'n_words': 161}