rbbt-util 5.32.24 → 5.32.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rbbt_find.rb +74 -0
  3. data/lib/rbbt/annotations/annotated_array.rb +4 -0
  4. data/lib/rbbt/annotations/util.rb +29 -0
  5. data/lib/rbbt/entity.rb +3 -1
  6. data/lib/rbbt/hpc/orchestrate/batches.rb +140 -0
  7. data/lib/rbbt/hpc/orchestrate/chains.rb +173 -0
  8. data/lib/rbbt/hpc/orchestrate/rules.rb +70 -0
  9. data/lib/rbbt/hpc/orchestrate.old.rb +220 -0
  10. data/lib/rbbt/hpc/orchestrate.rb +24 -200
  11. data/lib/rbbt/hpc/slurm.rb +1 -0
  12. data/lib/rbbt/persist/tsv.rb +1 -1
  13. data/lib/rbbt/tsv/excel.rb +16 -8
  14. data/lib/rbbt/util/log.rb +6 -2
  15. data/lib/rbbt/util/migrate.rb +6 -1
  16. data/lib/rbbt/util/misc/inspect.rb +4 -1
  17. data/lib/rbbt/util/misc.rb +5 -0
  18. data/lib/rbbt/util/python.rb +1 -1
  19. data/lib/rbbt/workflow/definition.rb +1 -1
  20. data/lib/rbbt/workflow/examples.rb +0 -65
  21. data/lib/rbbt/workflow/integration/nextflow.rb +74 -14
  22. data/lib/rbbt/workflow/step/accessor.rb +0 -70
  23. data/lib/rbbt/workflow/step/dependencies.rb +8 -2
  24. data/lib/rbbt/workflow/step/run.rb +1 -1
  25. data/lib/rbbt/workflow/step/save_load_inputs.rb +162 -0
  26. data/lib/rbbt/workflow/step.rb +2 -1
  27. data/lib/rbbt/workflow/task.rb +2 -2
  28. data/lib/rbbt/workflow.rb +9 -2
  29. data/share/rbbt_commands/hpc/tail +0 -13
  30. data/share/rbbt_commands/lsf/tail +0 -13
  31. data/share/rbbt_commands/slurm/tail +0 -13
  32. data/share/rbbt_commands/tsv/keys +14 -15
  33. data/share/rbbt_commands/tsv/read_excel +2 -2
  34. data/share/rbbt_commands/workflow/task +11 -5
  35. data/test/rbbt/annotations/test_util.rb +11 -0
  36. data/test/rbbt/hpc/orchestrate/test_batches.rb +113 -0
  37. data/test/rbbt/hpc/orchestrate/test_chains.rb +139 -0
  38. data/test/rbbt/hpc/orchestrate/test_rules.rb +92 -0
  39. data/test/rbbt/hpc/test_orchestrate.rb +144 -0
  40. data/test/rbbt/tsv/test_excel.rb +38 -4
  41. data/test/rbbt/util/test_misc.rb +4 -0
  42. data/test/rbbt/workflow/step/test_dependencies.rb +14 -13
  43. data/test/rbbt/workflow/step/test_save_load_inputs.rb +46 -0
  44. metadata +19 -2
@@ -25,71 +25,6 @@ module Workflow
25
25
  end.compact
26
26
  end
27
27
 
