class BaseChip::Cluster

Attributes

ids[RW]
slots[RW]
slots_used[RW]

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/base_chip/cluster.rb, line 39
def initialize 
  super 
  @ids        = []
  @slots      = 0
  @slots_used = 0
end

Public Instance Methods

available_slots() click to toggle source
# File lib/base_chip/cluster.rb, line 46
def available_slots
  @slots - @slots_used
end
kill(id) click to toggle source
# File lib/base_chip/cluster.rb, line 83
def kill(id)
  if kill_procedure
    kill_procedure.call(id)
  elsif kill_command
    system "#{kill_command} #{id}"
  else
    fault "kill_procedure and kill_command for #{full_name} are both missing at time of kill.  This should have been flagged on submit." unless kill_procedure or kill_command
  end
end
kill_all() click to toggle source
# File lib/base_chip/cluster.rb, line 78
def kill_all
  @ids.each do |id|
    kill id
  end
end
submit(command) click to toggle source
# File lib/base_chip/cluster.rb, line 50
def submit(command)
  fault "Cluster submission requires a way to kill spawned jobs.  Please specify kill_procedure or kill_command for #{full_name}" unless @kill_procedure || @kill_command

  if submit_procedure
    return submit_procedure.call command
  elsif submit_command
    output = `#{submit_command} #{command}`
    if id_regex
      if result = id_regex.match(output)
        captures = result[1..-1]
        if id = (captures.select{|c| (c!=nil) && (c!='') }.first)
          @ids << id
          return id
        else
          fault "Regex /#{id_regex}/ matched '#{result}' but no useful capture was found in output of submit_command:\n#{output}"
        end
      else
        fault "Regex /#{id_regex}/ could not be matched in output of submit_command:\n#{output}"
      end
    elsif id_procedure
      return id_procedure.call(output)
    else
      fault "job id is required for job tracking.  Please specify id_regex, id_variable or id_procedure for cluster #{full_name}" unless id_variable or id_procedure
    end
  else
    fault "No submit_procedure or submit_command defined for cluster #{full_name}"
  end
end