rbbt-util 5.9.2 → 5.9.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74f82edf975ef1ad0c05363e915c57fa2ae1ec43
4
- data.tar.gz: f42669bd1035c8734f8425f317ce30f8a0aedbaa
3
+ metadata.gz: 29daeb012f3ce90b479f7b858abff79e166f936d
4
+ data.tar.gz: 78e6fd7422a46b33271de8c8f0eb81d0fc97d772
5
5
  SHA512:
6
- metadata.gz: 1c8e0ca5a067f5cc2dc79dea4eaba8ebe369509ac5f23b24740ebcdddc80cf9bd2b7ee78b19359f8b5382ff27a40c5a92285f0450919e87b6209935c20996f60
7
- data.tar.gz: d617993ba70c9cb43a5aa9ba176da9994db0493aafc484831b68bb7c1804f34ffff3a7f88c2342d21d3b06cfd4a5db08014e033cd90915669e6cd7b56625f18f
6
+ metadata.gz: bcbb30fb3e53e872d6b2de2fce030f93a78fbe01b7d1a238d8dff243d602f2f42ba6d11e01de4f11ac9aead3d4a90c03779bdd8f1311aa72b4c62d2d320bfef5
7
+ data.tar.gz: 4e5faf9f1ac86e500fd9f5d747ed2c34ba31aabf2a8bbced66aa626bb7e2f1b7d3428cd5af714dfe09c7ae5990302409edfb691bafe1e7fa4bf99d64c01f4dcc
@@ -199,6 +199,7 @@ module TSV
199
199
  end
200
200
 
201
201
  def zip_new(key, values)
202
+ values = [values] unless Array === values
202
203
  if self.include? key
203
204
  new = []
204
205
  self[key, true].each_with_index do |v,i|
@@ -43,7 +43,7 @@ module Misc
43
43
  word = words.shift
44
44
  while word
45
45
  word = word[0..size-indent-offset-4] + '...' if word.length >= size - indent - offset
46
- while word and line.length + word.length <= size - indent
46
+ while word and Log.uncolor(line).length + Log.uncolor(word).length <= size - indent
47
47
  line << word << " "
48
48
  word = words.shift
49
49
  end
@@ -60,6 +60,7 @@ module Misc
60
60
  end
61
61
 
62
62
  def self.format_definition_list_item(dt, dd, size = 80, indent = 20, color = :yellow)
63
+ dd = "" if dd.nil?
63
64
  dt = dt.to_s + ":" unless dd.empty?
64
65
  dt = Log.color color, dt if color
65
66
  len = Log.uncolor(dt).length
data/lib/rbbt/workflow.rb CHANGED
@@ -107,9 +107,21 @@ module Workflow
107
107
  remote_workflows = Rbbt.etc.remote_workflows.yaml
108
108
  if Hash === remote_workflows and remote_workflows.include?(wf_name)
109
109
  url = remote_workflows[wf_name]
110
- require_remote_workflow(wf_name, url)
110
+ begin
111
+ return require_remote_workflow(wf_name, url)
112
+ ensure
113
+ Log.debug{"Workflow #{ wf_name } loaded remotely: #{ url }"}
114
+ end
115
+ end
116
+ end
117
+
118
+ if Open.remote? wf_name
119
+ url = wf_name
120
+ wf_name = File.basename(url)
121
+ begin
122
+ return require_remote_workflow(wf_name, url)
123
+ ensure
111
124
  Log.debug{"Workflow #{ wf_name } loaded remotely: #{ url }"}
112
- return
113
125
  end
114
126
  end
115
127
 
@@ -238,6 +238,29 @@ end
238
238
 
239
239
  module Workflow
240
240
 
241
+ def self.load_inputs(dir, input_names, input_types)
242
+ inputs = {}
243
+ dir = Path.setup(dir.dup)
244
+ input_names.each do |input|
245
+ file = dir[input].find
246
+ Log.debug "Trying #{ input }: #{file}"
247
+ next unless file.exists?
248
+
249
+ case input_types[input]
250
+ when :tsv, :array, :text
251
+ Log.debug "Pointing #{ input } to #{file}"
252
+ inputs[input.to_sym] = file
253
+ when :boolean
254
+ inputs[input.to_sym] = (file.read.strip == 'true')
255
+ else
256
+ Log.debug "Loading #{ input } from #{file}"
257
+ inputs[input.to_sym] = file.read.strip
258
+ end
259
+
260
+ end
261
+ IndiferentHash.setup(inputs)
262
+ end
263
+
241
264
  def log(status, message = nil, &block)
