comana 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/machinestatus DELETED
@@ -1,192 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
-
5
- puts "machinestatus is obsoleted. use 'hostinfo'"
6
- exit
7
-
8
- USAGE = <<HERE
9
- machinestatus HostA HostB
10
- machinestatus -g GroupA GroupB #-g option interprets as group name
11
- HERE
12
-
13
- require "pp"
14
- require "optparse"
15
- require "rubygems"
16
- require "comana"
17
- require "highline"
18
- require "tefil"
19
-
20
- HIGHLINE = HighLine.new
21
-
22
- ##Analyze options
23
- OPTIONS = {}
24
- op = OptionParser.new
25
- op.on("-a", "--ping-alive", "Check only alive using ping"){OPTIONS[:ping] = true}
26
- #op.on("-t", "--top" , "Info from top. "){OPTIONS[:top ] = true}
27
- #op.on("-p", "--ps" , "Info from ps. "){OPTIONS[:ps ] = true}
28
- op.on("-n", "--pbsnodes" , "Info from pbsnodes."){OPTIONS[:pbsnodes] = true}
29
- op.on("-l", "--load" , "Pbsnodes; state, loadave."){
30
- OPTIONS[:pbsnodes] = true
31
- OPTIONS[:load] = true
32
- }
33
- #op.on("-d", "--dmesg" , "Info from dmesg. "){OPTIONS[:dmesg ] = true}
34
-
35
- op.on("-g", "--group" , "Indicate group of hosts" ){OPTIONS[:group] = true}
36
- op.on("-q", "--quiet" , "No output 'Wainting for...'"){OPTIONS[:quiet] = true}
37
- op.parse!(ARGV)
38
-
39
-
40
- ##Select hosts
41
- cs = Comana::ClusterSetting.load_file
42
- groups = {}
43
- cs.groups.each do |key, val|
44
- cluster = key
45
- groups[key] = val["members"]
46
- end
47
-
48
- hs = Comana::HostSelector.new groups
49
- if OPTIONS[:group]
50
- hosts = []
51
- ARGV.each do |group|
52
- begin
53
- hosts << hs.select_group(group)
54
- rescue Comana::HostSelector::NoEntryError
55
- $stderr.puts "Unknown group: #{group}"
56
- end
57
- end
58
- hosts.flatten!
59
- else
60
- hosts = ARGV
61
- end
62
- hosts = hs.select_all if ARGV.empty?
63
-
64
- ##Collect information
65
- Thread.abort_on_exception = true
66
- results = {}
67
- threads = {}
68
- hosts.each do |host|
69
- threads[host] = Thread.start do
70
- results[host] = {}
71
- if OPTIONS[:ping]
72
- results[host][:ping] = Comana::HostInspector::Ping.new host
73
- end
74
- if OPTIONS[:pbsnodes]
75
- begin
76
- results[host][:pbsnodes] = Comana::HostInspector::Pbsnodes.new(host, cs.pbs_server)
77
- rescue Comana::HostInspector::Pbsnodes::UnknownNodeError
78
- #results[host][:pbsnodes] = Comana::HostInspector::Pbsnodes.new(host, cs.pbs_server)
79
- results[host][:pbsnodes] = nil
80
- #results[host][:pbsnodes]["status"] = {}
81
- end
82
- end
83
- end
84
- end
85
-
86
- threads.each do |host, thread|
87
- print "Waiting for #{host}...\n" unless OPTIONS[:quiet]
88
- thread.join # wait until all processes are completed
89
- end
90
-
91
- ##Titles
92
- titles = []
93
- titles << "host"
94
- if OPTIONS[:ping]
95
- titles << "ping"
96
- end
97
- if OPTIONS[:pbsnodes]
98
- titles << "state"
99
- titles << "np" unless OPTIONS[:load]
100
- titles << "properties" unless OPTIONS[:load]
101
- titles << "ntype" unless OPTIONS[:load]
102
- titles << "gpus" unless OPTIONS[:load]
103
- titles << "rectime" unless OPTIONS[:load]
104
- titles << "varattr" unless OPTIONS[:load]
105
- titles << "jobs"
106
- titles << "state" unless OPTIONS[:load]
107
- titles << "netload" unless OPTIONS[:load]
108
- titles << "gres" unless OPTIONS[:load]
109
- titles << "loadave"
110
- titles << "ncpus" unless OPTIONS[:load]
111
- titles << "physmem" unless OPTIONS[:load]
112
- titles << "availmem" unless OPTIONS[:load]
113
- titles << "totmem" unless OPTIONS[:load]
114
- titles << "idletime" unless OPTIONS[:load]
115
- titles << "nusers" unless OPTIONS[:load]
116
- titles << "nsessions" unless OPTIONS[:load]
117
- titles << "sessions" unless OPTIONS[:load]
118
- titles << "uname" unless OPTIONS[:load]
119
- titles << "opsys" unless OPTIONS[:load]
120
- end
121
-
122
- ##Data
123
- data = []
124
- results.keys.sort.each do |host|
125
- items = [host]
126
- #printf("%9s: ", )
127
- #
128
- if OPTIONS[:ping]
129
- #state = HIGHLINE.color("dead", :red)
130
- state = "dead"
131
- state = "alive" if results[host][:ping].alive?
132
- items << state
133
- #sprintf("%5s", state)
134
- end
135
-
136
- if OPTIONS[:pbsnodes]
137
- if results[host][:pbsnodes]
138
- items << results[host][:pbsnodes].state
139
- items << results[host][:pbsnodes].np unless OPTIONS[:load]
140
- items << results[host][:pbsnodes].properties unless OPTIONS[:load]
141
- items << results[host][:pbsnodes].ntype unless OPTIONS[:load]
142
- items << results[host][:pbsnodes].gpus unless OPTIONS[:load]
143
- items << results[host][:pbsnodes].status["rectime" ] unless OPTIONS[:load]
144
- items << results[host][:pbsnodes].status["varattr" ] unless OPTIONS[:load]
145
- items << results[host][:pbsnodes].status["jobs" ]
146
- items << results[host][:pbsnodes].status["state" ] unless OPTIONS[:load]
147
- items << results[host][:pbsnodes].status["netload" ] unless OPTIONS[:load]
148
- items << results[host][:pbsnodes].status["gres" ] unless OPTIONS[:load]
149
- items << results[host][:pbsnodes].status["loadave" ]
150
- items << results[host][:pbsnodes].status["ncpus" ] unless OPTIONS[:load]
151
- items << results[host][:pbsnodes].status["physmem" ] unless OPTIONS[:load]
152
- items << results[host][:pbsnodes].status["availmem" ] unless OPTIONS[:load]
153
- items << results[host][:pbsnodes].status["totmem" ] unless OPTIONS[:load]
154
- items << results[host][:pbsnodes].status["idletime" ] unless OPTIONS[:load]
155
- items << results[host][:pbsnodes].status["nusers" ] unless OPTIONS[:load]
156
- items << results[host][:pbsnodes].status["nsessions"] unless OPTIONS[:load]
157
- items << results[host][:pbsnodes].status["sessions" ] unless OPTIONS[:load]
158
- items << results[host][:pbsnodes].status["uname" ] unless OPTIONS[:load]
159
- items << results[host][:pbsnodes].status["opsys" ] unless OPTIONS[:load]
160
- else
161
- items << "pbs_unknown_host"
162
- items << "" unless OPTIONS[:load]
163
- items << "" unless OPTIONS[:load]
164
- items << "" unless OPTIONS[:load]
165
- items << "" unless OPTIONS[:load]
166
- items << "" unless OPTIONS[:load]
167
- items << "" unless OPTIONS[:load]
168
- items << ""
169
- items << "" unless OPTIONS[:load]
170
- items << "" unless OPTIONS[:load]
171
- items << "" unless OPTIONS[:load]
172
- items << ""
173
- items << "" unless OPTIONS[:load]
174
- items << "" unless OPTIONS[:load]
175
- items << "" unless OPTIONS[:load]
176
- items << "" unless OPTIONS[:load]
177
- items << "" unless OPTIONS[:load]
178
- items << "" unless OPTIONS[:load]
179
- items << "" unless OPTIONS[:load]
180
- items << "" unless OPTIONS[:load]
181
- items << "" unless OPTIONS[:load]
182
- items << "" unless OPTIONS[:load]
183
-
184
- end
185
- end
186
- data << items
187
- end
188
-
189
- data = data.unshift(titles)
190
- #pp data
191
- t = Tefil::ColumnFormer.new
192
- t.form(data, $stdout, "|")
data/bin/queueinfo DELETED
@@ -1,28 +0,0 @@
1
- #! /usr/bin/env ruby
2
-
3
-
4
- require 'thor'
5
- require 'comana'
6
- require 'pp'
7
-
8
- ### Command template
9
- class Queueinfo < Thor
10
- desc "light", "Detect the lightest queue."
11
-
12
- def lightqueue
13
- qinfo = Comana::QueueManager.new
14
- qinfo.light_queue
15
- end
16
-
17
- #def job
18
- #end
19
-
20
- def show
21
-
22
- end
23
-
24
- end
25
-
26
- Queueinfo.start(ARGV)
27
-
28
-
@@ -1,68 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- #
5
- #
6
- #
7
- class GridEngineScript
8
- #DEFAULT_QSUB_FILE = 'qsub.sh'
9
- QSUB_PATH = '/usr/bin/qsub'
10
-
11
- #
12
- def initialize()
13
- end
14
-
15
- # series: name of computers' series
16
- # ppn: number of using cores
17
- def self.generate(io, series, ppn, command)
18
- io.puts self.string(series, ppn, command)
19
- end
20
-
21
- def self.string(series, ppn, command)
22
- string = <<HERE
23
- \#! /bin/sh
24
- \#$ -S /bin/sh
25
- \#$ -cwd
26
- \#$ -o stdout
27
- \#$ -e stderr
28
- \#$ -q #{series}.q
29
- \#$ -pe #{series}.openmpi #{ppn}
30
-
31
- MACHINE_FILE="machines"
32
- ENV_FILE="printenv.log"
33
-
34
- LD_LIBRARY_PATH=/usr/lib:/usr/local/lib:/opt/intel/mkl/lib/intel64:/opt/intel/lib/intel64:/opt/intel/lib:/opt/openmpi-intel/lib
35
- export LD_LIBRARY_PATH
36
-
37
- cd $SGE_O_WORKDIR
38
- if [ -e $ENV_FILE ]; then
39
- echo "$ENV_FILE already exist. Exit."
40
- exit
41
- fi
42
- printenv | sort > printenv.log
43
- cut -d " " -f 1,2 $PE_HOSTFILE | sed 's/ / cpu=/' > $MACHINE_FILE
44
-
45
- #{command}
46
- HERE
47
- string
48
- end
49
-
50
- def self.write(series, ppn, command, io)
51
- io.puts self.string(series, ppn, command)
52
- end
53
-
54
- def self.write_submit(series, ppn, command, filename)
55
- #qsub_file = DEFAULT_QSUB_FILE
56
- io = File.open(filename, 'w')
57
- self.write(series, ppn, command, io)
58
- io.close
59
-
60
- logfile = filename.sub(/#{File.extname filename}$/, '.log')
61
- command = "#{QSUB_PATH} #{filename} > #{logfile}"
62
- #command = "qsub #{filename}"
63
- puts command
64
- system command
65
- end
66
-
67
- end
68
-
@@ -1,34 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- #
5
- #
6
- #
7
- class Comana::QueueManager
8
- #
9
- def initialize()
10
- end
11
-
12
- #
13
- def queues
14
- `qconf -sql`.split("\n")
15
- end
16
-
17
- # return a queue name with less tasks.
18
- def light_queue
19
- queues.each do |queue|
20
- hostlist(queue)
21
- end
22
-
23
- end
24
-
25
- def qhost
26
-
27
- end
28
-
29
- private
30
-
31
-
32
-
33
- end
34
-
@@ -1,156 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require "fileutils"
5
- #require "comana/computationmanager.rb"
6
- #require "comana/clustersetting.rb"
7
- #
8
- #For Torque. This class will be obsoleted.
9
-
10
- #
11
- #
12
- #
13
- class Comana::QueueSubmitter < Comana::ComputationManager
14
- SCRIPT = "script.sh"
15
- PROLOGUE = "prologue_script.sh"
16
- EPILOGUE = "epilogue_script.sh"
17
- WALLTIME = "7:00:00:00" # day:hour:minute:second
18
-
19
- class PrepareNextError < Exception; end
20
- class InitializeError < Exception; end
21
- class InvalidArgumentError < Exception; end
22
-
23
- # opts is a hash includes data belows:
24
- # :command => executable command line written in script.
25
- # :cluster => name of cluster.
26
- # :target => calculation as ComputationManager subclass.
27
- # Note that this is not target name, to check calculatable.
28
- def initialize(opts)
29
- [:target, :command].each do |symbol|
30
- raise InitializeError, "No '#{symbol}' in argument 'opts'" unless opts.has_key?(symbol)
31
- #raise InitializeError unless opts.has_key?(symbol)
32
- end
33
-
34
- super(opts[:target].dir)
35
-
36
- @command = opts[:command]
37
- @cluster = opts[:cluster]
38
- @num_nodes = opts[:num_nodes]
39
- @priority = opts[:priority]
40
- @lockdir = "lock_queuesubmitter"
41
- end
42
-
43
- def calculate
44
- # prologue
45
- prologue_path = "#{@dir}/#{PROLOGUE}"
46
- File.open(prologue_path, "w") { |io| dump_prologue(io) }
47
- FileUtils.chmod(0700, prologue_path)
48
-
49
- # epilogue
50
- epilogue_path = "#{@dir}/#{EPILOGUE}"
51
- File.open(epilogue_path, "w") { |io| dump_epilogue(io) }
52
- FileUtils.chmod(0700, epilogue_path)
53
-
54
- # script
55
- script_path = "#{@dir}/#{SCRIPT}"
56
- File.open(script_path, "w") { |io| dump_script(io) }
57
-
58
- # exec
59
- system("cd #{@dir}; qsub -l prologue=#{prologue_path} -l epilogue=#{epilogue_path} #{script_path} > jobid.log")
60
- end
61
-
62
- # Raise QueueSubmitter::PrepareNextError when called.
63
- def prepare_next
64
- raise PrepareNextError
65
- end
66
-
67
- # Return true after qsub executed.
68
- def finished?
69
- Dir.exist? @dir + "/" +@lockdir
70
- end
71
-
72
- private
73
-
74
- def dump_prologue(io = nil)
75
- str = [
76
- '#! /bin/sh',
77
- 'LOGFILE="${PBS_O_WORKDIR}/prologue_script.log"',
78
- 'echo "hostname : `hostname`" >> $LOGFILE',
79
- 'echo "job id : $1" >> $LOGFILE',
80
- 'echo "job execution user name : $2" >> $LOGFILE',
81
- 'echo "job execution group name : $3" >> $LOGFILE',
82
- 'echo "job name : $4" >> $LOGFILE',
83
- 'echo "list of requested resource limits: $5" >> $LOGFILE',
84
- 'echo "job execution queue : $6" >> $LOGFILE',
85
- 'echo "job account : $7" >> $LOGFILE',
86
- 'echo "PBS_O_WORKDIR : ${PBS_O_WORKDIR}" >> $LOGFILE',
87
- 'echo "nodes in pbs_nodefile : " >> $LOGFILE',
88
- 'cat ${PBS_NODEFILE} >> $LOGFILE',
89
- 'exit 0',
90
- ].join("\n")
91
-
92
- if io
93
- io.puts str
94
- else
95
- return str
96
- end
97
- end
98
-
99
- def dump_script(io = nil)
100
- lines = []
101
- lines << "#! /bin/sh"
102
- lines << "#PBS -N #{@dir}"
103
-
104
- if @num_nodes || @cluster
105
- tmp = []
106
- @num_nodes ||= 1
107
- tmp << "nodes=#{@num_nodes}"
108
- tmp << "ppn=1"
109
- #pp @cluster
110
- tmp << @cluster if @cluster
111
- lines << "#PBS -l #{tmp.join(":")},walltime=#{WALLTIME}"
112
- else
113
- lines << "#PBS -l walltime=#{WALLTIME}"
114
- end
115
-
116
- lines << "#PBS -p #{@priority}" if @priority
117
-
118
- lines << "#PBS -j oe"
119
- lines << ""
120
- lines << "cd ${PBS_O_WORKDIR} && \\"
121
- lines << "#{@command}"
122
-
123
- str = lines.join("\n")
124
-
125
- if io
126
- io.puts str
127
- else
128
- return str
129
- end
130
- end
131
-
132
- def dump_epilogue(io = nil)
133
- str = [
134
- '#! /bin/sh',
135
- 'LOGFILE="${PBS_O_WORKDIR}/epilogue_script.log"',
136
- 'echo "job id : $1" >> $LOGFILE',
137
- 'echo "job execution user name : $2" >> $LOGFILE',
138
- 'echo "job execution group name : $3" >> $LOGFILE',
139
- 'echo "job name : $4" >> $LOGFILE',
140
- 'echo "session id : $5" >> $LOGFILE',
141
- 'echo "list of requested resource limits: $6" >> $LOGFILE',
142
- 'echo "list of resources used by job : $7" >> $LOGFILE',
143
- 'echo "job execution queue : $8" >> $LOGFILE',
144
- 'echo "job account : $9" >> $LOGFILE',
145
- 'echo "job exit code : $10" >> $LOGFILE',
146
- 'exit 0',
147
- ].join("\n")
148
-
149
- if io
150
- io.puts str
151
- else
152
- return str
153
- end
154
- end
155
- end
156
-
data/memo.txt DELETED
@@ -1,34 +0,0 @@
1
- # Comana: COmputation MANAger
2
-
3
- Comana don't have information of output files.
4
- Because it is difficult to define final output and to deal systematically.
5
- e.g., repeated calculation till convergence.
6
-
7
- 0.0.10
8
-
9
- 0.0.9 release
10
- Change opts specification in QueueSubmitter; symbol to string
11
-
12
- 0.0.8 release
13
- Changed queuesubmitter option. (long name symbol)
14
- Add prologue and epilogue to QueueSubmitter.
15
-
16
- 0.0.7 release
17
- Bugfix of danger to rsync large directory:
18
- - bin/submitqueue is removed.
19
- - lib/queuesubmitter.rb is modified.
20
- lib/queuesubmitter.rb is modified.
21
- - finished? returns bool.
22
- - content of qsub script to use "rsync" and "mv dir ~/.trash".
23
-
24
- 0.0.6 release
25
- bin/submitqueue is add.
26
- lib/queuesubmitter.rb is add.
27
-
28
- 0.0.5 release
29
- Directory structure and file names are changed.
30
- Method names are hanged.
31
- MachineInfo is added.
32
-
33
- 0.0.4 release
34
-
@@ -1,16 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require "pp"
5
- require "helper"
6
- #require "test/unit"
7
- #require "pkg/klass.rb"
8
-
9
-
10
- class TC_GridEngineScript < Test::Unit::TestCase
11
- def setup
12
- @g00 = GridEngineScript.new
13
- end
14
-
15
- end
16
-
@@ -1,19 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require "helper"
5
- #require "test/unit"
6
- #require "pkg/klass.rb"
7
-
8
- class TC_QueueManager < Test::Unit::TestCase
9
- def setup
10
- @qm00 = Comana::QueueManager.new
11
- end
12
-
13
- def test_qhost
14
- @qm00.qhost
15
-
16
- end
17
-
18
- end
19
-