class WorkflowManager::TaskSpooler

Public Instance Methods

cluster_nodes() click to toggle source
# File lib/workflow_manager/cluster.rb, line 141
def cluster_nodes
  {"Local with TaskSpooler" => ""}
end
job_pending?(job_id) click to toggle source
# File lib/workflow_manager/cluster.rb, line 123
def job_pending?(job_id)
  command = "tsp"
  result = IO.popen(command) do |io|
    flag = false
    while line=io.gets
      x = line.split
      if x[0].to_i == job_id.to_i and x[1] == "queued"
        flag = true
        break
      end
    end
    flag
  end
  result
end
job_running?(pid) click to toggle source
# File lib/workflow_manager/cluster.rb, line 108
def job_running?(pid)
  command = "tsp"
  result = IO.popen(command) do |io|
    flag = false
    while line=io.gets
      x = line.split
      if x[0].to_i == pid.to_i and x[1] == "running"
        flag = true
        break
      end
    end
    flag
  end
  result
end
kill_command(job_id) click to toggle source
# File lib/workflow_manager/cluster.rb, line 138
def kill_command(job_id)
  command = "tsp -k #{job_id}"
end
submit_job(script_file, script_content, option='') click to toggle source
# File lib/workflow_manager/cluster.rb, line 96
def submit_job(script_file, script_content, option='')
  if script_name = File.basename(script_file) and script_name =~ /\.sh$/
    new_job_script = generate_new_job_script(script_name, script_content)
    new_job_script_base = File.basename(new_job_script)
    log_file = File.join(@log_dir, new_job_script_base + "_o.log")
    err_file = File.join(@log_dir, new_job_script_base + "_e.log")
    command = "tsp sh -c 'bash #{new_job_script} 1> #{log_file} 2> #{err_file}'"
    job_id = `#{command}`.to_s.chomp
    sleep 1
    [job_id.to_s, log_file, command]
  end
end