242
265
  Step.log(status, message, nil, &block)
243
266
  end
@@ -264,7 +287,7 @@ module Workflow
264
287
  :none
265
288
  end
266
289
 
267
-
290
+
268
291
  dependencies = task_dependencies[name].select{|dep| String === dep or Symbol === dep}
269
292
  { :id => File.join(self.to_s, name.to_s),
270
293
  :description => description,
@@ -38,14 +38,14 @@ begin
38
38
  end
39
39
 
40
40
  puts SOPT.doc
41
-
42
- puts "## COMMANDS"
43
41
  puts
44
- puts "Command:"
42
+ puts Log.color :magenta, "## COMMANDS"
43
+ puts
44
+ puts Log.color :magenta, "Command:"
45
45
  puts
46
- puts " #{File.basename($0)} #{prev * " "}"
46
+ puts " #{File.basename($0)} #{$previous_commands * " "} cmd"
47
47
  puts
48
- puts "Subcommands:"
48
+ puts Log.color :magenta, "Subcommands:"
49
49
  puts
50
50
  commands(prev).each do |command|
51
51
  puts " " << command
@@ -4,25 +4,6 @@ require 'rbbt/util/simpleopt'
4
4
  require 'rbbt/workflow'
5
5
  require 'rbbt/workflow/usage'
6
6
 
7
- def load_inputs(dir, task)
8
- inputs = {}
9
- dir = Path.setup(dir.dup)
10
- task.inputs.each do |input|
11
- file = dir[input].find
12
- Log.debug "Trying #{ input }: #{file}"
13
- next unless file.exists?
14
- case task.input_types[input]
15
- when :tsv, :array, :text
16
- Log.debug "Pointing #{ input } to #{file}"
17
- inputs[input.to_sym] = file
18
- else
19
- Log.debug "Loading #{ input } from #{file}"
20
- inputs[input.to_sym] = file.read.strip
21
- end
22
- end
23
- IndiferentHash.setup(inputs)
24
- end
25
-
26
7
  def report_options(options)
27
8
  if options.nil? or options.empty?
28
9
  puts "No options"
@@ -73,14 +54,14 @@ def SOPT_options(workflow, task)
73
54
  end
74
55
 
75
56
  def fix_options(workflow, task, job_options)
76
- option_types = workflow.rec_input_types(task.name)
57
+ option_types = IndiferentHash.setup workflow.rec_input_types(task.name)
77
58
 
78
59
  job_options_cleaned = {}
79
60
 
80
61
  job_options.each do |name, value|
81
62
  value = case option_types[name].to_sym
82
63
  when :boolean
83
- TrueClass === true or %w(true TRUE T yes).include? value
64
+ TrueClass === value or %w(true TRUE T yes).include? value
84
65
  when :float
85
66
  value.to_f
86
67
  when :integer
@@ -195,14 +176,7 @@ else
195
176
  remote_workflows = {}
196
177
  end
197
178
 
198
- if remote_workflows.include? workflow
199
- require 'rbbt/rest/client'
200
- workflow = WorkflowRESTClient.new remote_workflows[workflow], workflow
201
- else
202
- Workflow.require_workflow workflow
203
- workflow = Workflow.workflows.select{|mod| Misc.snake_case(mod.to_s) == Misc.snake_case(workflow)}.first
204
- workflow = Workflow.workflows.last if workflow.nil?
205
- end
179
+ workflow = Workflow.require_workflow workflow
206
180
 
207
181
  # Set task
208
182
  namespace = nil, nil
@@ -235,7 +209,8 @@ name = options.delete(:jobname) || "Default"
235
209
  # get job args
236
210
  sopt_option_string = SOPT_options(workflow, task)
237
211
  if options[:load_inputs]
238
- job_options = load_inputs(options[:load_inputs], task).merge(SOPT.get(sopt_option_string))
212
+ task_info = workflow.task_info(task_name)
213
+ job_options = Workflow.load_inputs(options[:load_inputs], task_info[:inputs], task_info[:input_types]).merge(SOPT.get(sopt_option_string))
239
214
  else
240
215
  job_options = SOPT.get sopt_option_string
241
216
  end
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.9.2
4
+ version: 5.9.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: 2014-03-19 00:00:00.000000000 Z
11
+ date: 2014-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake