rbbt-util 5.34.5 → 5.34.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rbbt/hpc/batch.rb +7 -7
  3. data/lib/rbbt/hpc/lsf.rb +4 -4
  4. data/lib/rbbt/hpc/slurm.rb +4 -4
  5. data/lib/rbbt/persist/tsv/tokyocabinet.rb +1 -1
  6. data/lib/rbbt/persist.rb +2 -2
  7. data/lib/rbbt/resource.rb +1 -1
  8. data/lib/rbbt/tsv/accessor.rb +3 -0
  9. data/lib/rbbt/tsv/manipulate.rb +13 -5
  10. data/lib/rbbt/tsv/parallel/traverse.rb +1 -1
  11. data/lib/rbbt/util/config.rb +1 -1
  12. data/lib/rbbt/util/migrate.rb +1 -1
  13. data/lib/rbbt/util/misc/development.rb +17 -12
  14. data/lib/rbbt/util/misc/inspect.rb +2 -2
  15. data/lib/rbbt/util/misc/pipes.rb +4 -4
  16. data/lib/rbbt/util/open.rb +3 -3
  17. data/lib/rbbt/util/tar.rb +1 -1
  18. data/lib/rbbt/workflow/integration/nextflow.rb +2 -2
  19. data/lib/rbbt/workflow/remote_workflow/driver/rest.rb +18 -1
  20. data/lib/rbbt/workflow/remote_workflow/remote_step/rest.rb +2 -1
  21. data/lib/rbbt/workflow/step/dependencies.rb +1 -1
  22. data/lib/rbbt/workflow/step/run.rb +1 -1
  23. data/lib/rbbt/workflow/step/save_load_inputs.rb +6 -6
  24. data/lib/rbbt/workflow/step/status.rb +1 -0
  25. data/lib/rbbt/workflow/util/archive.rb +8 -8
  26. data/lib/rbbt/workflow.rb +5 -5
  27. data/share/rbbt_commands/app/start +2 -0
  28. data/share/rbbt_commands/hpc/clean +8 -8
  29. data/share/rbbt_commands/hpc/list +9 -9
  30. data/share/rbbt_commands/hpc/tail +1 -1
  31. data/share/rbbt_commands/lsf/clean +8 -8
  32. data/share/rbbt_commands/lsf/list +9 -9
  33. data/share/rbbt_commands/lsf/tail +1 -1
  34. data/share/rbbt_commands/slurm/clean +8 -8
  35. data/share/rbbt_commands/slurm/list +9 -9
  36. data/share/rbbt_commands/slurm/tail +1 -1
  37. data/share/rbbt_commands/tsv/select +48 -0
  38. data/share/rbbt_commands/tsv/view +4 -3
  39. data/share/rbbt_commands/workflow/archive_all +1 -1
  40. data/share/rbbt_commands/workflow/prov +2 -2
  41. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '073587b420676db7c055e58dbabaecbf04a7b30ba9d7ea912f1c12df5a6d180d'
4
- data.tar.gz: 6d263d07b85095fefb48c15692af0db66b56ef671ada83e98c66a4765d4ca416
3
+ metadata.gz: 94c61252b24c9d379d614a059bcb90bf97acd614811833d870171150da1a44a9
4
+ data.tar.gz: fed2c0c9a2fd2571621dcfa06583f827e667cff12c602b339ccf3e0aa9940a2c
5
5
  SHA512:
6
- metadata.gz: 945c0f4b9d6f99024f6610dc2eb0c52c6546606937fff72558281ecf5d2aaddeb2e32ce3373b9348fa764e8e7285cdcdad6916118ba259d61c24b4b3477e3317
7
- data.tar.gz: a8ba069b626b1a09d6da8e73eaa901119795ade4b4af33f1891b8581cfe80ccf48ca439a6a96b67f45e6bdf687ba7e90df263b8b4caabec18af45f6008e2b5d9
6
+ metadata.gz: 4e8af59ed302f4ea9ab71cdae6254282e94223eb5b99954501a14a57df820482fc7fe2cb1b300ecdc989ee1e7ba8d41bfd88c40aae0792d568a1df3cc75a966b
7
+ data.tar.gz: 99a860373bf4fd8b95168d0c09d3226aa7ea8207e5c7afee5c44dee67720d85bc2793389c70ce0e4b848a7a316a5513d1acb6d6f748cb0d4026d4cddf867b609
@@ -514,7 +514,7 @@ env > #{batch_options[:fenv]}
514
514
 
515
515
  %w(std.out std.err job.id job.status dependencies.list canfail_dependencies.list exit.status sync.log inputs_dir).each do |filename|
516
516
  path = File.join(batch_dir, filename)
517
- Open.rm_rf path if File.exists? path
517
+ Open.rm_rf path if File.exist? path
518
518
  end if clean_batch_job
519
519
 
520
520
  batch_dependencies = [] if batch_dependencies.nil?
@@ -584,14 +584,14 @@ env > #{batch_options[:fenv]}
584
584
 
585
585
  job = Open.read(fjob).strip if Open.exists?(fjob)
586
586
 
587
- if job && ! File.exists?(fexit)
587
+ if job && ! File.exist?(fexit)
588
588
  begin
589
589
  status_txt = job_status(job)
590
590
  STDERR.puts Log.color(:magenta, "Status [#{job.to_i}]:")
591
591
  STDERR.puts status_txt
592
592
  lines = status_txt.split("\n").length
593
593
  rescue
594
- if ! File.exists?(fexit)
594
+ if ! File.exist?(fexit)
595
595
  STDERR.puts Log.color(:magenta, "Job #{job.to_i} not done and not running. STDERR:")
596
596
  STDERR.puts Open.read(ferr)
597
597
  end
@@ -599,7 +599,7 @@ env > #{batch_options[:fenv]}
599
599
  end
600
600
  end
601
601
 
602
- if File.exists?(fexit)
602
+ if File.exist?(fexit)
603
603
  exit_status = Open.read(fexit)
604
604
  if exit_status.to_i == 0
605
605
  STDERR.puts Log.color(:magenta, "Job #{job} done with exit_status 0. STDOUT:")
@@ -613,7 +613,7 @@ env > #{batch_options[:fenv]}
613
613
 
614
614
  if tail
615
615
  Log.severity = 10
616
- while ! File.exists? fout
616
+ while ! File.exist? fout
617
617
  if job
618
618
  STDERR.puts
619
619
  Log.clear_line(STDERR)
@@ -638,8 +638,8 @@ env > #{batch_options[:fenv]}
638
638
  begin
639
639
  status_txt = job_status(job)
640
640
  Open.write(fstatus, status_txt) unless status_txt.nil? || status_txt.empty?
641
- out = CMD.cmd("tail -f '#{fout}'", :pipe => true) if File.exists?(fout) and not tail == :STDERR
642
- err = CMD.cmd("tail -f '#{ferr}'", :pipe => true) if File.exists?(ferr)
641
+ out = CMD.cmd("tail -f '#{fout}'", :pipe => true) if File.exist?(fout) and not tail == :STDERR
642
+ err = CMD.cmd("tail -f '#{ferr}'", :pipe => true) if File.exist?(ferr)
643
643
 
644
644
  terr = Misc.consume_stream(err, true, STDERR) if err
645
645
  tout = Misc.consume_stream(out, true, STDOUT) if out
data/lib/rbbt/hpc/lsf.rb CHANGED
@@ -70,12 +70,12 @@ export BATCH_SYSTEM=LSF
70
70
  STDERR.puts Log.color(:magenta, "Issuing LSF file: #{fcmd}")
