nera 0.2.1 → 0.2.2
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/History.txt +5 -0
- data/README.rdoc +1 -1
- data/lib/nera/nera_cui.rb +1 -1
- data/lib/nera/nera_job_layer_controller.rb +2 -2
- data/lib/nera/nera_job_script.rb +2 -2
- data/lib/nera/nera_parameter_layer_controller.rb +6 -4
- data/lib/nera/nera_remote_connector.rb +39 -28
- data/lib/nera.rb +1 -1
- data/lib/nera_addhost/add_hosts.rb +2 -2
- data/lib/nera_addsim/make_simulator.rb +2 -2
- data/test/test_nera_remote_connector.rb +3 -22
- metadata +3 -3
data/History.txt
CHANGED
data/README.rdoc
CHANGED
data/lib/nera/nera_cui.rb
CHANGED
@@ -252,7 +252,7 @@ HEADER
|
|
252
252
|
}
|
253
253
|
return :run_layer
|
254
254
|
when "Create jobs"
|
255
|
-
num_job = Dialog::get_integer( "Input the number of jobs (must be equal or
|
255
|
+
num_job = Dialog::get_integer( "Input the number of jobs (must be equal or larger than zero)") { |i| i >= 0 }
|
256
256
|
return :run_layer if num_job == 0
|
257
257
|
num_run_per_job = Dialog::get_integer( "Input the number of runs per job (must be larger than zero)") { |i| i > 0 }
|
258
258
|
jobids = rlc.create_jobs( num_job, num_run_per_job)
|
@@ -113,8 +113,8 @@ module NERA
|
|
113
113
|
next if File.directory?( @db_folders.path_to_include_layer+File.basename( js_path).sub(/\.sh$/,'') ) or File.exist?( @db_folders.path_to_include_layer + File.basename( js_path).sub(/\.sh$/,'.tar.bz2'))
|
114
114
|
Dir.chdir( @db_folders.path_to_include_layer) {
|
115
115
|
system "nohup #{js_path} &"
|
116
|
-
submitted_jobs << jid
|
117
116
|
}
|
117
|
+
submitted_jobs << jid
|
118
118
|
@job_records.update_to_state_submitted( jid, "localhost")
|
119
119
|
@db_folders.logger.info( self.class.to_s) {
|
120
120
|
"submitted a job (jobid:#{jid}) to localhost"
|
@@ -162,7 +162,7 @@ module NERA
|
|
162
162
|
system(cmd)
|
163
163
|
raise "command : #{cmd} failed" unless $? == 0
|
164
164
|
tarpath = bz2_path.sub(/.bz2$/,'')
|
165
|
-
cmd = "tar
|
165
|
+
cmd = "tar xf #{tarpath}"
|
166
166
|
system(cmd)
|
167
167
|
raise "command : #{cmd} failed" unless $? == 0
|
168
168
|
stat_path = tarpath.sub(/.tar$/,'/nera_status.rb')
|
data/lib/nera/nera_job_script.rb
CHANGED
@@ -44,7 +44,7 @@ echo \" :parameters => {\" >> nera_status.rb
|
|
44
44
|
BODY
|
45
45
|
|
46
46
|
job_info[:params].each_pair do |key, value|
|
47
|
-
job_script += "echo \" #{key.to_sym.inspect} => #{value.inspect.gsub(/\"/,'\"')},\" >> nera_status.rb\n"
|
47
|
+
job_script += "echo \" #{key.to_sym.inspect.gsub(/\"/,'\"')} => #{value.inspect.gsub(/\"/,'\"')},\" >> nera_status.rb\n"
|
48
48
|
end
|
49
49
|
|
50
50
|
job_script +=<<"BODY"
|
@@ -63,7 +63,7 @@ echo \" #{run_id} => {\" >> nera_status.rb
|
|
63
63
|
echo \" :seed => #{job_info[:seeds][i]}, :start_at => DateTime.parse( <<'NERA_START_AT'.chomp), :output => <<'NERA_OUTPUT', :finish_at => DateTime.parse( <<'NERA_FINISH_AT'.chomp)\" >> nera_status.rb
|
64
64
|
date >> nera_status.rb
|
65
65
|
echo \"NERA_START_AT\" >> nera_status.rb
|
66
|
-
echo \"#{job_info[:execs][i]}\"
|
66
|
+
echo \"#{job_info[:execs][i]}\" >&2
|
67
67
|
mkdir -p #{run_id}
|
68
68
|
cd #{run_id}
|
69
69
|
{ time -p { #{job_info[:execs][i]};} } 2>> ../nera_status.rb
|
@@ -99,8 +99,8 @@ module NERA
|
|
99
99
|
flag = @param_records.update_to_state_trashbox(id)
|
100
100
|
return nil unless flag
|
101
101
|
r_path = @db_folders.path_to_run_layer( @sim_class, id).sub(/\/$/,'')
|
102
|
-
cmd = "tar
|
103
|
-
system(cmd)
|
102
|
+
cmd = "tar cjf #{File.basename(r_path)}.tar.bz2 #{File.basename(r_path)}"
|
103
|
+
Dir.chdir( File.dirname(r_path)) { system(cmd) }
|
104
104
|
raise "Command #{cmd} failed" unless $? == 0
|
105
105
|
FileUtils.rm_r(r_path)
|
106
106
|
@db_folders.logger.info(self.class.to_s) {
|
@@ -138,8 +138,10 @@ module NERA
|
|
138
138
|
flag = @param_records.update_to_state_active(id)
|
139
139
|
return nil unless flag
|
140
140
|
r_path = @db_folders.path_to_run_layer( @sim_class, id).sub(/\/$/,'')
|
141
|
-
cmd = "tar
|
142
|
-
|
141
|
+
cmd = "tar xjf #{File.basename(r_path)}.tar.bz2"
|
142
|
+
Dir.chdir( File.dirname(r_path) ) {
|
143
|
+
system(cmd)
|
144
|
+
}
|
143
145
|
raise "Command #{cmd} failed" unless $? == 0
|
144
146
|
FileUtils.rm(r_path+".tar.bz2")
|
145
147
|
@db_folders.logger.info(self.class.to_s) {
|
@@ -62,13 +62,14 @@ module NERA
|
|
62
62
|
return arr
|
63
63
|
end
|
64
64
|
|
65
|
-
def show_status( hostname)
|
65
|
+
def show_status( hostname, passphrase = nil)
|
66
66
|
found = @hosts.find do |host|
|
67
67
|
host[:name] == hostname
|
68
68
|
end
|
69
69
|
return :connection_failed unless found
|
70
70
|
h = { :port => found[:port], :timeout => 10 }
|
71
71
|
h[:keys] = found[:keys] if found.has_key?(:keys)
|
72
|
+
h[:passphrase] = passphrase if passphrase
|
72
73
|
cmd = 'ps au'
|
73
74
|
cmd = found[:show_status_command] if found.has_key?(:show_status_command)
|
74
75
|
str = ''
|
@@ -79,26 +80,26 @@ module NERA
|
|
79
80
|
end
|
80
81
|
rescue Errno::ECONNREFUSED => ex
|
81
82
|
$stderr.puts "failed"
|
82
|
-
@db_folders.logger.error(self.class.to_s) {
|
83
|
+
@db_folders.logger.error(self.class.to_s) { Errno::ECONNREFUSED }
|
83
84
|
return :connection_failed
|
84
85
|
rescue Errno::ENETUNREACH => ex
|
85
86
|
$stderr.puts "failed"
|
86
|
-
@db_folders.logger.error(self.class.to_s) {
|
87
|
+
@db_folders.logger.error(self.class.to_s) { Errno::ENETUNREACH }
|
87
88
|
return :connection_failed
|
88
89
|
rescue SocketError => ex
|
89
90
|
$stderr.puts "failed"
|
90
|
-
@db_folders.logger.error(self.class.to_s) {
|
91
|
+
@db_folders.logger.error(self.class.to_s) { SocketError }
|
91
92
|
return :connection_failed
|
92
93
|
rescue Net::SSH::Exception => ex
|
93
94
|
$stderr.puts "failed"
|
94
|
-
@db_folders.logger.error(self.class.to_s) {
|
95
|
+
@db_folders.logger.error(self.class.to_s) { Net::SSH::Exception }
|
95
96
|
return :connection_failed
|
96
97
|
end
|
97
98
|
$stderr.puts "done"
|
98
99
|
return str
|
99
100
|
end
|
100
101
|
|
101
|
-
def transfer( jobids, hostname)
|
102
|
+
def transfer( jobids, hostname, passphrase = nil)
|
102
103
|
raise ArgumentError unless jobids.is_a?(Array)
|
103
104
|
jobids.each do |jid|
|
104
105
|
raise ArgumentError unless jid.is_a?(Integer)
|
@@ -107,6 +108,8 @@ module NERA
|
|
107
108
|
|
108
109
|
host = @hosts.find do |h| h[:name] == hostname end
|
109
110
|
return :connection_failed unless host
|
111
|
+
|
112
|
+
succeeded_jobids = []
|
110
113
|
|
111
114
|
@job_records.transaction {
|
112
115
|
jids = []
|
@@ -116,8 +119,9 @@ module NERA
|
|
116
119
|
return :no_such_jobs if jids.size == 0
|
117
120
|
|
118
121
|
h = { :port => host[:port] }
|
122
|
+
h[:passphrase] = passphrase if passphrase
|
119
123
|
h[:keys] = host[:keys] if host.has_key?(:keys)
|
120
|
-
|
124
|
+
|
121
125
|
begin
|
122
126
|
$stderr.print "Connecting with #{host[:name]}.....\t"
|
123
127
|
Net::SSH.start( host[:host_url], host[:user], h) do |ssh|
|
@@ -138,29 +142,30 @@ module NERA
|
|
138
142
|
@db_folders.logger.info(self.class.to_s) {
|
139
143
|
"transfered a file (#{File.basename(pjs)}) to #{host[:name]}"
|
140
144
|
}
|
145
|
+
succeeded_jobids << jid
|
141
146
|
end
|
142
147
|
end
|
143
148
|
end
|
144
149
|
rescue Errno::ECONNREFUSED => ex
|
145
150
|
$stderr.puts "failed"
|
146
|
-
@db_folders.logger.error(self.class.to_s) { ex.
|
151
|
+
@db_folders.logger.error(self.class.to_s) { ex.inspect }
|
147
152
|
return :connection_failed
|
148
153
|
rescue Errno::ENETUNREACH => ex
|
149
154
|
$stderr.puts "failed"
|
150
|
-
@db_folders.logger.error(self.class.to_s) { ex.
|
155
|
+
@db_folders.logger.error(self.class.to_s) { ex.inspect }
|
151
156
|
return :connection_failed
|
152
157
|
rescue SocketError => ex
|
153
158
|
$stderr.puts "failed"
|
154
|
-
@db_folders.logger.error(self.class.to_s) { ex.
|
159
|
+
@db_folders.logger.error(self.class.to_s) { ex.inspect }
|
155
160
|
return :connection_failed
|
156
161
|
rescue Net::SSH::Exception => ex
|
157
162
|
$stderr.puts "failed"
|
158
|
-
@db_folders.logger.error(self.class.to_s) { ex.
|
163
|
+
@db_folders.logger.error(self.class.to_s) { ex.inspect }
|
159
164
|
return :connection_failed
|
160
165
|
end
|
161
166
|
$stderr.puts "done"
|
162
167
|
}
|
163
|
-
return
|
168
|
+
return succeeded_jobids
|
164
169
|
end
|
165
170
|
|
166
171
|
private
|
@@ -169,7 +174,7 @@ module NERA
|
|
169
174
|
end
|
170
175
|
|
171
176
|
public
|
172
|
-
def submit( jobids, hostname)
|
177
|
+
def submit( jobids, hostname, passphrase = nil)
|
173
178
|
raise ArgumentError unless jobids.is_a?(Array)
|
174
179
|
jobids.each do |jid|
|
175
180
|
raise ArgumentError unless jid.is_a?(Integer)
|
@@ -180,7 +185,8 @@ module NERA
|
|
180
185
|
return :connection_failed unless host
|
181
186
|
|
182
187
|
return :no_submission_command unless host.has_key?(:submission_command)
|
183
|
-
|
188
|
+
|
189
|
+
succeeded_jobids = []
|
184
190
|
@job_records.transaction {
|
185
191
|
jids = []
|
186
192
|
jobids.each do |jid|
|
@@ -189,7 +195,9 @@ module NERA
|
|
189
195
|
return :no_such_jobs if jids.size == 0
|
190
196
|
|
191
197
|
h = { :port => host[:port] }
|
198
|
+
h[:passphrase] = passphrase if passphrase
|
192
199
|
h[:keys] = host[:keys] if host.has_key?(:keys)
|
200
|
+
|
193
201
|
|
194
202
|
begin
|
195
203
|
$stderr.print "Connecting with #{host[:name]}.....\t"
|
@@ -208,43 +216,45 @@ module NERA
|
|
208
216
|
sftp.file.open(target_path, "w") do |f| f.puts contents end
|
209
217
|
ssh.exec!("chmod +x #{target_path}")
|
210
218
|
@job_records.update_to_state_copied( jid, host[:name])
|
211
|
-
ssh.exec!("cd #{target_dir} && #{host[:submission_command]} #{target_path}
|
219
|
+
ssh.exec!("cd #{target_dir} && #{host[:submission_command]} #{target_path}")
|
212
220
|
@job_records.update_to_state_submitted( jid, host[:name])
|
213
221
|
@db_folders.logger.info(self.class.to_s) {
|
214
222
|
"submitted a file (#{File.basename(pjs)}) to #{host[:name]}"
|
215
223
|
}
|
224
|
+
succeeded_jobids << jid
|
216
225
|
end
|
217
226
|
end
|
218
227
|
end
|
219
228
|
rescue Errno::ECONNREFUSED => ex
|
220
229
|
$stderr.puts "failed"
|
221
|
-
@db_folders.logger.error(self.class.to_s) { ex.
|
230
|
+
@db_folders.logger.error(self.class.to_s) { ex.inspect }
|
222
231
|
return :connection_failed
|
223
232
|
rescue Errno::ENETUNREACH => ex
|
224
233
|
$stderr.puts "failed"
|
225
|
-
@db_folders.logger.error(self.class.to_s) { ex.
|
234
|
+
@db_folders.logger.error(self.class.to_s) { ex.inspect }
|
226
235
|
return :connection_failed
|
227
236
|
rescue SocketError => ex
|
228
237
|
$stderr.puts "failed"
|
229
|
-
@db_folders.logger.error(self.class.to_s) { ex.
|
238
|
+
@db_folders.logger.error(self.class.to_s) { ex.inspect }
|
230
239
|
return :connection_failed
|
231
240
|
rescue Net::SSH::Exception => ex
|
232
241
|
$stderr.puts "failed"
|
233
|
-
@db_folders.logger.error(self.class.to_s) { ex.
|
242
|
+
@db_folders.logger.error(self.class.to_s) { ex.inspect }
|
234
243
|
return :connection_failed
|
235
244
|
end
|
236
245
|
$stderr.puts "done"
|
237
246
|
}
|
238
|
-
return
|
247
|
+
return succeeded_jobids
|
239
248
|
end
|
240
249
|
|
241
|
-
def check_completion( hostname)
|
250
|
+
def check_completion( hostname, passphrase = nil)
|
242
251
|
raise ArgumentError unless hostname.is_a?(String)
|
243
252
|
|
244
253
|
host = @hosts.find do |h| h[:name] == hostname end
|
245
254
|
return :connection_failed unless host
|
246
255
|
|
247
256
|
h = { :port => host[:port] }
|
257
|
+
h[:passphrase] = passphrase if passphrase
|
248
258
|
h[:keys] = host[:keys] if host.has_key?(:keys)
|
249
259
|
|
250
260
|
ls_str = ''
|
@@ -287,16 +297,16 @@ module NERA
|
|
287
297
|
end
|
288
298
|
|
289
299
|
public
|
290
|
-
def check_completion_all
|
300
|
+
def check_completion_all( passphrase = nil)
|
291
301
|
h = {}
|
292
302
|
hostnames.each do |hname|
|
293
|
-
h[hname] = check_completion(hname)
|
303
|
+
h[hname] = check_completion(hname, passphrase)
|
294
304
|
end
|
295
305
|
return h
|
296
306
|
end
|
297
307
|
|
298
308
|
|
299
|
-
def download( filenames, hostname)
|
309
|
+
def download( filenames, hostname, passphrase = nil)
|
300
310
|
raise ArgumentError unless filenames.is_a?(Array)
|
301
311
|
filenames.each do |fname|
|
302
312
|
raise ArgumentError unless fname.is_a?(String)
|
@@ -308,6 +318,7 @@ module NERA
|
|
308
318
|
return :connection_failed unless host
|
309
319
|
|
310
320
|
h = { :port => host[:port] }
|
321
|
+
h[:passphrase] = passphrase if passphrase
|
311
322
|
h[:keys] = host[:keys] if host.has_key?(:keys)
|
312
323
|
|
313
324
|
downloaded = []
|
@@ -343,19 +354,19 @@ module NERA
|
|
343
354
|
end
|
344
355
|
rescue Errno::ECONNREFUSED => ex
|
345
356
|
$stderr.puts "failed"
|
346
|
-
@db_folders.logger.error(self.class.to_s) { ex.
|
357
|
+
@db_folders.logger.error(self.class.to_s) { ex.inspect }
|
347
358
|
return :connection_failed
|
348
359
|
rescue Errno::ENETUNREACH => ex
|
349
360
|
$stderr.puts "failed"
|
350
|
-
@db_folders.logger.error(self.class.to_s) { ex.
|
361
|
+
@db_folders.logger.error(self.class.to_s) { ex.inspect }
|
351
362
|
return :connection_failed
|
352
363
|
rescue SocketError => ex
|
353
364
|
$stderr.puts "failed"
|
354
|
-
@db_folders.logger.error(self.class.to_s) { ex.
|
365
|
+
@db_folders.logger.error(self.class.to_s) { ex.inspect }
|
355
366
|
return :connection_failed
|
356
367
|
rescue Net::SSH::Exception => ex
|
357
368
|
$stderr.puts "failed"
|
358
|
-
@db_folders.logger.error(self.class.to_s) { ex.
|
369
|
+
@db_folders.logger.error(self.class.to_s) { ex.inspect }
|
359
370
|
return :connection_failed
|
360
371
|
end
|
361
372
|
$stderr.puts "done"
|
data/lib/nera.rb
CHANGED
@@ -6,9 +6,9 @@ module NERA
|
|
6
6
|
|
7
7
|
class CUI_Hosts_Editor
|
8
8
|
|
9
|
-
HOST_INFO = [ [:host_url,String,"
|
9
|
+
HOST_INFO = [ [:host_url,String,"host_url"], [:user,String,ENV['USER']], [:job_path,String,"~/"],
|
10
10
|
[:port,Integer,22], [:keys,String,"~/.ssh/id_rsa"],
|
11
|
-
[:submission_command,String,"
|
11
|
+
[:submission_command,String,"qsub"], [:show_status_command,String,"qstat"]]
|
12
12
|
|
13
13
|
|
14
14
|
#----- the unique module funciton -----
|
@@ -41,7 +41,6 @@ BODY
|
|
41
41
|
$stdout.puts "Input the simulator name again."
|
42
42
|
end
|
43
43
|
return ["seed",nil,nil] if name == "seed"
|
44
|
-
#array << ":#{name}"
|
45
44
|
array << name.to_sym.inspect
|
46
45
|
$stdout.puts
|
47
46
|
num = Dialog.select_one(type, "++Select parameter type+++")
|
@@ -115,7 +114,8 @@ BODY
|
|
115
114
|
$stdout.puts "Input the simulator name again."
|
116
115
|
end
|
117
116
|
return ["seed",nil,nil] if name == "seed"
|
118
|
-
param[0] = ":#{name}"
|
117
|
+
# param[0] = ":#{name}"
|
118
|
+
param[0] = name.to_sym.inspect
|
119
119
|
when 2
|
120
120
|
$stdout.puts
|
121
121
|
num = Dialog.select_one(type, "+++Select new parameter type+++ \n #{param[1]} ->")
|
@@ -18,7 +18,7 @@ class TC_NERA_RM_CONNECTOR < Test::Unit::TestCase
|
|
18
18
|
|
19
19
|
@hosts = []
|
20
20
|
@hosts << { :name => "localhost",:host_url => "localhost",:user => ENV['USER'], :job_path => FileUtils.pwd + '/job1'}
|
21
|
-
@hosts << { :name => "localhost_submittable",:host_url => "localhost",:user => ENV['USER'], :job_path => FileUtils.pwd + '/job2', :submission_command =>
|
21
|
+
@hosts << { :name => "localhost_submittable",:host_url => "localhost",:user => ENV['USER'], :job_path => FileUtils.pwd + '/job2', :submission_command => 'nohup', :show_status_command => 'ps au' }
|
22
22
|
@hosts << { :name => "unconnectable",:host_url => "unconnectable_host",:user => "hoge", :job_path => '~/job_test', :submission_command => 'qsub', :show_status_command => 'qstat; qstatlist;'}
|
23
23
|
File.open( @dbf.path_to_hosts_yaml, 'w') do |io|
|
24
24
|
YAML.dump( @hosts, io)
|
@@ -85,7 +85,7 @@ class TC_NERA_RM_CONNECTOR < Test::Unit::TestCase
|
|
85
85
|
assert_equal( s2+1, s3)
|
86
86
|
|
87
87
|
ret = @rc.transfer( [1,2], "localhost")
|
88
|
-
assert_equal(
|
88
|
+
assert_equal( [1,2], ret)
|
89
89
|
s3 = File.open(logp,'r').readlines.size
|
90
90
|
assert_equal( s2+3, s3)
|
91
91
|
|
@@ -138,7 +138,7 @@ class TC_NERA_RM_CONNECTOR < Test::Unit::TestCase
|
|
138
138
|
assert_equal( s1+1, s2)
|
139
139
|
|
140
140
|
ret = @rc.submit( [1,2], "localhost_submittable")
|
141
|
-
assert_equal(
|
141
|
+
assert_equal( [1,2], ret)
|
142
142
|
s2 = File.open(logp,'r').readlines.size
|
143
143
|
assert_equal( s1+3, s2)
|
144
144
|
|
@@ -242,23 +242,4 @@ class TC_NERA_RM_CONNECTOR < Test::Unit::TestCase
|
|
242
242
|
assert( FileTest.exist?(@db_folder+"/Jobs/Include/j000002.tar.bz2") )
|
243
243
|
end
|
244
244
|
|
245
|
-
=begin
|
246
|
-
def test_remote
|
247
|
-
@hosts << { :name => "cruijff",:host_url => "cruijff.t.u-tokyo.ac.jp",:user => 'murase', :job_path => '~/job1', :submission_command => 'qsub', :show_status_command => 'qstatlist'}
|
248
|
-
File.open( "hosts.yml", 'w') do |io|
|
249
|
-
YAML.dump( @hosts, io)
|
250
|
-
io.flush
|
251
|
-
end
|
252
|
-
@rc = NERA::RemoteConnector.new( @db_folder, "hosts.yml")
|
253
|
-
|
254
|
-
puts @rc.show_status("cruijff")
|
255
|
-
|
256
|
-
@rc.submit( [1,2], "cruijff")
|
257
|
-
sleep 3
|
258
|
-
a = @rc.check_completion("cruijff")
|
259
|
-
@rc.download( a, "cruijff")
|
260
|
-
|
261
|
-
end
|
262
|
-
=end
|
263
|
-
|
264
245
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nera
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yohsuke Murase
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05
|
12
|
+
date: 2009-08-05 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 1.
|
43
|
+
version: 1.4.1
|
44
44
|
version:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: hoe
|