Class: Rub2::Manager
- Inherits:
-
Object
- Object
- Rub2::Manager
- Defined in:
- lib/rub2.rb
Instance Method Summary collapse
- #array_request(req) ⇒ Object
- #continue_on_error ⇒ Object
- #dry_run ⇒ Object
-
#execute_with(first, *rest, &block) ⇒ Object
example: execute_with array (, arrays) do |arg1 (, args…)| return command_string end.
-
#get_executed_command(job_id) ⇒ Object
accessor.
- #inherit_environment ⇒ Object
-
#initialize(name) ⇒ Manager
constructor
A new instance of Manager.
-
#log(log_path) ⇒ Object
job options.
- #max_retry(count) ⇒ Object
-
#on_done(&block) ⇒ Object
example: on_done ‘done’.
-
#on_fail(&block) ⇒ Object
example: on_fail {|results| p results}.
- #queue(q) ⇒ Object
- #resource(res = {}) ⇒ Object
- #shell(intep) ⇒ Object
-
#slot_limit(limit) ⇒ Object
slot limit doent’t work on torque.
-
#submit ⇒ Object
exec qsub.
- #wait_finish ⇒ Object
Constructor Details
Instance Method Details
#array_request(req) ⇒ Object
344 345 346 |
# File 'lib/rub2.rb', line 344 def array_request(req) @script.array_request = req end |
#continue_on_error ⇒ Object
365 366 367 |
# File 'lib/rub2.rb', line 365 def continue_on_error @continue_on_error = true end |
#dry_run ⇒ Object
353 354 355 |
# File 'lib/rub2.rb', line 353 def dry_run @dry_run = true end |
#execute_with(first, *rest, &block) ⇒ Object
example: execute_with array (, arrays) do |arg1 (, args…)|
return command_string
end
309 310 311 312 313 314 315 316 |
# File 'lib/rub2.rb', line 309 def execute_with(first, *rest, &block) commands = [] first.zip(*rest) do |i| cmd = block.call(*i) commands.push cmd if cmd end @script.commands = commands end |
#get_executed_command(job_id) ⇒ Object
accessor
375 376 377 |
# File 'lib/rub2.rb', line 375 def get_executed_command(job_id) return @script.commands[job_id - 1] end |
#inherit_environment ⇒ Object
357 358 359 |
# File 'lib/rub2.rb', line 357 def inherit_environment @script.inherit_environment = true end |
#log(log_path) ⇒ Object
job options
332 333 334 |
# File 'lib/rub2.rb', line 332 def log(log_path) @script.log_path = Pathname.new(log_path) end |
#max_retry(count) ⇒ Object
369 370 371 |
# File 'lib/rub2.rb', line 369 def max_retry(count) @max_retry_count = count end |
#on_done(&block) ⇒ Object
example: on_done ‘done’
326 327 328 |
# File 'lib/rub2.rb', line 326 def on_done(&block) @done_proc = block end |
#on_fail(&block) ⇒ Object
example: on_fail {|results| p results}
321 322 323 |
# File 'lib/rub2.rb', line 321 def on_fail(&block) @fail_proc = block end |
#queue(q) ⇒ Object
361 362 363 |
# File 'lib/rub2.rb', line 361 def queue(q) @script.queue = q end |
#resource(res = {}) ⇒ Object
340 341 342 |
# File 'lib/rub2.rb', line 340 def resource(res = {}) @script.resource = res end |
#shell(intep) ⇒ Object
336 337 338 |
# File 'lib/rub2.rb', line 336 def shell(intep) @script.shell = intep end |
#slot_limit(limit) ⇒ Object
slot limit doent’t work on torque
349 350 351 |
# File 'lib/rub2.rb', line 349 def slot_limit(limit) @script.slot_limit = limit end |
#submit ⇒ Object
exec qsub
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
# File 'lib/rub2.rb', line 382 def submit unless @dry_run @script.log_path.dirname.mkpath unless @script.log_path.dirname.exist? @script.uri = start_tuplespace end @script.build if @dry_run puts @script.source return end if @script.commands.empty? raise "Empty commands" return end @jobid << submit_qsub(@script.source) @job_store.init_job(@jobid.first, @script.array_request, @max_retry_count) end |
#wait_finish ⇒ Object
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
# File 'lib/rub2.rb', line 404 def wait_finish return true if @dry_run results = polling_loop if results.all? {|aid, ret| ret == 0} if @done_proc @done_proc.call else Rub2.putlog "job succeeded" end return true end if @fail_proc @fail_proc.call(results) else results.each do |aid, ret| unless ret == 0 Rub2.putlog "array job[#{aid}] failed: #{ret}" end end end return false if @continue_on_error Rub2.putlog "job failed: #{@jobid.join(',')}" exit false end |