71
71
  STDERR.puts Open.read(fcmd)
72
72
 
73
- if File.exists?(fjob)
73
+ if File.exist?(fjob)
74
74
  job = Open.read(fjob).to_i
75
75
  else
76
76
 
77
- dependencies = Open.read(fdep).split("\n") if File.exists? fdep
78
- canfail_dependencies = Open.read(fcfdep).split("\n") if File.exists? fcfdep
77
+ dependencies = Open.read(fdep).split("\n") if File.exist? fdep
78
+ canfail_dependencies = Open.read(fcfdep).split("\n") if File.exist? fcfdep
79
79
 
80
80
  normal_dep_list = dependencies && dependencies.any? ? dependencies.collect{|d| "post_done(#{d})"} : []
81
81
  canfail_dep_list = canfail_dependencies && canfail_dependencies.any? ? canfail_dependencies.collect{|d| "done(#{d})"} : []
@@ -90,7 +90,7 @@ export BATCH_SYSTEM=LSF
90
90
 
91
91
  cmd = "bsub #{dep_str} < '#{fcmd}'"
92
92
 
93
- if File.exists?(fout)
93
+ if File.exist?(fout)
94
94
  return
95
95
  elsif dry_run
96
96
  STDERR.puts Log.color(:magenta, "To execute run: ") + Log.color(:blue, cmd)
@@ -101,12 +101,12 @@ export BATCH_SYSTEM=SLURM
101
101
  Log.info "Issuing SLURM file: #{fcmd}"
102
102
  Log.debug Open.read(fcmd)
103
103
 
104
- if File.exists?(fjob)
104
+ if File.exist?(fjob)
105
105
  job = Open.read(fjob).to_i
106
106
  else
107
107
 
108
- dependencies = Open.read(fdep).split("\n") if File.exists? fdep
109
- canfail_dependencies = Open.read(fcfdep).split("\n") if File.exists? fcfdep
108
+ dependencies = Open.read(fdep).split("\n") if File.exist? fdep
109
+ canfail_dependencies = Open.read(fcfdep).split("\n") if File.exist? fcfdep
110
110
 
111
111
  normal_dep_str = dependencies && dependencies.any? ? "afterok:" + dependencies * ":" : nil
112
112
  canfail_dep_str = canfail_dependencies && canfail_dependencies.any? ? "afterany:" + canfail_dependencies * ":" : nil
@@ -119,7 +119,7 @@ export BATCH_SYSTEM=SLURM
119
119
 
120
120
  cmd = "sbatch #{dep_str} '#{fcmd}'"
121
121
 
122
- if File.exists?(fout)
122
+ if File.exist?(fout)
123
123
  return
124
124
  elsif dry_run
125
125
  STDERR.puts Log.color(:magenta, "To execute run: ") + Log.color(:blue, "sbatch '#{fcmd}'")
@@ -16,7 +16,7 @@ module Persist
16
16
  end
17
17
 
18
18
  dir = File.dirname(File.expand_path(path))
19
- File.mkdir(dir) unless File.exists?(dir)
19
+ File.mkdir(dir) unless File.exist?(dir)
20
20
 
21
21
  tokyocabinet_class = TokyoCabinet::HDB if tokyocabinet_class == "HDB" or tokyocabinet_class.nil?
22
22
  tokyocabinet_class = TokyoCabinet::BDB if tokyocabinet_class == "BDB"
data/lib/rbbt/persist.rb CHANGED
@@ -31,8 +31,8 @@ module Persist
31
31
  path = path.find if Path === path
32
32
  file = file.find if Path === file
33
33
  if by_link
34
- patht = File.exists?(path) ? File.lstat(path).mtime : nil
35
- filet = File.exists?(file) ? File.lstat(file).mtime : nil
34
+ patht = File.exist?(path) ? File.lstat(path).mtime : nil
35
+ filet = File.exist?(file) ? File.lstat(file).mtime : nil
36
36
  else
37
37
  patht = Open.mtime(path)
38
38
  filet = Open.mtime(file)
data/lib/rbbt/resource.rb CHANGED
@@ -233,7 +233,7 @@ module Resource
233
233
  when :install
234
234
  Log.debug "Installing software: #{path}"
235
235
 
236
- $set_software_env = false unless File.exists? path
236
+ $set_software_env = false unless File.exist? path
237
237
 
238
238
  software_dir = path.resource.root.software.find :user
239
239
  helper_file = File.expand_path(Rbbt.share.install.software.lib.install_helpers.find(:lib, caller_lib_dir(__FILE__)))
@@ -16,6 +16,9 @@ module TSV
16
16
 
17
17
  def annotate(tsv)
18
18
  TSV.setup(tsv, info)
19
+ tsv.entity_options = self.entity_options
20
+ tsv.entity_templates = self.entity_templates
21
+ tsv
19
22
  end
20
23
 
21
24
  def entity_options
@@ -527,13 +527,21 @@ module TSV
527
527
  self.unnamed = old_unnamed
528
528
 
529
529
  when String === method
530
- with_unnamed do
531
- through :key, key do |key, values|
532
- values = [values] if type == :single
533
- new[key] = self[key] if invert ^ (values.flatten.select{|v| v == method}.length > 0)
530
+ if method =~ /^([<>]=?)(.*)/
531
+ with_unnamed do
532
+ through :key, key do |key, values|
533
+ value = Array === values ? values.flatten.first : values
534
+ new[key] = self[key] if value.to_f.send($1, $2.to_f)
535
+ end
536
+ end
537
+ else
538
+ with_unnamed do
539
+ through :key, key do |key, values|
540
+ values = [values] if type == :single
541
+ new[key] = self[key] if invert ^ (values.flatten.select{|v| v == method}.length > 0)
542
+ end
534
543
  end
535
544
  end
536
-
537
545
  when Numeric === method
538
546
  with_unnamed do
539
547
  through :key, key do |key, values|
@@ -389,7 +389,7 @@ module TSV
389
389
  when Set
390
390
  traverse_array(obj.to_a, options, &block)
391
391
  when String
392
- if Open.remote?(obj) or Misc.is_filename?(obj)
392
+ if Open.remote?(obj) || Open.ssh?(obj) || Misc.is_filename?(obj)
393
393
  Open.open(obj) do |s|
394
394
  traverse_obj(s, options, &block)
395
395
  end
@@ -145,7 +145,7 @@ module Rbbt::Config
145
145
  end
146
146
 
147
147
  def self.process_config(config)
148
- if Misc.is_filename?(config) && File.exists?(config)
148
+ if Misc.is_filename?(config) && File.exist?(config)
149
149
  Rbbt::Config.load_file(config)
150
150
  elsif Rbbt.etc.config_profile[config].exists?
151
151
  Rbbt::Config.load_file(Rbbt.etc.config_profile[config].find)
@@ -17,7 +17,7 @@ puts path.glob_all.collect{|p| File.directory?(p) ? p + "/" : p } * "\n"
17
17
 
18
18
  [path, paths.collect{|p| [source, p] * ":"}, lpath]
19
19
  else
20
- if File.exists?(path)
20
+ if File.exist?(path)
21
21
  path = resource.identify(path)
22
22
  else
23
23
  path = Path.setup(path)
@@ -135,20 +135,25 @@ def self.add_libdir(dir=nil)
135
135
  end
136
136
 
137
137
  def self.insist(times = 4, sleep = nil, msg = nil)
