Class: TORQUE::Qstat::Job

Inherits:
EnanchedOpenStruct show all
Defined in:
lib/torque_rm/qstat.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Job

Returns a new instance of Job.



73
74
75
76
77
78
# File 'lib/torque_rm/qstat.rb', line 73

def initialize(*args)
  super(*args)
  class_eval do
    alias_method :id, :job_id
  end
end

Class Method Details

.fieldsObject



127
128
129
# File 'lib/torque_rm/qstat.rb', line 127

def self.fields
  FIELDS + %w( is_runnig? is_queued? is_exited? is_completed? time memory node )
end

.json_load(json) ⇒ Object



143
144
145
# File 'lib/torque_rm/qstat.rb', line 143

def self.json_load(json)
  JSON.load(json)
end

Instance Method Details

#fieldsObject



123
124
125
# File 'lib/torque_rm/qstat.rb', line 123

def fields
  FIELDS + %w( is_runnig? is_queued? is_exited? is_completed? time memory node )
end

#is_completed?Boolean Also known as: completed?

Returns:

  • (Boolean)


85
86
87
# File 'lib/torque_rm/qstat.rb', line 85

def is_completed?
  job_state == 'C'
end

#is_exited?Boolean Also known as: exited?

Returns:

  • (Boolean)


90
91
92
# File 'lib/torque_rm/qstat.rb', line 90

def is_exited?
  job_state == 'E'
end

#is_queued?Boolean Also known as: queued?, is_in_queue?

Returns:

  • (Boolean)


95
96
97
# File 'lib/torque_rm/qstat.rb', line 95

def is_queued?
  job_state == 'Q'
end

#is_runnig?Boolean Also known as: running?

Returns:

  • (Boolean)


80
81
82
# File 'lib/torque_rm/qstat.rb', line 80

def is_runnig?
  job_state == 'R'
end

#memoryObject



105
106
107
# File 'lib/torque_rm/qstat.rb', line 105

def memory
  (resources_used && resources_used.mem) ? (resources_used.mem.split("kb").first.to_f/1000).round(1) : "0"
end

#nodeObject



109
110
111
# File 'lib/torque_rm/qstat.rb', line 109

def node 
  exec_host ? exec_host.split("+").map {|n| n.split(".").first}.uniq.join(",") : "-"
end

#procsObject



113
114
115
116
117
118
119
120
121
# File 'lib/torque_rm/qstat.rb', line 113

def procs
	if resource_list.ncpus
		return resource_list.ncpus
	elsif resource_list.nodes
		return resource_list.nodes.split("ppn=")[-1]
	else
 			return "-"
     end
end

#rmObject Also known as: del, delete



147
148
149
# File 'lib/torque_rm/qstat.rb', line 147

def rm
  Qdel.rm(job_id)
end

#timeObject



101
102
103
# File 'lib/torque_rm/qstat.rb', line 101

def time
				return (resources_used && resources_used.walltime) ? resources_used.walltime[:diff] : "-" #using time_diff it prints a nice report in case of more than 1 day
end

#to_json(*a) ⇒ Object



139
140
141
# File 'lib/torque_rm/qstat.rb', line 139

def to_json(*a)
  to_map.to_json(*a)
end

#to_mapObject

alias to_hash to_h



133
134
135
136
137
# File 'lib/torque_rm/qstat.rb', line 133

def to_map
  map = Hash.new
  self.members.each { |m| map[m] = self[m] }
  map
end