28
- def self.load_inputs(dir, input_names, input_types)
29
- inputs = {}
30
- if File.exists?(dir) && ! File.directory?(dir)
31
- Log.debug "Loading inputs from #{dir}, not a directory trying as tar.gz"
32
- tarfile = dir
33
- digest = CMD.cmd("md5sum '#{tarfile}'").read.split(" ").first
34
- tmpdir = Rbbt.tmp.input_bundle[digest].find
35
- Misc.untar(tarfile, tmpdir) unless File.exists? tmpdir
36
- files = tmpdir.glob("*")
37
- if files.length == 1 && File.directory?(files.first)
38
- tmpdir = files.first
39
- end
40
- load_inputs(tmpdir, input_names, input_types)
41
- else
42
- dir = Path.setup(dir.dup)
43
- input_names.each do |input|
44
- file = dir[input].find
45
- file = dir.glob(input.to_s + ".*").reject{|f| f =~ /\.md5$/}.first if file.nil? or not file.exists?
46
- Log.debug "Trying #{ input }: #{file}"
47
- next unless file and file.exists?
48
-
49
-
50
- case input_types[input]
51
- when :file, :binary
52
- Log.debug "Pointing #{ input } to #{file}"
53
- if file =~ /\.yaml/
54
- inputs[input.to_sym] = YAML.load(Open.read(file))
55
- else
56
- if File.symlink?(file)
57
- link_target = File.expand_path(File.readlink(file), File.dirname(file))
58
- inputs[input.to_sym] = link_target
59
- else
60
- inputs[input.to_sym] = Open.realpath(file)
61
- end
62
- end
63
- when :text
64
- Log.debug "Reading #{ input } from #{file}"
65
- inputs[input.to_sym] = Open.read(file)
66
- when :array
67
- Log.debug "Reading array #{ input } from #{file}"
68
- inputs[input.to_sym] = Open.read(file).split("\n")
69
- when :tsv
70
- Log.debug "Opening tsv #{ input } from #{file}"
71
- inputs[input.to_sym] = TSV.open(file)
72
- when :boolean
73
- inputs[input.to_sym] = (file.read.strip == 'true')
74
- else
75
- Log.debug "Loading #{ input } from #{file}"
76
- inputs[input.to_sym] = file.read.strip
77
- end
78
-
79
- end
80
- inputs = IndiferentHash.setup(inputs)
81
-
82
- dir.glob("*#*").each do |od|
83
- name = File.basename(od)
84
- value = Open.read(od)
85
- Log.debug "Loading override dependency #{ name } as #{value}"
86
- inputs[name] = value.chomp
87
- end
88
-
89
- inputs
90
- end
91
- end
92
-
93
28
  def example_inputs(task_name, example)
94
29
  inputs = {}
95
30
  IndiferentHash.setup(inputs)
@@ -1,37 +1,97 @@
1
1
  module Workflow
2
- def nextflow_file(file, name = nil)
2
+ def self.nextflow_file_params(file)
3
+ Open.read(file).scan(/params\.\w+/).collect{|p| p.split(".").last}.uniq
4
+ end
5
+
6
+ def self.nextflow_includes(file)
7
+ Open.read(file).scan(/^include\s*{\s*(.*?)(?:\s*as.*?)?}\s*from\s+"(.*?)"(?:\s*params.*)?/).collect{|p| p}.uniq
8
+ end
9
+
10
+ def self.nextflow_recursive_params(file)
11
+ params = nextflow_file_params(file)
12
+ dir = File.dirname(file)
13
+ nextflow_includes(file).inject(params) do |params,info|
14
+ name_str, included_file = info
15
+ included_file = File.join(dir, included_file)
16
+ included_file += '.nf' unless File.exists?(included_file) || ! File.exists?(included_file + '.nf')
17
+ name_str.split(";").each do |name|
18
+ name = name.strip
19
+ include_params = nextflow_recursive_params(included_file).collect{|p| [p,name] * "-"}
20
+ params += include_params
21
+ end
22
+ params
23
+ end
24
+ end
25
+
26
+ def nextflow_file(file, name = nil, output = nil)
27
+ name, output = nil, name if Hash === name
28
+
29
+ if Hash === output
30
+ result, output = output.collect.first
31
+ else
32
+ result = :text
33
+ end
34
+
3
35
  file = file + '.nf' unless File.exists?(file) || ! File.exists?(file + '.nf')
4
36
  file = File.expand_path(file)
5
- name ||= File.basename(file).sub(/\.nf$/,'')
6
- params = Open.read(file).scan(/params\.\w+/).collect{|p| p.split(".").last}.uniq
37
+ name ||= File.basename(file).sub(/\.nf$/,'').gsub(/\s/,'_')
38
+ params = Workflow.nextflow_recursive_params(file)
7
39
 