138
- if Array === times
139
- sleep_array = times
140
- times = sleep_array.length
141
- sleep = sleep_array.shift
142
- end
143
- try = 0
144
-
145
- if sleep.nil?
146
- sleep_array = ([0] + [0.001, 0.01, 0.1, 0.5] * (times / 3)).sort[0..times-1]
147
- sleep = sleep_array.shift
148
- end
138
+ sleep_array = nil
149
139
 
140
+ try = 0
150
141
  begin
151
- yield
142
+ begin
143
+ yield
144
+ rescue Exception
145
+ if Array === times
146
+ sleep_array = times
147
+ times = sleep_array.length
148
+ sleep = sleep_array.shift
149
+ end
150
+
151
+ if sleep.nil?
152
+ sleep_array = ([0] + [0.001, 0.01, 0.1, 0.5] * (times / 3)).sort[0..times-1]
153
+ sleep = sleep_array.shift
154
+ end
155
+ raise $!
156
+ end
152
157
  rescue TryAgain
153
158
  sleep sleep
154
159
  retry
@@ -266,7 +266,7 @@ module Misc
266
266
 
267
267
  def self.mtime_str(path)
268
268
  path = path.find if Path === path
269
- if File.exists? path
269
+ if File.exist? path
270
270
  "mtime: " << File.mtime(path).to_s
271
271
  else
272
272
  "mtime: not present"
@@ -416,7 +416,7 @@ module Misc
416
416
  end
417
417
 
418
418
  def self.file2md5(file)
419
- if File.exists?(file + '.md5')
419
+ if File.exist?(file + '.md5')
420
420
  Open.read(file + '.md5')
421
421
  else
422
422
  md5 = CMD.cmd("md5sum '#{file}'").read.strip.split(" ").first
@@ -39,11 +39,11 @@ module Misc
39
39
  begin
40
40
  erase = path.nil?
41
41
  path = TmpFile.tmp_file if path.nil?
42
- File.rm path if clean && File.exists?(path)
42
+ File.rm path if clean && File.exist?(path)
43
43
  File.mkfifo path
44
44
  yield path
45
45
  ensure
46
- FileUtils.rm path if erase && File.exists?(path)
46
+ FileUtils.rm path if erase && File.exist?(path)
47
47
  end
48
48
  end
49
49
 
@@ -340,11 +340,11 @@ module Misc
340
340
  Log.medium "Consume stream aborted #{Misc.fingerprint io}"
341
341
  io.abort if io.respond_to? :abort
342
342
  #io.close unless io.closed?
343
- FileUtils.rm into_path if into_path and File.exists? into_path
343
+ FileUtils.rm into_path if into_path and File.exist? into_path
344
344
  rescue Exception
345
345
  Log.medium "Exception consuming stream: #{Misc.fingerprint io}: #{$!.message}"
346
346
  io.abort $! if io.respond_to? :abort
347
- FileUtils.rm into_path if into_path and File.exists? into_path
347
+ FileUtils.rm into_path if into_path and File.exist? into_path
348
348
  raise $!
349
349
  end
350
350
  end
@@ -389,8 +389,8 @@ module Open
389
389
  # source = source.find if Path === source
390
390
  # target = target.find if Path === target
391
391
 
392
- # FileUtils.mkdir_p File.dirname(target) unless File.exists?(File.dirname(target))
393
- # FileUtils.rm target if File.exists?(target)
392
+ # FileUtils.mkdir_p File.dirname(target) unless File.exist?(File.dirname(target))
393
+ # FileUtils.rm target if File.exist?(target)
394
394
  # FileUtils.cp source, target
395
395
  #end
396
396
 
@@ -522,7 +522,7 @@ module Open
522
522
  # Questions
523
523
 
524
524
  def self.remote?(file)
