rbbt-util 5.29.2 → 5.30.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,11 +21,12 @@ $slurm_options = SOPT.get <<EOF
21
21
  -CS--contain_and_sync Contain and sync to default locations
22
22
  -ci--copy_image When using a container directory, copy image there
23
23
  -t--tail Tail the logs
24
+ -SPERF--SLURM_procpath* Save Procpath performance for SLURM job; specify only options
24
25
  -q--queue* Queue
25
26
  -t--task_cpus* Tasks
26
27
  -W--workflows* Additional workflows
27
28
  -tm--time* Time
28
- -R--orchestration_rules* Orchestration rules
29
+ -OR--orchestration_rules* Orchestration rules
29
30
  -rmb--remove_slurm_basedir Remove the SLURM working directory (command, STDIN, exit status, ...)
30
31
  EOF
31
32
 
@@ -43,5 +44,5 @@ class Step
43
44
  end
44
45
  end
45
46
 
46
- ARGV.concat ["-W", $slurm_options[:workflows]] if $slurm_options[:workflows]
47
+ ARGV.concat ["-W", $slurm_options[:workflows], '--detach'] if $slurm_options[:workflows]
47
48
  load Rbbt.share.rbbt_commands.workflow.task.find
@@ -20,6 +20,7 @@ $slurm_options = SOPT.get <<EOF
20
20
  -CS--contain_and_sync Contain and sync to default locations
21
21
  -ci--copy_image When using a container directory, copy image there
22
22
  -t--tail Tail the logs
23
+ -SPERF--SLURM_procpath* Save Procpath performance for SLURM job; specify only options
23
24
  -q--queue* Queue
24
25
  -t--task_cpus* Tasks
25
26
  -W--workflows* Additional workflows
@@ -35,7 +35,7 @@ file = case file
35
35
  fields = options[:fields]
36
36
  raise ParameterException, "Please specify the fields to slice" if fields.nil?
37
37
 
38
- options[:header_hash] = options["header_hash"]
38
+ options[:header_hash] ||= options["header_hash"]
39
39
 
40
40
  case
41
41
  when options[:tokyocabinet]
@@ -45,8 +45,8 @@ when options[:tokyocabinet_bd]
45
45
  tsv = Persist.open_tokyocabinet(file, false, nil, TokyoCabinet::BDB)
46
46
  puts tsv.summary
47
47
  else
48
- stream = TSV.traverse file, options.merge(:into => :stream, :type => :list, :keys => fields, :unnamed => true) do |*p|
49
- p * "\t"
48
+ stream = TSV.traverse file, options.merge(:into => :stream, :type => :list, :fields => fields.split(","), :unnamed => true) do |k,fields,names|
49
+ [k,fields].flatten * "\t"
50
50
  end
51
51
  puts stream.read
52
52
  exit 0
@@ -86,7 +86,7 @@ messages = info[:messages]
86
86
  backtrace = info[:backtrace]
87
87
  pid = info[:pid]
88
88
  exception = info[:exception]
89
- rest = info.keys - [:inputs, :dependencies, :status, :time_elapsed, :messages, :backtrace, :exception, :pid, :archived_info]
89
+ rest = info.keys - [:inputs, :dependencies, :status, :time_elapsed, :messages, :backtrace, :exception, :archived_info]
90
90
 
91
91
 
92
92
  puts Log.color(:magenta, "File") << ": " << step.path
@@ -20,7 +20,7 @@ def usage(workflow = nil, task = nil, exception=nil, abridge = false)
20
20
  puts
21
21
  if workflow.nil?
22
22
  puts "No workflow specified. Use `rbbt workflow list` to list available workflows."
23
- exit -1
23
+ exit! -1
24
24
  end
25
25
 
26
26
  if task.nil?
@@ -203,10 +203,11 @@ The `recursive_clean` cleans all the job dependency steps recursively.
203
203
  -prec--prepare_cpus* Number of dependencies prepared in parallel
204
204
  -rwt--remote_workflow_tasks* Load a yaml file describing remote workflow tasks
205
205
  -od--override_deps* Override deps using 'Workflow#task=<path>' array_separated