8
40
  params.each do |param|
9
- input param, :string
41
+ p,_sep, section = param.partition("-")
42
+ if section.nil? || section.empty?
43
+ input param, :string, "Nextflow param #{p}", nil, :nofile => true
44
+ else
45
+ input param, :string, "Nextflow param #{p} from import #{section}", nil, :nofile => true
46
+ end
10
47
  end
11
- task name => :text do
48
+ task name => result do
12
49
  work = file('work')
13
- output = file('output')
14
50
  profile = config :profile, :nextflow
15
- Misc.in_dir output do
51
+
52
+ new_inputs = inputs.zip(inputs.fields).collect do |v,f|
53
+ if String === v && m = v.match(/^JOB_FILE:(.*)/)
54
+ file(m[1])
55
+ elsif v.nil?
56
+ Rbbt::Config.get(['nextflow', f] * "_", 'default', f)
57
+ else
58
+ v
59
+ end
60
+ end
61
+
62
+ inputs.replace new_inputs
63
+
64
+ Misc.in_dir file('stage') do
16
65
  if profile
17
- cmd("nextflow run -work-dir #{work} -name #{clean_name} -ansi-log false -profile #{profile} #{file}", inputs.to_hash.merge('add_option_dashes' => true))
66
+ cmd("nextflow run -work-dir #{work} -ansi-log false -profile #{profile} #{file}", inputs.to_hash.merge('add_option_dashes' => true))
18
67
  else
19
- cmd("nextflow run -work-dir #{work} -name #{clean_name} -ansi-log false #{file}", inputs.to_hash.merge('add_option_dashes' => true))
68
+ cmd("nextflow run -work-dir #{work} -ansi-log false #{file}", inputs.to_hash.merge('add_option_dashes' => true))
20
69
  end
21
70
  end
71
+
72
+ output_file = file(output).glob.first if output
73
+ output_file = work[File.join('*', '*', output)].glob.first if output && output_file.nil?
74
+
75
+ if output_file.nil?
76
+ work[File.join("*", "*", "*")].glob * "\n"
77
+ else
78
+ Open.link output_file, self.tmp_path
79
+ #Open.rm_rf file('work')
80
+ nil
81
+ end
22
82
  end
23
83
  end
24
84
 
25
- def nextflow_dir(path)
85
+ def nextflow_dir(path, output = nil)
26
86
  main = File.join(path, 'main.nf')
27
- nextflow_file main, File.basename(path)
87
+ nextflow_file main, File.basename(path), output
28
88
  end
29
89
 
30
- def nextflow(path)
90
+ def nextflow(path, *args)
31
91
  if File.directory?(path)
32
- nextflow_dir path
92
+ nextflow_dir path, *args
33
93
  else
34
- nextflow_file path
94
+ nextflow_file path, *args
35
95
  end
36
96
  end
37
97
  end
@@ -86,76 +86,6 @@ class Step
86
86
  end
87
87
  end
88
88
 