525
- !! (file =~ /^(?:https?|ftp):\/\//)
525
+ !! (file =~ /^(?:https?|ftp|ssh):\/\//)
526
526
  end
527
527
 
528
528
  def self.ssh?(file)
data/lib/rbbt/util/tar.rb CHANGED
@@ -93,7 +93,7 @@ module Misc
93
93
  # directory
94
94
  def self.untar(io, destination)
95
95
  io = io.find if Path === io
96
- if String === io and File.exists?(io)
96
+ if String === io and File.exist?(io)
97
97
  Open.open(io) do |f|
98
98
  untar(f, destination)
99
99
  end
@@ -13,7 +13,7 @@ module Workflow
13
13
  nextflow_includes(file).inject(params) do |params,info|
14
14
  name_str, included_file = info
15
15
  included_file = File.join(dir, included_file)
16
- included_file += '.nf' unless File.exists?(included_file) || ! File.exists?(included_file + '.nf')
16
+ included_file += '.nf' unless File.exist?(included_file) || ! File.exist?(included_file + '.nf')
17
17
  name_str.split(";").each do |name|
18
18
  name = name.strip
19
19
  include_params = nextflow_recursive_params(included_file).collect{|p| [p,name] * "-"}
@@ -32,7 +32,7 @@ module Workflow
32
32
  result = :text
33
33
  end
34
34
 
35
- file = file + '.nf' unless File.exists?(file) || ! File.exists?(file + '.nf')
35
+ file = file + '.nf' unless File.exist?(file) || ! File.exist?(file + '.nf')
36
36
  file = File.expand_path(file)
37
37
  name ||= File.basename(file).sub(/\.nf$/,'').gsub(/\s/,'_')
38
38
  params = Workflow.nextflow_recursive_params(file)
@@ -18,7 +18,24 @@ class RemoteWorkflow
18
18
  end
19
19
  end
20
20
 
21
+ def self.escape_url(url)
22
+ base, _sep, query = url.partition("?")
23
+ protocol, path = base.split("://")
24
+ path = protocol if path.nil?
25
+ path = path.split("/").collect{|p| CGI.escape(p) }* "/"
26
+ base = protocol ? [protocol, path] * "://" : path
27
+
28
+ if query && ! query.empty?
29
+ query = query.split("&").collect{|e| e.split("=").collect{|pe| CGI.escape(pe) } * "=" } * "&"
30
+ [base, query] * "?"
31
+ else
32
+ base
33
+ end
34
+ end
35
+
21
36
  def self.encode(url)
37
+ # ToDo: Check this
38
+ return escape_url(url)
22
39
  begin
23
40
  URI::DEFAULT_PARSER.escape(url)
24
41
  rescue
@@ -135,7 +152,7 @@ class RemoteWorkflow
135
152
 
136
153
  def self.execute_job(base_url, task, task_params, cache_type)
137
154
  RemoteWorkflow.capture_exception do
138
- task_url = URI.encode(File.join(base_url, task.to_s))
155
+ task_url = self.escape_url(File.join(base_url, task.to_s))
139
156
 
140
157
  sout, sin = Misc.pipe
141
158
 
@@ -132,7 +132,7 @@ class RemoteStep
132
132
  def _run_job(cache_type = :asynchronous)
133
133
  get_streams
134
134
 
135
- task_url = URI.encode(File.join(base_url, task.to_s))
135
+ task_url = RemoteWorkflow::REST.escape_url(File.join(base_url, task.to_s))
136
136
  @adaptor.__prepare_inputs_for_restclient(inputs)
137
137
  task_params = inputs.merge(:_cache_type => cache_type, :jobname => base_name, :_format => [:string, :boolean, :tsv, :annotations].include?(result_type) ? :raw : :json)
138
138
 
@@ -147,6 +147,7 @@ class RemoteStep
147
147
 
148
148
  def produce(*args)
149
149
  @started = true
150
+ init_job
150
151
  _run_job
151
152
  end
152
153
 
@@ -92,7 +92,7 @@ class Step
92
92
  (!(job.noinfo? || job.done? || job.error? || job.aborted? || job.running?))
93
93
 
94
94
  if ! (job.resumable? && (job.updated? && ! job.dirty?))
95
- Log.high "About to clean -- status: #{status}, present #{File.exists?(job.path)}, " +
95
+ Log.high "About to clean -- status: #{status}, present #{File.exist?(job.path)}, " +
96
96
  %w(done? error? recoverable_error? noinfo? updated? dirty? aborted? running? resumable?).
97
97
  collect{|v| [v, job.send(v)]*": "} * ", " if RBBT_DEBUG_CLEAN
98
98
 
@@ -421,7 +421,7 @@ class Step
421
421
  config_keys = Rbbt::Config::GOT_KEYS[config_keys_pre.length..-1]
422
422
  set_info :config_keys, config_keys.uniq
423
423
 
424
- if result.nil? && File.exists?(self.tmp_path) && ! File.exists?(self.path)
424
+ if result.nil? && File.exist?(self.tmp_path) && ! File.exist?(self.path)
425
425
  Open.mv self.tmp_path, self.path
426
426
  end
427
427
  result
@@ -2,12 +2,12 @@ module Workflow
2
2
 
3
3
  def self.load_inputs(dir, input_names, input_types)
4
4
  inputs = {}
5
- if File.exists?(dir) && ! File.directory?(dir)
5
+ if File.exist?(dir) && ! File.directory?(dir)
6
6
  Log.debug "Loading inputs from #{dir}, not a directory trying as tar.gz"
7
7
  tarfile = dir
8
8
  digest = CMD.cmd("md5sum '#{tarfile}'").read.split(" ").first
9
9
  tmpdir = Rbbt.tmp.input_bundle[digest].find
10
- Misc.untar(tarfile, tmpdir) unless File.exists? tmpdir
10
+ Misc.untar(tarfile, tmpdir) unless File.exist? tmpdir
11
11
  files = tmpdir.glob("*")
12
12
  if files.length == 1 && File.directory?(files.first)
13
13
  tmpdir = files.first
@@ -177,7 +177,7 @@ class Step
177
177
 
178
178
  Log.debug "Saving job input #{name} (#{type}) into #{path}"
179
179
 
180
- if value.respond_to? :filename
180
+ if IO === value && value.respond_to?(:filename) && value.filename
181
181
  Open.write(path, value.filename)
182
182
  elsif IO === value
183
183
  Open.write(path, value)
@@ -256,7 +256,7 @@ class Step
256
256
  # when Step === value
257
257
  # Open.ln_s(value.path, path)
258
258
  # when type.to_s == "binary"
259
- # if String === value && File.exists?(value)
259
+ # if String === value && File.exist?(value)
260
260
  # value = File.expand_path(value)
261
261
  # Open.ln_s(value, path)
262
262
  # elsif String === value && Misc.is_filename?(value, false)
@@ -269,7 +269,7 @@ class Step
269
269
  # when Array === value
270
270
  # Open.write(path, value.collect{|v| Step === v ? v.path : v.to_s} * "\n")
271
271
  # when %w(file tsv array).include?(type.to_s)
272
- # if String === value && File.exists?(value)
272
+ # if String === value && File.exist?(value)
273
273
  # value = File.expand_path(value)
274
274
  # Open.ln_s(value, path)
275
275
  # elsif String === value && Misc.is_filename?(value, false)
@@ -280,7 +280,7 @@ class Step
280
280
  # Open.write(path + '.yaml', value.to_yaml)
281
281
  # end
282
282
  # when IO === value
283
- # if value.filename && String === value.filename && File.exists?(value.filename)
283
+ # if value.filename && String === value.filename && File.exist?(value.filename)
284
284
  # Open.ln_s(value.filename, path)
285
285
  # else
286
286
  # Open.write(path, value)
@@ -75,6 +75,7 @@ class Step
75
75
 
76
76
  def dirty?
77
77
  return true if Open.exists?(pid_file) && ! ( Open.exists?(info_file) || done? )
78
+ return true if done? && ! (status == :done || status == :noinfo)
78
79
  return false unless done? || status == :done
79
80
  return false unless ENV["RBBT_UPDATE"] == "true"
80
81
 
@@ -13,9 +13,9 @@ class Step
13
13
  return if target_dir[workflow][task][name].exists? || File.symlink?(target_dir[workflow][task][name].find)
14
14
  Log.debug "Linking #{ path }"
15
15
  FileUtils.mkdir_p target_dir[workflow][task] unless target_dir[workflow][task].exists?
16
- FileUtils.ln_s path, target_dir[workflow][task][name].find if File.exists?(path)
17
- FileUtils.ln_s path + '.files', target_dir[workflow][task][name].find + '.files' if File.exists?(path + '.files')
18
- FileUtils.ln_s path + '.info', target_dir[workflow][task][name].find + '.info' if File.exists?(path + '.info')
16
+ FileUtils.ln_s path, target_dir[workflow][task][name].find if File.exist?(path)
17
+ FileUtils.ln_s path + '.files', target_dir[workflow][task][name].find + '.files' if File.exist?(path + '.files')
18
+ FileUtils.ln_s path + '.info', target_dir[workflow][task][name].find + '.info' if File.exist?(path + '.info')
19
19
  end
20
20
 
21
21
  def archive(target = nil)
@@ -65,15 +65,15 @@ class Step
65
65
  end.uniq
66
66
 
67
67
  jobs.each do |step|
68
- next unless File.exists?(step.path)
68
+ next unless File.exist?(step.path)
69
69
  next if skip_overriden && step.overriden
70
70
 
71
71
  job_files << step.path
72
- job_files << step.info_file if File.exists?(step.info_file)
73
- job_files << Step.md5_file(step.path) if File.exists?(Step.md5_file step.path)
72
+ job_files << step.info_file if File.exist?(step.info_file)
73
+ job_files << Step.md5_file(step.path) if File.exist?(Step.md5_file step.path)
74
74
  job_file_dir_content = Dir.glob(step.files_dir + '/**/*')
75
75
  job_files += job_file_dir_content
76
- job_files << step.files_dir if File.exists?(step.files_dir)
76
+ job_files << step.files_dir if File.exist?(step.files_dir)
77
77
  rec_dependencies = Set.new
78
78
 
79
79
  next unless recursive
@@ -99,7 +99,7 @@ class Step
99
99
  dep = Workflow.load_step path
100
100
  job_files << dep.path
101
101
  job_files << dep.files_dir if Dir.glob(dep.files_dir + '/*').any?
102
- job_files << dep.info_file if File.exists?(dep.info_file)
102
+ job_files << dep.info_file if File.exist?(dep.info_file)
103
103
  end
104
104
  end
105
105
 
data/lib/rbbt/workflow.rb CHANGED
@@ -543,13 +543,13 @@ module Workflow
543
543
  persist = input_values.nil? ? false : true
544
544
  persist = false
545
545
 
546
- if ! (Path === step_path ? step_path.find : File.exists?(step_path)) && step_path.split("/").length == 3 && File.exists?(new_path = Rbbt.var.jobs[step_path].find)
546
+ if ! (Path === step_path ? step_path.find : File.exist?(step_path)) && step_path.split("/").length == 3 && File.exist?(new_path = Rbbt.var.jobs[step_path].find)
547
547
  step_path = new_path
548
548
  end
549
549
 
550
550
  key = Path === step_path ? step_path.find : step_path
551
551
 
552
- if ! File.exists?(step_path) && step_path.split("/").length == 3 && File.exists?(new_path = Rbbt.var.jobs[step_path].find)
552
+ if ! File.exist?(step_path) && step_path.split("/").length == 3 && File.exist?(new_path = Rbbt.var.jobs[step_path].find)
553
553
  step_path = new_path
554
554
  end
555
555
 
@@ -602,7 +602,7 @@ module Workflow
602
602
  pother = other.split(/\/+/)
603
603
  end_part = pother[-3..-1] * "/"
604
604
  new_path = prefix + "/" << end_part
605
- if File.exists? new_path
605
+ if File.exist? new_path
606
606
  new_path
607
607
  else
608
608
  Rbbt.var.jobs[end_part].find
@@ -615,7 +615,7 @@ module Workflow
615
615
  pother = other.split(/\/+/)
616
616
  end_part = pother[-3..-1] * "/"
617
617
  new_path = preal[0..-4] * "/" << "/" << end_part
618
- return new_path if File.exists?(new_path) || File.exists?(new_path + '.info')
618
+ return new_path if File.exist?(new_path) || File.exist?(new_path + '.info')
619
619
  Rbbt.var.jobs[end_part].find
620
620
  end
621
621
 
@@ -713,7 +713,7 @@ module Workflow
713
713
  def self.load_step(path)
714
714
  path = Path.setup(path.dup) unless Path === path
715
715
 
716
- if ! (Path === path ? path.exists? : File.exists?(path)) && path.split("/").length == 3
716
+ if ! (Path === path ? path.exists? : File.exist?(path)) && path.split("/").length == 3
717
717
  new_path = Rbbt.var.jobs[path]
718
718
  if new_path.exists? || new_path.set_extension('info').exists?
719
719
  path = new_path
@@ -96,6 +96,8 @@ Misc.in_dir(app_dir) do
96
96
  system ENV, "env RBBT_LOG=0 passenger start -R '#{config_ru_file}' -p #{options[:Port] || "2887"}"
97
97
  when 'puma_alt'
98
98
  system ENV, "puma '#{config_ru_file}' -p #{options[:Port] || "2887"} -w 3 -t 8:32 --preload"
99
+ when 'puma_production'
100
+ CMD.cmd_log("env RBBT_LOG=#{Log.severity.to_s} puma '#{config_ru_file}' -p #{options[:Port] || "2887"} -w 20 -t 10:160 --preload")
99
101
  else
100
102
  options[:config] = config_ru_file
101
103
  options[:threads] = "8:8"
@@ -97,19 +97,19 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
97
97
 
98
98
  different_system = job_batch_system != batch_system
99
99
 
100
- if File.exists?(fid = File.join(dir, 'job.id'))
100
+ if File.exist?(fid = File.join(dir, 'job.id'))
101
101
  id = Open.read(fid).chomp
102
102
  else
103
103
  id = nil
104
104
  end
105
105
 
106
- if File.exists?(fstatus = File.join(dir, 'exit.status'))
106
+ if File.exist?(fstatus = File.join(dir, 'exit.status'))
107
107
  exit_status = Open.read(fstatus).to_i
108
108
  else
109
109
  exit_status = nil
110
110
  end
111
111
 
112
- if File.exists?(fstatus = File.join(dir, 'job.status'))
112
+ if File.exist?(fstatus = File.join(dir, 'job.status'))
113
113
  fstatus_txt = Open.read(fstatus)
114
114
  begin
115
115
  if job_batch_system == "lsf"
@@ -126,17 +126,17 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
126
126
  nodes = []
127
127
  end
128
128
 
129
- if File.exists?(File.join(dir, 'std.out'))
129
+ if File.exist?(File.join(dir, 'std.out'))
130
130
  outt = File.mtime File.join(dir, 'std.out')
131
131
  errt = File.mtime File.join(dir, 'std.err')
132
132
  time_diff = Time.now - [outt, errt].max
133
133
  end
134
134
 
135
135
  fdep = File.join(dir, 'dependencies.list')
136
- deps = Open.read(fdep).split("\n") if File.exists?(fdep)
136
+ deps = Open.read(fdep).split("\n") if File.exist?(fdep)
137
137
 
138
138
  fcadep = File.join(dir, 'canfail_dependencies.list')
139
- cadeps = Open.read(fcadep).split("\n") if File.exists?(fcadep)
139
+ cadeps = Open.read(fcadep).split("\n") if File.exist?(fcadep)
140
140
 
141
141
  aborted = error = true if aborted.nil? && error.nil?
142
142
  #if done || error || aborted || running || queued || jobid || search
@@ -177,7 +177,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
177
177
  puts Log.color(:magenta, "Dependencies: ") << deps * ", " if deps
178
178
  puts Log.color(:magenta, "Dependencies (can fail): ") << cadeps * ", " if cadeps
179
179
  puts Log.color(:magenta, "Nodes: ") << nodes * ", "
180
- puts Log.color(:magenta, "Output: ") << File.exists?(File.join(dir, 'std.out')).to_s << (id.nil? ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)")
180
+ puts Log.color(:magenta, "Output: ") << File.exist?(File.join(dir, 'std.out')).to_s << (id.nil? ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)")
181
181
 
182
182
  if options[:batch_parameters]
183
183
  puts Log.color(:magenta, "BATCH parameters: ")
@@ -189,7 +189,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
189
189
  end
190
190
  end
191
191
 
192
- if tail && File.exists?(File.join(dir, 'std.err'))
192
+ if tail && File.exist?(File.join(dir, 'std.err'))
193
193
  if exit_status && exit_status != 0
194
194
  puts Log.color(:magenta, "First error or exception found: ")
195
195
  puts CMD.cmd("grep -i -w 'error\\|[a-z]*exception' #{File.join(dir, 'std.err')} -A #{tail.to_i} |head -n #{tail.to_i}", :no_fail => true).read
@@ -118,19 +118,19 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
118
118
  container_home = nil
119
119
  end
120
120
 
121
- if File.exists?(fid = File.join(dir, 'job.id'))
121
+ if File.exist?(fid = File.join(dir, 'job.id'))
122
122
  id = Open.read(fid).chomp
123
123
  else
124
124
  id = nil
125
125
  end
126
126
 
127
- if File.exists?(fstatus = File.join(dir, 'exit.status'))
127
+ if File.exist?(fstatus = File.join(dir, 'exit.status'))
128
128
  exit_status = Open.read(fstatus).to_i
129
129
  else
130
130
  exit_status = nil
131
131
  end
132
132
 
133
- if File.exists?(fstatus = File.join(dir, 'job.status'))
133
+ if File.exist?(fstatus = File.join(dir, 'job.status'))
134
134
  fstatus_txt = Open.read(fstatus)
135
135
  begin
136
136
  if job_batch_system == "lsf"
@@ -147,13 +147,13 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
147
147
  nodes = []
148
148
  end
149
149
 
150
- if File.exists?(File.join(dir, 'exit.status'))
150
+ if File.exist?(File.join(dir, 'exit.status'))
151
151
  now = File.ctime(File.join(dir, 'exit.status'))
152
152
  else
153
153
  now = Time.now
154
154
  end
155
155
 
156
- if File.exists?(File.join(dir, 'std.out'))
156
+ if File.exist?(File.join(dir, 'std.out'))
157
157
  cerrt = File.ctime File.join(dir, 'std.err')
158
158
  coutt = File.ctime File.join(dir, 'std.out')
159
159
  outt = File.mtime File.join(dir, 'std.out')
@@ -163,10 +163,10 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
163
163
  end
164
164
 
165
165
  fdep = File.join(dir, 'dependencies.list')
166
- deps = Open.read(fdep).split("\n") if File.exists?(fdep)
166
+ deps = Open.read(fdep).split("\n") if File.exist?(fdep)
167
167
 
168
168
  fcadep = File.join(dir, 'canfail_dependencies.list')
169
- cadeps = Open.read(fcadep).split("\n") if File.exists?(fcadep)
169
+ cadeps = Open.read(fcadep).split("\n") if File.exist?(fcadep)
170
170
 
171
171
  if done || error || aborted || running || queued || jobid
172
172
  select = false
@@ -244,7 +244,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
244
244
  puts Log.color(:magenta, "Dependencies (can fail): ") << cadeps * ", " if cadeps
245
245
  puts Log.color(:magenta, "Nodes: ") << nodes * ", " if long
246
246
  puts Log.color(:magenta, "Time elapsed: ") << Misc.format_seconds(time_elapsed) if time_elapsed
247
- puts Log.color(:magenta, "Output: ") << File.exists?(File.join(dir, 'std.out')).to_s << (id.nil? || File.exists?(File.join(dir, 'exit.status')) ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)") if long
247
+ puts Log.color(:magenta, "Output: ") << File.exist?(File.join(dir, 'std.out')).to_s << (id.nil? || File.exist?(File.join(dir, 'exit.status')) ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)") if long
248
248
 
249
249
  if options[:batch_parameters]
250
250
  puts Log.color(:magenta, "BATCH parameters: ")
@@ -316,7 +316,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
316
316
  end
317
317
 
318
318
 
319
- if tail && File.exists?(File.join(dir, 'std.err'))
319
+ if tail && File.exist?(File.join(dir, 'std.err'))
320
320
  if exit_status && exit_status != 0
321
321
  puts Log.color(:magenta, "First error or exception found: ")
322
322
  puts CMD.cmd("grep -i -w 'error\\|[a-z]*exception' #{File.join(dir, 'std.err')} -A #{tail.to_i} |head -n #{tail.to_i}", :no_fail => true).read
@@ -46,7 +46,7 @@ if directory =~ /^[0-9]*$/
46
46
  end
47
47
  end
48
48
 
49
- raise ParameterException, "Could not identify job #{directory}" unless File.exists?(directory)
49
+ raise ParameterException, "Could not identify job #{directory}" unless File.exist?(directory)
50
50
 
51
51
  require 'rbbt/hpc/slurm'
52
52
 
@@ -97,19 +97,19 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
97
97
 
98
98
  different_system = job_batch_system != batch_system
99
99
 
100
- if File.exists?(fid = File.join(dir, 'job.id'))
100
+ if File.exist?(fid = File.join(dir, 'job.id'))
101
101
  id = Open.read(fid).chomp
102
102
  else
103
103
  id = nil
104
104
  end
105
105
 
106
- if File.exists?(fstatus = File.join(dir, 'exit.status'))
106
+ if File.exist?(fstatus = File.join(dir, 'exit.status'))
107
107
  exit_status = Open.read(fstatus).to_i
108
108
  else
109
109
  exit_status = nil
110
110
  end
111
111
 
112
- if File.exists?(fstatus = File.join(dir, 'job.status'))
112
+ if File.exist?(fstatus = File.join(dir, 'job.status'))
113
113
  fstatus_txt = Open.read(fstatus)
114
114
  begin
115
115
  if job_batch_system == "lsf"
@@ -126,17 +126,17 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
126
126
  nodes = []
127
127
  end
128
128
 
129
- if File.exists?(File.join(dir, 'std.out'))
129
+ if File.exist?(File.join(dir, 'std.out'))
130
130
  outt = File.mtime File.join(dir, 'std.out')
131
131
  errt = File.mtime File.join(dir, 'std.err')
132
132
  time_diff = Time.now - [outt, errt].max
133
133
  end
134
134
 
135
135
  fdep = File.join(dir, 'dependencies.list')
136
- deps = Open.read(fdep).split("\n") if File.exists?(fdep)
136
+ deps = Open.read(fdep).split("\n") if File.exist?(fdep)
137
137
 
138
138
  fcadep = File.join(dir, 'canfail_dependencies.list')
139
- cadeps = Open.read(fcadep).split("\n") if File.exists?(fcadep)
139
+ cadeps = Open.read(fcadep).split("\n") if File.exist?(fcadep)
140
140
 
141
141
  aborted = error = true if aborted.nil? && error.nil?
142
142
  #if done || error || aborted || running || queued || jobid || search
@@ -177,7 +177,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
177
177
  puts Log.color(:magenta, "Dependencies: ") << deps * ", " if deps
178
178
  puts Log.color(:magenta, "Dependencies (can fail): ") << cadeps * ", " if cadeps
179
179
  puts Log.color(:magenta, "Nodes: ") << nodes * ", "
180
- puts Log.color(:magenta, "Output: ") << File.exists?(File.join(dir, 'std.out')).to_s << (id.nil? ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)")
180
+ puts Log.color(:magenta, "Output: ") << File.exist?(File.join(dir, 'std.out')).to_s << (id.nil? ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)")
181
181
 
182
182
  if options[:batch_parameters]
183
183
  puts Log.color(:magenta, "BATCH parameters: ")
@@ -189,7 +189,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
189
189
  end
190
190
  end
191
191
 
192
- if tail && File.exists?(File.join(dir, 'std.err'))
192
+ if tail && File.exist?(File.join(dir, 'std.err'))
193
193
  if exit_status && exit_status != 0
194
194
  puts Log.color(:magenta, "First error or exception found: ")
195
195
  puts CMD.cmd("grep -i -w 'error\\|[a-z]*exception' #{File.join(dir, 'std.err')} -A #{tail.to_i} |head -n #{tail.to_i}", :no_fail => true).read
@@ -118,19 +118,19 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
118
118
  container_home = nil
119
119
  end
120
120
 
121
- if File.exists?(fid = File.join(dir, 'job.id'))
121
+ if File.exist?(fid = File.join(dir, 'job.id'))
122
122
  id = Open.read(fid).chomp
123
123
  else
124
124
  id = nil
125
125
  end
126
126
 
127
- if File.exists?(fstatus = File.join(dir, 'exit.status'))
127
+ if File.exist?(fstatus = File.join(dir, 'exit.status'))
128
128
  exit_status = Open.read(fstatus).to_i
129
129
  else
130
130
  exit_status = nil
131
131
  end
132
132
 
133
- if File.exists?(fstatus = File.join(dir, 'job.status'))
133
+ if File.exist?(fstatus = File.join(dir, 'job.status'))
134
134
  fstatus_txt = Open.read(fstatus)
135
135
  begin
136
136
  if job_batch_system == "lsf"
@@ -147,13 +147,13 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
147
147
  nodes = []
148
148
  end
149
149
 
150
- if File.exists?(File.join(dir, 'exit.status'))
150
+ if File.exist?(File.join(dir, 'exit.status'))
151
151
  now = File.ctime(File.join(dir, 'exit.status'))
152
152
  else
153
153
  now = Time.now
154
154
  end
155
155
 
156
- if File.exists?(File.join(dir, 'std.out'))
156
+ if File.exist?(File.join(dir, 'std.out'))
157
157
  cerrt = File.ctime File.join(dir, 'std.err')
158
158
  coutt = File.ctime File.join(dir, 'std.out')
159
159
  outt = File.mtime File.join(dir, 'std.out')
@@ -163,10 +163,10 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
163
163
  end
164
164
 
165
165
  fdep = File.join(dir, 'dependencies.list')
166
- deps = Open.read(fdep).split("\n") if File.exists?(fdep)
166
+ deps = Open.read(fdep).split("\n") if File.exist?(fdep)
167
167
 
168
168
  fcadep = File.join(dir, 'canfail_dependencies.list')
169
- cadeps = Open.read(fcadep).split("\n") if File.exists?(fcadep)
169
+ cadeps = Open.read(fcadep).split("\n") if File.exist?(fcadep)
170
170
 
171
171
  if done || error || aborted || running || queued || jobid
172
172
  select = false
@@ -244,7 +244,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
244
244
  puts Log.color(:magenta, "Dependencies (can fail): ") << cadeps * ", " if cadeps
245
245
  puts Log.color(:magenta, "Nodes: ") << nodes * ", " if long
246
246
  puts Log.color(:magenta, "Time elapsed: ") << Misc.format_seconds(time_elapsed) if time_elapsed
247
- puts Log.color(:magenta, "Output: ") << File.exists?(File.join(dir, 'std.out')).to_s << (id.nil? || File.exists?(File.join(dir, 'exit.status')) ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)") if long
247
+ puts Log.color(:magenta, "Output: ") << File.exist?(File.join(dir, 'std.out')).to_s << (id.nil? || File.exist?(File.join(dir, 'exit.status')) ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)") if long
248
248
 
249
249
  if options[:batch_parameters]
250
250
  puts Log.color(:magenta, "BATCH parameters: ")
@@ -316,7 +316,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
316
316
  end
317
317
 
318
318
 
319
- if tail && File.exists?(File.join(dir, 'std.err'))
319
+ if tail && File.exist?(File.join(dir, 'std.err'))
320
320
  if exit_status && exit_status != 0
321
321
  puts Log.color(:magenta, "First error or exception found: ")
322
322
  puts CMD.cmd("grep -i -w 'error\\|[a-z]*exception' #{File.join(dir, 'std.err')} -A #{tail.to_i} |head -n #{tail.to_i}", :no_fail => true).read
@@ -46,7 +46,7 @@ if directory =~ /^[0-9]*$/
46
46
  end
47
47
  end
48
48
 
49
- raise ParameterException, "Could not identify job #{directory}" unless File.exists?(directory)
49
+ raise ParameterException, "Could not identify job #{directory}" unless File.exist?(directory)
50
50
 
51
51
  require 'rbbt/hpc/slurm'
52
52
 
@@ -97,19 +97,19 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
97
97
 
98
98
  different_system = job_batch_system != batch_system
99
99
 
100
- if File.exists?(fid = File.join(dir, 'job.id'))
100
+ if File.exist?(fid = File.join(dir, 'job.id'))
101
101
  id = Open.read(fid).chomp
102
102
  else
103
103
  id = nil
104
104
  end
105
105
 
106
- if File.exists?(fstatus = File.join(dir, 'exit.status'))
106
+ if File.exist?(fstatus = File.join(dir, 'exit.status'))
107
107
  exit_status = Open.read(fstatus).to_i
108
108
  else
109
109
  exit_status = nil
110
110
  end
111
111
 
112
- if File.exists?(fstatus = File.join(dir, 'job.status'))
112
+ if File.exist?(fstatus = File.join(dir, 'job.status'))
113
113
  fstatus_txt = Open.read(fstatus)
114
114
  begin
115
115
  if job_batch_system == "lsf"
@@ -126,17 +126,17 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
126
126
  nodes = []
127
127
  end
128
128
 
129
- if File.exists?(File.join(dir, 'std.out'))
129
+ if File.exist?(File.join(dir, 'std.out'))
130
130
  outt = File.mtime File.join(dir, 'std.out')
131
131
  errt = File.mtime File.join(dir, 'std.err')
132
132
  time_diff = Time.now - [outt, errt].max
133
133
  end
134
134
 
135
135
  fdep = File.join(dir, 'dependencies.list')
136
- deps = Open.read(fdep).split("\n") if File.exists?(fdep)
136
+ deps = Open.read(fdep).split("\n") if File.exist?(fdep)
137
137
 
138
138
  fcadep = File.join(dir, 'canfail_dependencies.list')
139
- cadeps = Open.read(fcadep).split("\n") if File.exists?(fcadep)
139
+ cadeps = Open.read(fcadep).split("\n") if File.exist?(fcadep)
140
140
 
141
141
  aborted = error = true if aborted.nil? && error.nil?
142
142
  #if done || error || aborted || running || queued || jobid || search
@@ -177,7 +177,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
177
177
  puts Log.color(:magenta, "Dependencies: ") << deps * ", " if deps
178
178
  puts Log.color(:magenta, "Dependencies (can fail): ") << cadeps * ", " if cadeps
179
179
  puts Log.color(:magenta, "Nodes: ") << nodes * ", "
180
- puts Log.color(:magenta, "Output: ") << File.exists?(File.join(dir, 'std.out')).to_s << (id.nil? ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)")
180
+ puts Log.color(:magenta, "Output: ") << File.exist?(File.join(dir, 'std.out')).to_s << (id.nil? ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)")
181
181
 
182
182
  if options[:batch_parameters]
183
183
  puts Log.color(:magenta, "BATCH parameters: ")
@@ -189,7 +189,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
189
189
  end
190
190
  end
191
191
 
192
- if tail && File.exists?(File.join(dir, 'std.err'))
192
+ if tail && File.exist?(File.join(dir, 'std.err'))
193
193
  if exit_status && exit_status != 0
194
194
  puts Log.color(:magenta, "First error or exception found: ")
195
195
  puts CMD.cmd("grep -i -w 'error\\|[a-z]*exception' #{File.join(dir, 'std.err')} -A #{tail.to_i} |head -n #{tail.to_i}", :no_fail => true).read
@@ -118,19 +118,19 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
118
118
  container_home = nil
119
119
  end
120
120
 
121
- if File.exists?(fid = File.join(dir, 'job.id'))
121
+ if File.exist?(fid = File.join(dir, 'job.id'))
122
122
  id = Open.read(fid).chomp
123
123
  else
124
124
  id = nil
125
125
  end
126
126
 
127
- if File.exists?(fstatus = File.join(dir, 'exit.status'))
127
+ if File.exist?(fstatus = File.join(dir, 'exit.status'))
128
128
  exit_status = Open.read(fstatus).to_i
129
129
  else
130
130
  exit_status = nil
131
131
  end
132
132
 
133
- if File.exists?(fstatus = File.join(dir, 'job.status'))
133
+ if File.exist?(fstatus = File.join(dir, 'job.status'))
134
134
  fstatus_txt = Open.read(fstatus)
135
135
  begin
136
136
  if job_batch_system == "lsf"
@@ -147,13 +147,13 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
147
147
  nodes = []
148
148
  end
149
149
 
150
- if File.exists?(File.join(dir, 'exit.status'))
150
+ if File.exist?(File.join(dir, 'exit.status'))
151
151
  now = File.ctime(File.join(dir, 'exit.status'))
152
152
  else
153
153
  now = Time.now
154
154
  end
155
155
 
156
- if File.exists?(File.join(dir, 'std.out'))
156
+ if File.exist?(File.join(dir, 'std.out'))
157
157
  cerrt = File.ctime File.join(dir, 'std.err')
158
158
  coutt = File.ctime File.join(dir, 'std.out')
159
159
  outt = File.mtime File.join(dir, 'std.out')
@@ -163,10 +163,10 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
163
163
  end
164
164
 
165
165
  fdep = File.join(dir, 'dependencies.list')
166
- deps = Open.read(fdep).split("\n") if File.exists?(fdep)
166
+ deps = Open.read(fdep).split("\n") if File.exist?(fdep)
167
167
 
168
168
  fcadep = File.join(dir, 'canfail_dependencies.list')
169
- cadeps = Open.read(fcadep).split("\n") if File.exists?(fcadep)
169
+ cadeps = Open.read(fcadep).split("\n") if File.exist?(fcadep)
170
170
 
171
171
  if done || error || aborted || running || queued || jobid
172
172
  select = false
@@ -244,7 +244,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
244
244
  puts Log.color(:magenta, "Dependencies (can fail): ") << cadeps * ", " if cadeps
245
245
  puts Log.color(:magenta, "Nodes: ") << nodes * ", " if long
246
246
  puts Log.color(:magenta, "Time elapsed: ") << Misc.format_seconds(time_elapsed) if time_elapsed
247
- puts Log.color(:magenta, "Output: ") << File.exists?(File.join(dir, 'std.out')).to_s << (id.nil? || File.exists?(File.join(dir, 'exit.status')) ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)") if long
247
+ puts Log.color(:magenta, "Output: ") << File.exist?(File.join(dir, 'std.out')).to_s << (id.nil? || File.exist?(File.join(dir, 'exit.status')) ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)") if long
248
248
 
249
249
  if options[:batch_parameters]
250
250
  puts Log.color(:magenta, "BATCH parameters: ")
@@ -316,7 +316,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
316
316
  end
317
317
 
318
318
 
319
- if tail && File.exists?(File.join(dir, 'std.err'))
319
+ if tail && File.exist?(File.join(dir, 'std.err'))
320
320
  if exit_status && exit_status != 0
321
321
  puts Log.color(:magenta, "First error or exception found: ")
322
322
  puts CMD.cmd("grep -i -w 'error\\|[a-z]*exception' #{File.join(dir, 'std.err')} -A #{tail.to_i} |head -n #{tail.to_i}", :no_fail => true).read
@@ -46,7 +46,7 @@ if directory =~ /^[0-9]*$/
46
46
  end
47
47
  end
48
48
 
49
- raise ParameterException, "Could not identify job #{directory}" unless File.exists?(directory)
49
+ raise ParameterException, "Could not identify job #{directory}" unless File.exist?(directory)
50
50
 
51
51
  require 'rbbt/hpc/slurm'
52
52
 
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rbbt-util'
4
+ require 'rbbt/util/simpleopt'
5
+
6
+ $0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands
7
+
8
+ options = SOPT.setup <<EOF
9
+ Select entries in a tsv based on some criteria
10
+
11
+ $ rbbt tsv subset [options] file.tsv <key> <criteria>
12
+
13
+ Subsets entries from a TSV file from a given list. Works with Tokyocabinet HDB and BDB as well.
14
+
15
+ -tch--tokyocabinet File is a TC HDB
16
+ -tcb--tokyocabinet_bd File is a TC BDB
17
+ -hh--header_hash* Change the character used to mark the header line (defaults to #)
18
+ -s--subset* Subset of keys (Comma-separated or file)
19
+ -m--merge Merge TSV rows
20
+ -h--help Help
21
+ EOF
22
+
23
+ SOPT.usage if options[:help]
24
+
25
+ file, key, criteria = ARGV
26
+
27
+ key, criteria, file = [file, key, nil] if criteria.nil?
28
+
29
+ file = STDIN if file == '-' || file.nil?
30
+
31
+ raise ParameterException, "Please specify the tsv file as argument" if file.nil?
32
+
33
+ options[:fields] = options[:fields].split(/,\|/) if options[:fields]
34
+ options[:header_hash] = options["header_hash"]
35
+
36
+ case
37
+ when options[:tokyocabinet]
38
+ tsv = Persist.open_tokyocabinet(file, false)
39
+ puts tsv.summary
40
+ when options[:tokyocabinet_bd]
41
+ tsv = Persist.open_tokyocabinet(file, false, nil, TokyoCabinet::BDB)
42
+ puts tsv.summary
43
+ else
44
+ tsv = TSV.open(file, options)
45
+ end
46
+
47
+ criteria = criteria.to_regexp.to_regexp if criteria =~ /\/.*\/.*/
48
+ puts tsv.select(key => criteria)
@@ -28,7 +28,7 @@ end
28
28
 
29
29
  file = ARGV.shift
30
30
 
31
- file = STDIN if file == '-'
31
+ file = STDIN if file == '-' || file.nil?
32
32
 
33
33
  case
34
34
  when options[:tokyocabinet]
@@ -38,15 +38,16 @@ when options[:tokyocabinet_bd]
38
38
  else
39
39
  if String === file
40
40
  file = file.dup
41
- Path.setup(File.expand_path(file))
41
+ file = Path.setup(File.expand_path(file))
42
42
  end
43
43
  tsv = file
44
44
  end
45
45
 
46
- tsv = TSV.open(tsv) if IO === tsv
46
+ tsv = TSV.open(tsv) if IO === tsv || Path === tsv
47
47
 
48
48
 
49
49
  begin
50
+ require 'rbbt/workflow'
50
51
  Workflow.require_workflow "Genomics"
51
52
  tsv = Genomics.job(:names, nil, :tsv => tsv).run
52
53
  rescue
@@ -28,5 +28,5 @@ SOPT.usage if options[:help]
28
28
 
29
29
  target, *files = ARGV
30
30
 
31
- raise "Target already exists: #{ target }" if File.exists?(target) and not File.directory?(target)
31
+ raise "Target already exists: #{ target }" if File.exist?(target) and not File.directory?(target)
32
32
  Step.archive(files, target)
@@ -36,14 +36,14 @@ file = ARGV.shift
36
36
 
37
37
  $seen = []
38
38
  def get_step(file)
39
- file = File.expand_path(file) if File.exists?(file)
39
+ file = File.expand_path(file) if File.exist?(file)
40
40
  file = file.sub(/\.(info|files)$/,'')
41
41
  $seen << file
42
42
  Workflow.load_step file
43
43
  end
44
44
 
45
45
  def touch(step)
46
- return unless File.exists?(step.path)
46
+ return unless File.exist?(step.path)
47
47
  step.dependencies.each do |dep|
48
48
  next unless Open.exists?(dep.path)
49
49
  if Open.mtime(dep.path) > Open.mtime(step.path) + 1
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.34.5
4
+ version: 5.34.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-20 00:00:00.000000000 Z
11
+ date: 2022-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -452,6 +452,7 @@ files:
452
452
  - share/rbbt_commands/tsv/query
453
453
  - share/rbbt_commands/tsv/read
454
454
  - share/rbbt_commands/tsv/read_excel
455
+ - share/rbbt_commands/tsv/select
455
456
  - share/rbbt_commands/tsv/slice
456
457
  - share/rbbt_commands/tsv/sort
457
458
  - share/rbbt_commands/tsv/subset