<commit_before>require "socket"

module Pwrake

  class HostInfo

    @@local_ip = nil

    def self.local_ip
      @@local_ip ||=
        Socket.getifaddrs.select{|a| a.addr.ip?}.map{|a| a.addr.ip_address}
    end

    def initialize(name,id,ncore,weight,group=nil)
      @name = name
      @ncore = ncore
      @weight = weight || 1.0
      @group = group || 0
      @id = id
      @continuous_fail = 0
      @total_fail = 0
      @count_task = 0
      @ipaddr = []
    end

    attr_reader :name, :ncore, :weight, :group, :id, :steal_flag
    attr_reader :ipaddr
    attr_accessor :idle_cores

    def local?
      ipa = IPSocket.getaddress(@name)
      HostInfo.local_ip.include?(ipa)
    end

    def set_ncore(n)
      @busy_cores = 0
      @ncore = @idle_cores = n
    end

    def set_ip(ipa)
      @ipaddr.push(ipa)
    end

    def idle(n)
      @busy_cores -= n
      @idle_cores += n
    end

    def busy(n)
      @busy_cores += n
      @idle_cores -= n
    end

    def retire(n)<commit_msg>add IP address of @name in HostInfo#initialize<commit_after>require "socket"

module Pwrake

  class HostInfo

    @@local_ip = nil

    def self.local_ip
      @@local_ip ||=
        Socket.getifaddrs.select{|a| a.addr.ip?}.map{|a| a.addr.ip_address}
    end

    def initialize(name,id,ncore,weight,group=nil)
      @name = name
      @ncore = ncore
      @weight = weight || 1.0
      @group = group || 0
      @id = id
      @continuous_fail = 0
      @total_fail = 0
      @count_task = 0
      @ipaddr = []
      begin
        @ipaddr << IPSocket.getaddress(@name)
      rescue
      end
    end

    attr_reader :name, :ncore, :weight, :group, :id, :steal_flag
    attr_reader :ipaddr
    attr_accessor :idle_cores

    def local?
      ipa = IPSocket.getaddress(@name)
      HostInfo.local_ip.include?(ipa)
    end

    def set_ncore(n)
      @busy_cores = 0
      @ncore = @idle_cores = n
    end

    def set_ip(ipa)
      @ipaddr.push(ipa)
    end

    def idle(n)
      @busy_cores -= n
      @idle_cores += n
    end

    def busy(n)
      @busy_cores += n
      @idle_cores -= n
    end

    def retire(n)
{'fraction_non_alphanumeric': 0.11534839924670433, 'fraction_numerical': 0.006591337099811676, 'mean_word_length': 2.0357142857142856, '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': '5911607', 'n_tokens_mistral': 831, 'n_tokens_neox': 786, 'n_words': 174}