89
- def self.save_inputs(inputs, input_types, dir)
90
- inputs.each do |name,value|
91
- type = input_types[name]
92
- type = type.to_s if type
93
- path = File.join(dir, name.to_s)
94
-
95
- Log.debug "Saving job input #{name} (#{type}) into #{path}"
96
- case
97
- when Step === value
98
- Open.ln_s(value.path, path)
99
- when type.to_s == "file"
100
- if String === value && File.exists?(value)
101
- value = File.expand_path(value)
102
- Open.ln_s(value, path)
103
- else
104
- value = value.collect{|v| v = "#{v}" if Path === v; v }if Array === value
105
- value = "#{value}" if Path === value
106
- Open.write(path + '.yaml', value.to_yaml)
107
- end
108
- when Array === value
109
- Open.write(path, value.collect{|v| Step === v ? v.path : v.to_s} * "\n")
110
- when IO === value
111
- if value.filename && String === value.filename && File.exists?(value.filename)
112
- Open.ln_s(value.filename, path)
113
- else
114
- Open.write(path, value)
115
- end
116
- else
117
- Open.write(path, value.to_s)
118
- end
119
- end.any?
120
- end
121
-
122
- def self.save_job_inputs(job, dir, options = nil)
123
- options = IndiferentHash.setup options.dup if options
124
-
125
- task_name = Symbol === job.overriden ? job.overriden : job.task_name
126
- workflow = job.workflow
127
- workflow = Kernel.const_get workflow if String === workflow
128
- if workflow
129
- task_info = IndiferentHash.setup(workflow.task_info(task_name))
130
- input_types = IndiferentHash.setup(task_info[:input_types])
131
- task_inputs = IndiferentHash.setup(task_info[:inputs])
132
- input_defaults = IndiferentHash.setup(task_info[:input_defaults])
133
- else
134
- task_info = IndiferentHash.setup({})
135
- input_types = IndiferentHash.setup({})
136
- task_inputs = IndiferentHash.setup({})
137
- input_defaults = IndiferentHash.setup({})
138
- end
139
-
140
- inputs = IndiferentHash.setup({})
141
- real_inputs = job.real_inputs || job.info[:real_inputs]
142
- job.recursive_inputs.zip(job.recursive_inputs.fields).each do |value,name|
143
- next unless task_inputs.include? name.to_sym
144
- next unless real_inputs.include? name.to_sym
145
- next if options && ! options.include?(name)
146
- next if value.nil?
147
- next if input_defaults[name] == value
148
- inputs[name] = value
149
- end
150
-
151
- if options && options.include?('override_dependencies')
152
- inputs.merge!(:override_dependencies => open[:override_dependencies])
153
- input_types = IndiferentHash.setup(input_types.merge(:override_dependencies => :array))
154
- end
155
- save_inputs(inputs, input_types, dir)
156
-
157
- inputs.keys
158
- end
159
89
 
160
90
  def name