206
+ -PERF--procpath_performance* Measure performance using procpath
206
207
  EOF
207
208
 
208
209
  workflow = ARGV.shift
209
- usage and exit -1 if workflow.nil?
210
+ usage and exit! -1 if workflow.nil?
210
211
 
211
212
  task = ARGV.shift
212
213
 
@@ -232,7 +233,8 @@ else
232
233
  remote_workflows = {}
233
234
  end
234
235
 
235
- Workflow.workdir = Path.setup(File.expand_path(options.delete(:workdir_all))) if options[:workdir_all]
236
+ #Workflow.workdir = Path.setup(File.expand_path(options.delete(:workdir_all))) if options[:workdir_all]
237
+ Workflow.workdir.search_paths.merge!({:workdir => File.expand_path(options.delete(:workdir_all)), :default => :workdir }) if options[:workdir_all]
236
238
 
237
239
  workflow = Workflow.require_workflow workflow
238
240
 
@@ -406,6 +408,23 @@ begin
406
408
  exit 0
407
409
  end
408
410
 
411
+ if options[:procpath_performance]
412
+ require 'rbbt/util/procpath'
413
+ current_pid = job.info[:pid]
414
+ job.fork
415
+ job.soft_grace
416
+ sleep 2 if job.info[:pid] == current_pid
417
+ if job.info[:pid] != current_pid
418
+ pid = job.info[:pid]
419
+ begin
420
+ ProcPath.monitor(pid, options[:procpath_performance])
421
+ rescue Errno::ECHILD
422
+ Log.warn "Procpath didn't find process #{pid} to monitor. Maybe it finished already"
423
+ rescue
424
+ Log.warn "Procpath failed: #{$!.message}"
425
+ end
426
+ end
427
+ end
409
428
 
410
429
  if do_fork
411
430
  ENV["RBBT_NO_PROGRESS"] = "true"
@@ -422,7 +441,6 @@ begin
422
441
  res = job
423
442
  end
424
443
 
425
-
426
444
  if options.delete(:printpath)
427
445
  job.join
428
446
  raise job.messages.last if (job.error? || job.aborted?) && job.messages
@@ -486,7 +504,7 @@ rescue ParameterException
486
504
  puts
487
505
  report_options saved_job_options
488
506
  puts
489
- exit -1
507
+ exit! -1
490
508
  end
491
509
 
492
510
  if options.delete(:list_job_files)
@@ -538,7 +556,7 @@ when Step
538
556
  io.abort if io.respond_to? :abort
539
557
  io.join if io.respond_to? :join
540
558
  ensure
541
- exit -1
559
+ exit! -1
542
560
  end
543
561
  rescue Exception
544
562
  Log.exception $!
@@ -547,9 +565,11 @@ when Step
547
565
  io.abort if io.respond_to? :abort
548
566
  io.join if io.respond_to? :join
549
567
  ensure
550
- exit -1
568
+ exit! -1
551
569
  end
552
570
  end
571
+ elsif detach
572
+ exit! 0
553
573
  else
554
574
  res.join