161
91
  @name ||= path.sub(/.*\/#{Regexp.quote task_name.to_s}\/(.*)/, '\1')
@@ -254,7 +254,12 @@ class Step
254
254
  when :bootstrap
255
255
  cpus = rest.nil? ? nil : rest.first
256
256
 
257
- cpus = config('dep_cpus', 'bootstrap', :default => [5, list.length / 2].min) if cpus.nil? || cpus.to_i == 0
257
+ if cpus.nil?
258
+ keys = ['bootstrap'] + list.collect{|d| [d.task_name, d.task_signature] }.flatten.uniq
259
+ cpus = config('dep_cpus', *keys, :default => [5, list.length / 2].min)
260
+ elsif Symbol === cpus
261
+ cpus = config('dep_cpus', cpus, :default => [5, list.length / 2].min)
262
+ end
258
263
 
259
264
  respawn = rest && rest.include?(:respawn)
260
265
  respawn = false if rest && rest.include?(:norespawn)
@@ -369,7 +374,8 @@ class Step
369
374
  next unless step.dependencies and step.dependencies.any?
370
375
  (step.dependencies + step.input_dependencies).each do |step_dep|
371
376
  next unless step.dependencies.include?(step_dep)
372
- next if step_dep.done? or step_dep.running? or (ComputeDependency === step_dep and (step_dep.compute == :nodup or step_dep.compute == :ignore))
377
+ next if step_dep.done? or step_dep.running? or
378
+ (ComputeDependency === step_dep and (step_dep.compute == :nodup or step_dep.compute == :ignore))
373
379
  dep_step[step_dep.path] ||= []
374
380
  dep_step[step_dep.path] << step
375
381
  end
@@ -419,7 +419,7 @@ class Step
419
419
  set_info :dependencies, dependencies.collect{|dep| [dep.task_name, dep.name, dep.path]}
420
420
 
421
421
  config_keys = Rbbt::Config::GOT_KEYS[config_keys_pre.length..-1]
422
- set_info :config_keys, config_keys
422
+ set_info :config_keys, config_keys.uniq
423
423
 
424
424
  if result.nil? && File.exists?(self.tmp_path) && ! File.exists?(self.path)
425
425
  Open.mv self.tmp_path, self.path
@@ -0,0 +1,162 @@
1
+ module Workflow
2
+ def self.load_inputs(dir, input_names, input_types)
3
+ inputs = {}
4
+ if File.exists?(dir) && ! File.directory?(dir)
5
+ Log.debug "Loading inputs from #{dir}, not a directory trying as tar.gz"
6
+ tarfile = dir
7
+ digest = CMD.cmd("md5sum '#{tarfile}'").read.split(" ").first
8
+ tmpdir = Rbbt.tmp.input_bundle[digest].find
9
+ Misc.untar(tarfile, tmpdir) unless File.exists? tmpdir
10
+ files = tmpdir.glob("*")
11
+ if files.length == 1 && File.directory?(files.first)
12
+ tmpdir = files.first
13
+ end
14
+ load_inputs(tmpdir, input_names, input_types)
15
+ else
16
+ dir = Path.setup(dir.dup)
17
+ input_names.each do |input|
18
+ file = dir[input].find
19
+ file = dir.glob(input.to_s + ".*").reject{|f| f =~ /\.md5$/}.first if file.nil? or not (File.symlink?(file) || file.exists?)
20
+ Log.debug "Trying #{ input }: #{file}"
21
+ next unless file and (File.symlink?(file) || file.exists?)
22
+
23
+ type = input_types[input]
24
+
25
+ type = :io if file.split(".").last == 'as_io'
26
+
27
+ case type
28
+ when :io
29
+ inputs[input.to_sym] = Open.open(Open.realpath(file))
30
+ when :file, :binary
31
+ Log.debug "Pointing #{ input } to #{file}"
32
+ if file =~ /\.yaml/
33
+ inputs[input.to_sym] = YAML.load(Open.read(file))
34
+ else
35
+ if File.symlink?(file)
36
+ link_target = File.expand_path(File.readlink(file), File.dirname(file))
37
+ inputs[input.to_sym] = link_target
38
+ else
39
+ inputs[input.to_sym] = Open.realpath(file)
40
+ end
41
+ end
42
+ when :text
43
+ Log.debug "Reading #{ input } from #{file}"
44
+ inputs[input.to_sym] = Open.read(file)
45
+ when :array
46
+ Log.debug "Reading array #{ input } from #{file}"
47
+ inputs[input.to_sym] = Open.read(file).split("\n")
48
+ when :tsv
49
+ Log.debug "Opening tsv #{ input } from #{file}"
50
+ inputs[input.to_sym] = TSV.open(file)
51
+ when :boolean
52
+ inputs[input.to_sym] = (file.read.strip == 'true')
53
+ else
54
+ Log.debug "Loading #{ input } from #{file}"
55
+ inputs[input.to_sym] = file.read.strip
56
+ end
57
+
58
+ end
59
+ inputs = IndiferentHash.setup(inputs)
60
+
61
+ dir.glob("*#*").each do |od|
62
+ name = File.basename(od)
63
+ value = Open.read(od)
64
+ Log.debug "Loading override dependency #{ name } as #{value}"
65
+ inputs[name] = value.chomp
66
+ end
67
+
68
+ inputs
69
+ end
70
+ end
71
+
72
+ def task_inputs_from_directory(task_name, directory)
73
+ task_info = self.task_info(task_name)
74
+ Workflow.load_inputs(directory, task_info[:inputs], task_info[:input_types])
75
+ end
76
+
77
+ def job_for_directory_inputs(task_name, directory, jobname = nil)
78
+ inputs = task_inputs_from_directory(task_name, directory)
79
+ job(task_name, jobname, inputs)
80
+ end
81
+
82
+ end
83
+
84
+ class Step
85
+ def self.save_inputs(inputs, input_types, input_options, dir)
86
+ inputs.each do |name,value|
87
+ type = input_types[name]
88
+ type = type.to_s if type
89
+ path = File.join(dir, name.to_s)
90
+
91
+ path = path + '.as_io' if (IO === value || Step === value) && ! (input_options[name] && input_options[name][:nofile])
92
+ Log.debug "Saving job input #{name} (#{type}) into #{path}"
93
+
94
+ case
95
+ when IO === value
96
+ Open.write(path, value.to_s)
97
+ when Step === value
98
+ Open.ln_s(value.path, path)
99
+ when type.to_s == "file"
100
+ if String === value && File.exists?(value)
101
+ value = File.expand_path(value)
102
+ Open.ln_s(value, path)
103
+ else
104
+ value = value.collect{|v| v = "#{v}" if Path === v; v }if Array === value
105
+ value = "#{value}" if Path === value
106
+ Open.write(path + '.yaml', value.to_yaml)
107
+ end
108
+ when Array === value
109
+ Open.write(path, value.collect{|v| Step === v ? v.path : v.to_s} * "\n")
110
+ when IO === value
111
+ if value.filename && String === value.filename && File.exists?(value.filename)
112
+ Open.ln_s(value.filename, path)
113
+ else
114
+ Open.write(path, value)
115
+ end
116
+ else
117
+ Open.write(path, value.to_s)
118
+ end
119
+ end.any?
120
+ end
121
+
122
+ def self.save_job_inputs(job, dir, options = nil)
123
+ options = IndiferentHash.setup options.dup if options
124
+
125
+ task_name = Symbol === job.overriden ? job.overriden : job.task_name
126
+ workflow = job.workflow
127
+ workflow = Kernel.const_get workflow if String === workflow
128
+ if workflow
129
+ task_info = IndiferentHash.setup(workflow.task_info(task_name))
130
+ input_types = IndiferentHash.setup(task_info[:input_types])
131
+ input_options = IndiferentHash.setup(task_info[:input_options])
132
+ task_inputs = IndiferentHash.setup(task_info[:inputs])
133
+ input_defaults = IndiferentHash.setup(task_info[:input_defaults])
134
+ else
135
+ task_info = IndiferentHash.setup({})
136
+ input_types = IndiferentHash.setup({})
137
+ task_inputs = IndiferentHash.setup({})
138
+ task_options = IndiferentHash.setup({})
139
+ input_defaults = IndiferentHash.setup({})
140
+ end
141
+
142
+ inputs = IndiferentHash.setup({})
143
+ real_inputs = job.real_inputs || job.info[:real_inputs]
144
+ job.recursive_inputs.zip(job.recursive_inputs.fields).each do |value,name|
145
+ next unless task_inputs.include? name.to_sym
146
+ next unless real_inputs.include? name.to_sym
147
+ next if options && ! options.include?(name)
148
+ next if value.nil?
149
+ next if input_defaults[name] == value
150
+ inputs[name] = value
151
+ end
152
+
153
+ if options && options.include?('override_dependencies')
154
+ inputs.merge!(:override_dependencies => open[:override_dependencies])
155
+ input_types = IndiferentHash.setup(input_types.merge(:override_dependencies => :array))
156
+ end
157
+
158
+ save_inputs(inputs, input_types, input_options, dir)
159
+
160
+ inputs.keys
161
+ end
162
+ end
@@ -6,6 +6,7 @@ require 'rbbt/workflow/step/accessor'
6
6
  require 'rbbt/workflow/step/prepare'
7
7
  require 'rbbt/workflow/step/status'
8
8
  require 'rbbt/workflow/step/info'
9
+ require 'rbbt/workflow/step/save_load_inputs'
9
10
 
10
11
  class Step
11
12
  attr_accessor :clean_name, :path, :task, :workflow, :inputs, :dependencies, :bindings
@@ -321,7 +322,7 @@ class Step
321
322
  def load
322
323
  res = begin
323
324
  @result = nil if IO === @result && @result.closed?
324
- if @result && @path != @result
325
+ if @result && @path != @result && ! StreamArray === @result
325
326
  res = @result
326
327
  else
327
328
  join if not done?
@@ -90,11 +90,11 @@ module Task
90
90
 
91
91
  maps = (Array === dep and Hash === dep.last) ? dep.last.keys : []
92
92
  raise "Dependency task not found: #{dep}" if task.nil?
93
- next if seen.include? [wf, task.name]
93
+ next if seen.include? [wf, task.name, maps]
94
94
 
95
95
  task.workflow = wf if wf
96
96
 
97
- seen << [wf, task.name]
97
+ seen << [wf, task.name, maps]
98
98
  new_inputs = task.inputs - maps
99
99
  next unless new_inputs.any?
100
100
  if task_inputs[task].nil?
data/lib/rbbt/workflow.rb CHANGED
@@ -244,7 +244,7 @@ module Workflow
244
244
  when :hash
245
245
  clean_inputs = Annotated.purge(inputs)
246
246
  clean_inputs = clean_inputs.collect{|i| Symbol === i ? i.to_s : i }
247
- deps_str = dependencies.collect{|d| (Step === d || (defined?(RemoteStep) && RemoteStep === Step)) ? "Step: " << (d.overriden? ? d.path : d.short_path) : d }
247
+ deps_str = dependencies.collect{|d| (Step === d || (defined?(RemoteStep) && RemoteStep === Step)) ? "Step: " << (Symbol === d.overriden ? d.path : d.short_path) : d }
248
248
  key_obj = {:inputs => clean_inputs, :dependencies => deps_str }
249
249
  key_str = Misc.obj2str(key_obj)
250
250
  hash_str = Misc.digest(key_str)
@@ -465,7 +465,14 @@ module Workflow
465
465
  extension = nil
466
466
  if dependencies.any?
467
467
  dep_basename = File.basename(dependencies.last.path)
468
- extension = dep_basename.split(".").last if dep_basename.include?('.')
468
+ if dep_basename.include? "."
469
+ parts = dep_basename.split(".")
470
+ extension = [parts.pop]
471
+ while parts.last.length <= 4
472
+ extension << parts.pop
473
+ end
474
+ extension = extension.reverse * "."
475
+ end
469
476
  end
470
477
  end
471
478
 
@@ -13,19 +13,6 @@ Queue a job in Marenostrum
13
13
  $ rbbt slurm tail <directory> [options]
14
14
 
15
15
  -h--help Print this help
16
- -d--done Done jobs only
17
- -e--error Error jobs only
18
- -a--aborted SLURM aboted jobs
19
- -r--running Running jobs only
20
- -q--queued Queued jobs only
21
- -j--job* Job ids
22
- -s--search* Regular expression
23
- -t--tail* Show the last lines of the STDERR
24
- -p--progress Report progress of job and the dependencies
25
- -SBP--sbatch_parameters show sbatch parameters
26
- -PERF--procpath_performance show Procpath performance summary
27
- -sacct--sacct_peformance show sacct performance summary
28
- -bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
29
16
  EOF
30
17
 
31
18
  if options[:help]
@@ -13,19 +13,6 @@ Queue a job in Marenostrum
13
13
  $ rbbt slurm tail <directory> [options]
14
14
 
15
15
  -h--help Print this help
16
- -d--done Done jobs only
17
- -e--error Error jobs only
18
- -a--aborted SLURM aboted jobs
19
- -r--running Running jobs only
20
- -q--queued Queued jobs only
21
- -j--job* Job ids
22
- -s--search* Regular expression
23
- -t--tail* Show the last lines of the STDERR
24
- -p--progress Report progress of job and the dependencies
25
- -SBP--sbatch_parameters show sbatch parameters
26
- -PERF--procpath_performance show Procpath performance summary
27
- -sacct--sacct_peformance show sacct performance summary
28
- -bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
29
16
  EOF
30
17
 
31
18
  if options[:help]
@@ -13,19 +13,6 @@ Queue a job in Marenostrum
13
13
  $ rbbt slurm tail <directory> [options]
14
14
 
15
15
  -h--help Print this help
16
- -d--done Done jobs only
17
- -e--error Error jobs only
18
- -a--aborted SLURM aboted jobs
19
- -r--running Running jobs only
20
- -q--queued Queued jobs only
21
- -j--job* Job ids
22
- -s--search* Regular expression
23
- -t--tail* Show the last lines of the STDERR
24
- -p--progress Report progress of job and the dependencies
25
- -SBP--sbatch_parameters show sbatch parameters
26
- -PERF--procpath_performance show Procpath performance summary
27
- -sacct--sacct_peformance show sacct performance summary
28
- -bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
29
16
  EOF
30
17
 
31
18
  if options[:help]
@@ -41,19 +41,18 @@ parser = TSV::Parser.new TSV.get_stream(file), options.merge(:fields => [])
41
41
 
42
42
  options[:merge] = false if options[:merge] == "false"
43
43
 
44
- Thread.new do
45
- line = parser.first_line
46
- bar = Log::ProgressBar.new
47
- while line
48
- bar.tick
49
-
50
- line = Misc.fixutf8(line)
51
- line = parser.process line
52
- raise SKIP_LINE if line.empty?
53
- parts = parser.chop_line line
54
- key, values = parser.get_values parts
55
- values = parser.cast_values values if parser.cast?
56
-
57
- puts key
58
- end
44
+ line = parser.first_line
45
+ bar = Log::ProgressBar.new
46
+ while line
47
+ bar.tick
48
+
49
+ line = Misc.fixutf8(line)
50
+ line = parser.process line
51
+ raise SKIP_LINE if line.empty?
52
+ parts = parser.chop_line line
53
+ key, values = parser.get_values parts
54
+ values = parser.cast_values values if parser.cast?
55
+
56
+ puts key
57
+ line = parser.stream.gets
59
58
  end
@@ -22,7 +22,7 @@ Use - to read from STDIN
22
22
  -h--help Print this help
23
23
  -s--sheet* Sheet to extract
24
24
  -skip--skip_rows* Initial rows to skip
25
-
25
+ -o--original Dump the rows without parsing them into TSV
26
26
  EOF
27
27
  if options[:help]
28
28
  if defined? rbbt_usage
@@ -39,5 +39,5 @@ raise ParameterException, "No excel file given" if excelfile.nil?
39
39
 
40
40
  options[:zipped] ||= true if options[:merge]
41
41
  require 'rbbt/tsv/excel'
42
- puts TSV.excel(excelfile, options).to_s
42
+ puts TSV.excel(excelfile, options.merge(:text => options[:original]))
43
43
 
@@ -104,7 +104,7 @@ def fix_options(workflow, task, job_options)
104
104
  elsif input_options[name] and input_options[name][:stream] and value == "-"
105
105
  STDIN
106
106
  else
107
- if Array === value
107
+ if Array === value || IO === value
108
108
  value
109
109
  else
110
110
  array_separator = $array_separator
@@ -137,6 +137,8 @@ def fix_options(workflow, task, job_options)
137
137
  TSV.open(STDIN, :unnamed => true, :sep => $field_separator, :sep2 => ($array_separator || "|"))
138
138
  when (Misc.is_filename?(value) and String)
139
139
  TSV.open(value, :unnamed => true, :sep => $field_separator, :sep2 => ($array_separator || "|"))
140
+ when IO
141
+ TSV.open(value, :unnamed => true, :sep => $field_separator, :sep2 => ($array_separator || "|"))
140
142
  else
141
143
  TSV.open(StringIO.new(value), :unnamed => true, :sep => $field_separator, :sep2 => ($array_separator || "|"))
142
144
  end
@@ -571,10 +573,14 @@ when Step
571
573
  elsif detach
572
574
  exit! 0
573
575
  else
574
- res.join
575
- Open.open(res.path, :mode => 'rb') do |io|
576
- Misc.consume_stream(io, false, out)
577
- end if Open.exist?(res.path) || Open.remote?(res.path) || Open.ssh?(res.path)
576
+ if %w(float integer string boolean).include?(res.result_type.to_s)
577
+ out.puts res.load
578
+ else
579
+ res.join
580
+ Open.open(res.path, :mode => 'rb') do |io|
581
+ Misc.consume_stream(io, false, out)
582
+ end if Open.exist?(res.path) || Open.remote?(res.path) || Open.ssh?(res.path)
583
+ end
578
584
  end
579
585
  else
580
586
  if Array === res