555
575
  out.puts Open.read(res.path) if Open.exist?(res.path) || Open.remote?(res.path) || Open.ssh?(res.path)
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rbbt/workflow'
4
+
5
+ require 'rbbt-util'
6
+ require 'rbbt-util'
7
+ require 'rbbt/util/simpleopt'
8
+
9
+ $0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands
10
+
11
+ options = SOPT.setup <<EOF
12
+ Examine the info of a job result
13
+
14
+ $ rbbt workflow info <job-result> <key> <value>
15
+
16
+ -h--help Help
17
+ -f--force Write info even if key is already present
18
+ -r--recursive Write info for all dependencies as well
19
+ -p--check_pid Check that recursive jobs where created by the same process
20
+ EOF
21
+
22
+ SOPT.usage if options[:help]
23
+
24
+ file, key, value = ARGV
25
+
26
+ force, recursive, check_pid = options.values_at :force, :recursive, :check_pid
27
+
28
+ def get_step(file)
29
+ file = file.sub(/\.(info|files)/,'')
30
+ step = Workflow.load_step file
31
+ step
32
+ end
33
+
34
+ raise ParameterException if key.nil? || value.nil?
35
+
36
+ if %w(DELETE nil).include? value
37
+ value = nil
38
+ force = true
39
+ end
40
+
41
+ step = get_step file
42
+
43
+ step.set_info key, value if force || ! step.info.include?(key)
44
+
45
+ pid = step.info[:pid]
46
+ host = step.info[:pid_hostname]
47
+
48
+ step.rec_dependencies.each do |dep|
49
+ dep.set_info key, value if (force || ! dep.info.include?(key)) && (!check_pid || dep.info[:pid].to_s == pid and dep.info[:pid_hostname] == host)
50
+ rescue
51
+ Log.warn "Could no set info #{key} for #{dep.path}: #{$!.message}"
52
+ end if recursive
@@ -0,0 +1,23 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helper.rb')
2
+ require 'rbbt/util/procpath'
3
+
4
+ class TestProcPath < Test::Unit::TestCase
5
+ def test_record_and_plot
6
+ Log.with_severity 0 do
7
+ pid = Process.fork do
8
+ a = ""
9
+ (0..1000).each do
10
+ a << (0..rand(10000).to_i).to_a.collect{|i| "TEST #{i}" } * " "
11
+ sleep 0.1
12
+ end
13
+ end
14
+
15
+ TmpFile.with_file(nil, false) do |db|
16
+
17
+ ProcPath.record(pid, db, :interval => '1', "recnum" => 100)
18
+ ProcPath.plot(db, db + '.svg', "moving-average-window" => 1 )
19
+ end
20
+ end
21
+ end
22
+ end
23
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.29.2
4
+ version: 5.30.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-18 00:00:00.000000000 Z
11
+ date: 2021-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -300,6 +300,7 @@ files:
300
300
  - lib/rbbt/util/misc/system.rb
301
301
  - lib/rbbt/util/named_array.rb
302
302
  - lib/rbbt/util/open.rb
303
+ - lib/rbbt/util/procpath.rb
303
304
  - lib/rbbt/util/python.rb
304
305
  - lib/rbbt/util/semaphore.rb
305
306
  - lib/rbbt/util/simpleDSL.rb
@@ -378,6 +379,7 @@ files:
378
379
  - share/rbbt_commands/resource/produce
379
380
  - share/rbbt_commands/resource/read
380
381
  - share/rbbt_commands/rsync
382
+ - share/rbbt_commands/slurm/clean
381
383
  - share/rbbt_commands/slurm/list
382
384
  - share/rbbt_commands/slurm/orchestrate
383
385
  - share/rbbt_commands/slurm/task
@@ -437,6 +439,7 @@ files:
437
439
  - share/rbbt_commands/workflow/server
438
440
  - share/rbbt_commands/workflow/task
439
441
  - share/rbbt_commands/workflow/trace
442
+ - share/rbbt_commands/workflow/write_info
440
443
  - share/unicorn.rb
441
444
  - share/workflow_config.ru
442
445
  - test/rbbt/annotations/test_util.rb
@@ -515,6 +518,7 @@ files:
515
518
  - test/rbbt/util/test_log.rb
516
519
  - test/rbbt/util/test_misc.rb
517
520
  - test/rbbt/util/test_open.rb
521
+ - test/rbbt/util/test_procpath.rb
518
522
  - test/rbbt/util/test_python.rb
519
523
  - test/rbbt/util/test_semaphore.rb
520
524
  - test/rbbt/util/test_simpleDSL.rb
@@ -562,6 +566,7 @@ test_files:
562
566
  - test/rbbt/workflow/test_task.rb
563
567
  - test/rbbt/resource/test_path.rb
564
568
  - test/rbbt/util/test_colorize.rb
569
+ - test/rbbt/util/test_procpath.rb
565
570
  - test/rbbt/util/misc/test_omics.rb
566
571
  - test/rbbt/util/misc/test_pipes.rb
567
572
  - test/rbbt/util/misc/test_format.rb