scout-gear 7.2.0 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.vimproject +51 -6
  3. data/VERSION +1 -1
  4. data/bin/scout +6 -3
  5. data/lib/rbbt-scout.rb +1 -0
  6. data/lib/scout/cmd.rb +1 -1
  7. data/lib/scout/concurrent_stream.rb +33 -29
  8. data/lib/scout/config.rb +1 -1
  9. data/lib/scout/exceptions.rb +1 -0
  10. data/lib/scout/log/color.rb +4 -2
  11. data/lib/scout/log/progress/report.rb +1 -1
  12. data/lib/scout/log/progress/util.rb +71 -2
  13. data/lib/scout/log/progress.rb +1 -1
  14. data/lib/scout/log/trap.rb +107 -0
  15. data/lib/scout/log.rb +56 -21
  16. data/lib/scout/meta_extension.rb +13 -6
  17. data/lib/scout/misc/digest.rb +1 -1
  18. data/lib/scout/misc/format.rb +12 -0
  19. data/lib/scout/misc/helper.rb +31 -0
  20. data/lib/scout/misc/insist.rb +1 -1
  21. data/lib/scout/misc/monitor.rb +12 -1
  22. data/lib/scout/misc/system.rb +10 -0
  23. data/lib/scout/misc.rb +1 -0
  24. data/lib/scout/named_array.rb +65 -3
  25. data/lib/scout/open/lock/lockfile.rb +587 -0
  26. data/lib/scout/open/lock.rb +28 -2
  27. data/lib/scout/open/remote.rb +4 -0
  28. data/lib/scout/open/stream.rb +111 -42
  29. data/lib/scout/open/util.rb +13 -3
  30. data/lib/scout/path/find.rb +9 -1
  31. data/lib/scout/path/util.rb +35 -0
  32. data/lib/scout/persist/serialize.rb +18 -5
  33. data/lib/scout/persist.rb +60 -30
  34. data/lib/scout/resource/path.rb +53 -0
  35. data/lib/scout/resource/produce.rb +0 -8
  36. data/lib/scout/resource/util.rb +2 -1
  37. data/lib/scout/semaphore.rb +8 -1
  38. data/lib/scout/tmpfile.rb +7 -8
  39. data/lib/scout/tsv/attach.rb +177 -0
  40. data/lib/scout/tsv/change_id.rb +40 -0
  41. data/lib/scout/tsv/dumper.rb +85 -54
  42. data/lib/scout/tsv/index.rb +188 -20
  43. data/lib/scout/tsv/open.rb +182 -0
  44. data/lib/scout/tsv/parser.rb +200 -118
  45. data/lib/scout/tsv/path.rb +5 -6
  46. data/lib/scout/tsv/persist/adapter.rb +26 -37
  47. data/lib/scout/tsv/persist/fix_width_table.rb +327 -0
  48. data/lib/scout/tsv/persist/serialize.rb +117 -0
  49. data/lib/scout/tsv/persist/tokyocabinet.rb +6 -3
  50. data/lib/scout/tsv/persist.rb +4 -2
  51. data/lib/scout/tsv/transformer.rb +141 -0
  52. data/lib/scout/tsv/traverse.rb +136 -37
  53. data/lib/scout/tsv/util/filter.rb +312 -0
  54. data/lib/scout/tsv/util/process.rb +73 -0
  55. data/lib/scout/tsv/util/reorder.rb +81 -0
  56. data/lib/scout/tsv/util/select.rb +265 -0
  57. data/lib/scout/tsv/util/unzip.rb +86 -0
  58. data/lib/scout/tsv/util.rb +126 -19
  59. data/lib/scout/tsv.rb +28 -5
  60. data/lib/scout/work_queue/socket.rb +6 -1
  61. data/lib/scout/work_queue/worker.rb +5 -2
  62. data/lib/scout/work_queue.rb +15 -8
  63. data/lib/scout/workflow/definition.rb +29 -2
  64. data/lib/scout/workflow/step/dependencies.rb +24 -4
  65. data/lib/scout/workflow/step/info.rb +40 -5
  66. data/lib/scout/workflow/step/progress.rb +14 -0
  67. data/lib/scout/workflow/step/provenance.rb +8 -7
  68. data/lib/scout/workflow/step/status.rb +45 -0
  69. data/lib/scout/workflow/step.rb +104 -33
  70. data/lib/scout/workflow/task/inputs.rb +14 -20
  71. data/lib/scout/workflow/task.rb +86 -47
  72. data/lib/scout/workflow/usage.rb +10 -6
  73. data/scout-gear.gemspec +30 -3
  74. data/scout_commands/workflow/task +37 -9
  75. data/scout_commands/workflow/task_old +2 -2
  76. data/test/scout/open/test_stream.rb +61 -59
  77. data/test/scout/path/test_find.rb +10 -1
  78. data/test/scout/resource/test_produce.rb +15 -0
  79. data/test/scout/test_meta_extension.rb +25 -0
  80. data/test/scout/test_named_array.rb +18 -0
  81. data/test/scout/test_persist.rb +67 -0
  82. data/test/scout/test_tmpfile.rb +1 -1
  83. data/test/scout/test_tsv.rb +222 -3
  84. data/test/scout/test_work_queue.rb +21 -18
  85. data/test/scout/tsv/persist/test_adapter.rb +11 -1
  86. data/test/scout/tsv/persist/test_fix_width_table.rb +134 -0
  87. data/test/scout/tsv/persist/test_tokyocabinet.rb +29 -1
  88. data/test/scout/tsv/test_attach.rb +227 -0
  89. data/test/scout/tsv/test_change_id.rb +98 -0
  90. data/test/scout/tsv/test_dumper.rb +1 -1
  91. data/test/scout/tsv/test_index.rb +127 -3
  92. data/test/scout/tsv/test_open.rb +167 -0
  93. data/test/scout/tsv/test_parser.rb +45 -3
  94. data/test/scout/tsv/test_persist.rb +9 -0
  95. data/test/scout/tsv/test_transformer.rb +108 -0
  96. data/test/scout/tsv/test_traverse.rb +195 -3
  97. data/test/scout/tsv/test_util.rb +24 -0
  98. data/test/scout/tsv/util/test_filter.rb +188 -0
  99. data/test/scout/tsv/util/test_process.rb +47 -0
  100. data/test/scout/tsv/util/test_reorder.rb +94 -0
  101. data/test/scout/tsv/util/test_select.rb +58 -0
  102. data/test/scout/tsv/util/test_unzip.rb +112 -0
  103. data/test/scout/work_queue/test_socket.rb +0 -1
  104. data/test/scout/work_queue/test_worker.rb +63 -6
  105. data/test/scout/workflow/step/test_load.rb +3 -3
  106. data/test/scout/workflow/step/test_status.rb +31 -0
  107. data/test/scout/workflow/task/test_inputs.rb +14 -14
  108. data/test/scout/workflow/test_step.rb +13 -13
  109. data/test/scout/workflow/test_task.rb +168 -32
  110. data/test/scout/workflow/test_usage.rb +33 -6
  111. data/test/test_helper.rb +3 -1
  112. metadata +29 -2
@@ -1,4 +1,5 @@
1
1
  require_relative '../meta_extension'
2
+ require_relative '../named_array'
2
3
  require_relative 'step'
3
4
  require_relative 'task/inputs'
4
5
 
@@ -24,7 +25,7 @@ module Task
24
25
  return inputs if deps.nil?
25
26
  deps.inject(inputs) do |acc,dep|
26
27
  workflow, task = dep
27
- next if workflow.nil?
28
+ next acc if workflow.nil? || task.nil?
28
29
  acc += workflow.tasks[task].recursive_inputs
29
30
  end
30
31
  end
@@ -43,27 +44,45 @@ module Task
43
44
 
44
45
  provided_inputs ||= {}
45
46
 
46
- load_dep = proc do |id, workflow, task, inputs, hash_options, dependencies|
47
- task = hash_options[:task] if hash_options.include?(:task)
48
- workflow = hash_options[:workflow] if hash_options.include?(:workflow)
49
- id = hash_options[:id] if hash_options.include? :id
47
+ # Helper function
48
+ load_dep = proc do |id, workflow, task, step_options, definition_options, dependencies|
49
+ task = step_options.delete(:task) if step_options.include?(:task)
50
+ workflow = step_options.delete(:workflow) if step_options.include?(:workflow)
51
+ id = step_options.delete(:id) if step_options.include?(:id)
52
+ id = step_options.delete(:jobname) if step_options.include?(:jobname)
50
53
 
51
- hash_inputs = hash_options.include?(:inputs)? hash_options[:inputs] : hash_options
52
- inputs = IndiferentHash.add_defaults hash_inputs, inputs
54
+ step_inputs = step_options.include?(:inputs)? step_options.delete(:inputs) : step_options
55
+ step_inputs = IndiferentHash.add_defaults step_inputs, definition_options
53
56
 
54
57
  resolved_inputs = {}
55
- inputs.each do |k,v|
58
+ step_inputs.each do |k,v|
56
59
  if Symbol === v
57
60
  input_dep = dependencies.select{|d| d.task_name == v }.first
58
- resolved_inputs[k] = input_dep || inputs[v] || k
61
+ resolved_inputs[k] = input_dep || step_inputs[v] || k
59
62
  else
60
63
  resolved_inputs[k] = v
61
64
  end
62
65
  end
63
- workflow.job(task, id, resolved_inputs)
66
+ [workflow.job(task, id, resolved_inputs), step_inputs]
64
67
  end
65
68
 
66
- deps.each do |workflow,task,options,block=nil|
69
+ # Helper function
70
+ find_dep_non_default_inputs = proc do |dep,definition_options,step_inputs={}|
71
+ dep_non_default_inputs = dep.non_default_inputs
72
+ dep_non_default_inputs.select do |name|
73
+ step_inputs.include?(name)
74
+ end
75
+ dep_non_default_inputs.reject! do |name|
76
+ definition_options.include?(name) &&
77
+ (definition_options[name] != :placeholder || definition_options[name] != dep.inputs[name])
78
+ end
79
+
80
+ dep_non_default_inputs
81
+ end
82
+
83
+ deps.each do |workflow,task,definition_options,block=nil|
84
+ definition_options[:id] = definition_options.delete(:jobname) if definition_options.include?(:jobname)
85
+
67
86
  if provided_inputs.include?(overriden = [workflow.name, task] * "#")
68
87
  dep = provided_inputs[overriden]
69
88
  dep = Step.new dep unless Step === dep
@@ -73,58 +92,52 @@ module Task
73
92
  next
74
93
  end
75
94
 
76
- options ||= {}
95
+ definition_options ||= {}
96
+
77
97
  if block
78
- inputs = IndiferentHash.add_defaults options.dup, provided_inputs
98
+ fixed_provided_inputs = self.assign_inputs(provided_inputs).first.to_hash
99
+ self.inputs.each do |name,type,desc,value|
100
+ fixed_provided_inputs[name] = value unless fixed_provided_inputs.include?(name)
101
+ end
102
+ fixed_provided_inputs = IndiferentHash.add_defaults fixed_provided_inputs, provided_inputs
103
+ block_options = IndiferentHash.add_defaults definition_options.dup, fixed_provided_inputs
79
104
 
80
- res = block.call id, inputs, dependencies
105
+ res = block.call id, block_options, dependencies
81
106
 
82
107
  case res
83
108
  when Step
84
109
  dep = res
85
110
  dependencies << dep
86
- dep_non_default_inputs = dep.task.assign_inputs(dep.inputs).last
87
- non_default_inputs.concat(dep_non_default_inputs - options.keys)
111
+ dep_non_default_inputs = find_dep_non_default_inputs.call(dep, block_options)
112
+ non_default_inputs.concat(dep_non_default_inputs)
88
113
  when Hash
89
- new_options = res
90
- dep = load_dep.call(id, workflow, task, inputs, new_options, dependencies)
114
+ step_options = block_options.merge(res)
115
+ dep, step_inputs = load_dep.call(id, workflow, task, step_options, block_options, dependencies)
91
116
  dependencies << dep
92
- dep_non_default_inputs = dep.task.assign_inputs(dep.inputs).last
93
- dep_non_default_inputs -= options.keys
94
- if new_options.include?(:inputs)
95
- dep_non_default_inputs -= new_options[:inputs].keys
96
- else
97
- dep_non_default_inputs -= new_options.keys
98
- end
117
+ dep_non_default_inputs = find_dep_non_default_inputs.call(dep, definition_options, step_inputs)
99
118
  non_default_inputs.concat(dep_non_default_inputs)
100
119
  when Array
101
120
  res.each do |_res|
102
121
  if Hash === _res
103
- new_options = _res
104
- dep = load_dep.call(id, workflow, task, inputs, new_options, dependencies)
122
+ step_options = block_options.merge(_res)
123
+ dep, step_inputs = load_dep.call(id, workflow, task, step_options, block_options, dependencies)
105
124
  dependencies << dep
106
- dep_non_default_inputs = dep.task.assign_inputs(dep.inputs).last
107
- dep_non_default_inputs -= options.keys
108
- if new_options.include?(:inputs)
109
- dep_non_default_inputs -= new_options[:inputs].keys
110
- else
111
- dep_non_default_inputs -= new_options.keys
112
- end
125
+ dep_non_default_inputs = find_dep_non_default_inputs.call(dep, definition_options, step_inputs)
113
126
  non_default_inputs.concat(dep_non_default_inputs)
114
127
  else
115
128
  dep = _res
116
129
  dependencies << dep
117
- dep_non_default_inputs = dep.task.assign_inputs(dep.inputs).last
118
- non_default_inputs.concat(dep_non_default_inputs - options.keys)
130
+ dep_non_default_inputs = find_dep_non_default_inputs.call(dep, block_options)
131
+ non_default_inputs.concat(dep_non_default_inputs)
119
132
  end
120
133
  end
121
134
  end
122
135
  else
123
- inputs = IndiferentHash.add_defaults options.dup, provided_inputs
124
- dep = load_dep.call(id, workflow, task, inputs, {}, dependencies)
136
+ step_options = IndiferentHash.add_defaults definition_options.dup, provided_inputs
137
+ dep, step_inputs = load_dep.call(id, workflow, task, step_options, definition_options, dependencies)
125
138
  dependencies << dep
126
- dep_non_default_inputs = dep.task.assign_inputs(dep.inputs).last
127
- non_default_inputs.concat(dep_non_default_inputs - options.keys)
139
+ dep_non_default_inputs = find_dep_non_default_inputs.call(dep, definition_options, step_inputs)
140
+ non_default_inputs.concat(dep_non_default_inputs)
128
141
  end
129
142
  end
130
143
 
@@ -136,21 +149,47 @@ module Task
136
149
  provided_inputs = {} if provided_inputs.nil?
137
150
  id = DEFAULT_NAME if id.nil?
138
151
 
139
- inputs, non_default_inputs, input_hash = process_inputs provided_inputs
152
+ inputs, non_default_inputs, input_digest_str = process_inputs provided_inputs
140
153
 
141
154
  dependencies = dependencies(id, provided_inputs, non_default_inputs)
142
155
 
143
156
  non_default_inputs.concat provided_inputs.keys.select{|k| String === k && k.include?("#") } if Hash === provided_inputs
144
157
 
145
158
  if non_default_inputs.any?
146
- hash = Misc.digest(:inputs => input_hash, :dependencies => dependencies)
147
- Log.debug "Hash #{name} - #{hash}: #{Misc.digest_str(:inputs => inputs, :non_default_inputs => non_default_inputs, :dependencies => dependencies)}"
148
- id = [id, hash] * "_"
159
+ hash = Misc.digest(:inputs => input_digest_str, :dependencies => dependencies)
160
+ name = [id, hash] * "_"
161
+ else
162
+ name = id
163
+ end
164
+
165
+ extension = self.extension
166
+ if extension == :dep_task
167
+ extension = nil
168
+ if dependencies.any?
169
+ dep_basename = File.basename(dependencies.last.path)
170
+ if dep_basename.include? "."
171
+ parts = dep_basename.split(".")
172
+ extension = [parts.pop]
173
+ while parts.last.length <= 4
174
+ extension << parts.pop
175
+ end
176
+ extension = extension.reverse * "."
177
+ end
178
+ end
149
179
  end
150
180
 
151
- path = directory[id]
181
+ path = directory[name]
182
+
183
+ path = path.set_extension(extension) if extension
152
184
 
153
- NamedArray.setup(inputs, @inputs.collect{|i| i[0] }) if @inputs
154
- Step.new path.find, inputs, dependencies, &self
185
+ Persist.memory(path) do
186
+ if hash
187
+ Log.debug "ID #{self.name} #{id} - #{hash}: #{Log.fingerprint(:input_digest => input_digest_str, :non_default_inputs => non_default_inputs, :dependencies => dependencies)}"
188
+ else
189
+ Log.debug "ID #{self.name} #{id} - Clean"
190
+ end
191
+ NamedArray.setup(inputs, @inputs.collect{|i| i[0] }) if @inputs
192
+ Step.new path.find, inputs, dependencies, id, non_default_inputs, &self
193
+ end
155
194
  end
156
195
  end
@@ -16,13 +16,16 @@ module Task
16
16
  str.puts
17
17
  end
18
18
 
19
+ deps = workflow ? workflow.recursive_deps(self.name) : self.deps if deps.nil?
19
20
  if deps and deps.any?
20
21
  seen = inputs.collect{|name,_| name }
21
22
  dep_inputs = {}
22
- deps.each do |dep_workflow,task_name|
23
+ deps.each do |dep_workflow,task_name,options|
24
+ next if task_name.nil?
23
25
  task = dep_workflow.tasks[task_name]
24
26
  next if task.inputs.nil?
25
27
  inputs = task.inputs.reject{|name, _| seen.include? name }
28
+ inputs = task.inputs.reject{|name, _| options.include? name }
26
29
  next unless inputs.any?
27
30
  dep = workflow.nil? || dep_workflow.name != workflow.name ? ["#{dep_workflow.name}", task_name.to_s] *"#" : task_name.to_s
28
31
  dep_inputs[dep] = inputs
@@ -108,24 +111,25 @@ end
108
111
 
109
112
  module Workflow
110
113
 
111
- def dep_tree(task_name, seen = nil)
114
+ def dep_tree(task_name, seen = nil, seen_options = nil)
112
115
  @dep_tree ||= {}
113
116
  key = [self, task_name]
114
117
 
115
118
  return @dep_tree[key] if @dep_tree.include?(key)
116
119
  save = seen.nil?
117
120
  seen = Set.new if seen.nil?
121
+ seen_options = {} if seen_options.nil?
118
122
 
119
123
  dep_tree = {}
120
124
  task = self.tasks[task_name]
121
- task.deps.each do |dep|
125
+ task.deps.each do |workflow, task, options|
122
126
  next if seen.include? dep
123
- seen << dep
124
- workflow, task, *rest = dep
127
+ seen << [workflow, task, options.merge(seen_options)]
128
+ next if task.nil?
125
129
 
126
130
  key = [workflow, task]
127
131
 
128
- dep_tree[key] = workflow.dep_tree(task, seen)
132
+ dep_tree[key] = workflow.dep_tree(task, seen, options.merge(seen_options))
129
133
  end if task.deps
130
134
 
131
135
  @dep_tree[key] = dep_tree if save
data/scout-gear.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: scout-gear 7.2.0 ruby lib
5
+ # stub: scout-gear 8.0.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "scout-gear".freeze
9
- s.version = "7.2.0"
9
+ s.version = "8.0.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Miguel Vazquez".freeze]
14
- s.date = "2023-05-09"
14
+ s.date = "2023-05-23"
15
15
  s.description = "Temporary files, logs, etc.".freeze
16
16
  s.email = "mikisvaz@gmail.com".freeze
17
17
  s.executables = ["scout".freeze]
@@ -45,17 +45,20 @@ Gem::Specification.new do |s|
45
45
  "lib/scout/log/progress.rb",
46
46
  "lib/scout/log/progress/report.rb",
47
47
  "lib/scout/log/progress/util.rb",
48
+ "lib/scout/log/trap.rb",
48
49
  "lib/scout/meta_extension.rb",
49
50
  "lib/scout/misc.rb",
50
51
  "lib/scout/misc/digest.rb",
51
52
  "lib/scout/misc/filesystem.rb",
52
53
  "lib/scout/misc/format.rb",
54
+ "lib/scout/misc/helper.rb",
53
55
  "lib/scout/misc/insist.rb",
54
56
  "lib/scout/misc/monitor.rb",
55
57
  "lib/scout/misc/system.rb",
56
58
  "lib/scout/named_array.rb",
57
59
  "lib/scout/open.rb",
58
60
  "lib/scout/open/lock.rb",
61
+ "lib/scout/open/lock/lockfile.rb",
59
62
  "lib/scout/open/remote.rb",
60
63
  "lib/scout/open/stream.rb",
61
64
  "lib/scout/open/util.rb",
@@ -83,15 +86,26 @@ Gem::Specification.new do |s|
83
86
  "lib/scout/simple_opt/setup.rb",
84
87
  "lib/scout/tmpfile.rb",
85
88
  "lib/scout/tsv.rb",
89
+ "lib/scout/tsv/attach.rb",
90
+ "lib/scout/tsv/change_id.rb",
86
91
  "lib/scout/tsv/dumper.rb",
87
92
  "lib/scout/tsv/index.rb",
93
+ "lib/scout/tsv/open.rb",
88
94
  "lib/scout/tsv/parser.rb",
89
95
  "lib/scout/tsv/path.rb",
90
96
  "lib/scout/tsv/persist.rb",
91
97
  "lib/scout/tsv/persist/adapter.rb",
98
+ "lib/scout/tsv/persist/fix_width_table.rb",
99
+ "lib/scout/tsv/persist/serialize.rb",
92
100
  "lib/scout/tsv/persist/tokyocabinet.rb",
101
+ "lib/scout/tsv/transformer.rb",
93
102
  "lib/scout/tsv/traverse.rb",
94
103
  "lib/scout/tsv/util.rb",
104
+ "lib/scout/tsv/util/filter.rb",
105
+ "lib/scout/tsv/util/process.rb",
106
+ "lib/scout/tsv/util/reorder.rb",
107
+ "lib/scout/tsv/util/select.rb",
108
+ "lib/scout/tsv/util/unzip.rb",
95
109
  "lib/scout/work_queue.rb",
96
110
  "lib/scout/work_queue/socket.rb",
97
111
  "lib/scout/work_queue/worker.rb",
@@ -104,7 +118,9 @@ Gem::Specification.new do |s|
104
118
  "lib/scout/workflow/step/file.rb",
105
119
  "lib/scout/workflow/step/info.rb",
106
120
  "lib/scout/workflow/step/load.rb",
121
+ "lib/scout/workflow/step/progress.rb",
107
122
  "lib/scout/workflow/step/provenance.rb",
123
+ "lib/scout/workflow/step/status.rb",
108
124
  "lib/scout/workflow/task.rb",
109
125
  "lib/scout/workflow/task/inputs.rb",
110
126
  "lib/scout/workflow/usage.rb",
@@ -165,19 +181,30 @@ Gem::Specification.new do |s|
165
181
  "test/scout/test_work_queue.rb",
166
182
  "test/scout/test_workflow.rb",
167
183
  "test/scout/tsv/persist/test_adapter.rb",
184
+ "test/scout/tsv/persist/test_fix_width_table.rb",
168
185
  "test/scout/tsv/persist/test_tokyocabinet.rb",
186
+ "test/scout/tsv/test_attach.rb",
187
+ "test/scout/tsv/test_change_id.rb",
169
188
  "test/scout/tsv/test_dumper.rb",
170
189
  "test/scout/tsv/test_index.rb",
190
+ "test/scout/tsv/test_open.rb",
171
191
  "test/scout/tsv/test_parser.rb",
172
192
  "test/scout/tsv/test_persist.rb",
193
+ "test/scout/tsv/test_transformer.rb",
173
194
  "test/scout/tsv/test_traverse.rb",
174
195
  "test/scout/tsv/test_util.rb",
196
+ "test/scout/tsv/util/test_filter.rb",
197
+ "test/scout/tsv/util/test_process.rb",
198
+ "test/scout/tsv/util/test_reorder.rb",
199
+ "test/scout/tsv/util/test_select.rb",
200
+ "test/scout/tsv/util/test_unzip.rb",
175
201
  "test/scout/work_queue/test_socket.rb",
176
202
  "test/scout/work_queue/test_worker.rb",
177
203
  "test/scout/workflow/step/test_dependencies.rb",
178
204
  "test/scout/workflow/step/test_info.rb",
179
205
  "test/scout/workflow/step/test_load.rb",
180
206
  "test/scout/workflow/step/test_provenance.rb",
207
+ "test/scout/workflow/step/test_status.rb",
181
208
  "test/scout/workflow/task/test_inputs.rb",
182
209
  "test/scout/workflow/test_definition.rb",
183
210
  "test/scout/workflow/test_documentation.rb",
@@ -4,6 +4,9 @@ require 'scout'
4
4
 
5
5
  $0 = "scout #{$previous_commands.any? ? $previous_commands*" " + " " : "" }#{ File.basename(__FILE__) }" if $previous_commands
6
6
 
7
+ ENV["SCOUT_NO_STREAM"] = "true" if ARGV.include? "--nostream"
8
+ ENV["SCOUT_UPDATE"] = "true" if ARGV.include? "--update"
9
+
7
10
  options = SOPT.setup <<EOF
8
11
 
9
12
  Run a workflow job
@@ -11,11 +14,14 @@ Run a workflow job
11
14
  $ #{$0} [<options>] <workflow> <task>
12
15
 
13
16
  -h--help Print this help
17
+ --nostream Disable job streaming
18
+ --update Update jobs with newer dependencies
14
19
  -jn--job_name* Name to use as job identifier
15
20
  -pf--print_filepath Print the file path
16
21
  -prov--provenance Print the step provenance
17
22
  -cl--clean Clean the last step
18
23
  -rcl--recursive_clean Clean all steps
24
+ -ct--clean_task* Clean a particular task
19
25
  EOF
20
26
 
21
27
  workflow_name, task_name = ARGV
@@ -24,11 +30,14 @@ raise MissingParameterException.new :workflow if workflow_name.nil?
24
30
 
25
31
  workflow = Workflow.require_workflow workflow_name
26
32
  task_name = task_name.to_sym if task_name
27
- task = workflow.tasks[task_name.to_sym]
33
+ task = workflow.tasks[task_name.to_sym] if task_name
28
34
 
29
35
  options[:help] = true if task.nil?
30
36
 
31
- if options[:help]
37
+ help, provenance, clean, recursive_clean, clean_task, jobname, print_filepath = IndiferentHash.process_options options,
38
+ :help, :provenance, :clean, :recursive_clean, :clean_task, :job_name, :print_filepath
39
+
40
+ if help
32
41
  if defined? scout_usage
33
42
  scout_usage
34
43
  else
@@ -40,22 +49,41 @@ if options[:help]
40
49
  end
41
50
 
42
51
  job_options = task.get_SOPT(task)
43
- job = workflow.job(task_name, options[:job_name], job_options)
52
+ job = workflow.job(task_name, jobname, job_options)
53
+
54
+ job.recursive_clean if recursive_clean
55
+ job.clean if clean
56
+
57
+ if clean_task
58
+ ENV["SCOUT_UPDATE"] = 'true'
59
+ clean_task.split(",").each do |clean_task|
60
+ if clean_task.include? "#"
61
+ clean_workflow, clean_task = clean_task.split("#")
62
+ end
44
63
 
45
- job.recursive_clean if options[:recursive_clean]
46
- job.clean if options[:clean]
64
+ job.rec_dependencies.each do |dep|
65
+ next unless dep.task_name.to_s == clean_task.to_s
66
+ next unless clean_workflow.nil? || clean_workflow == dep.workflow.to_s
67
+ dep.clean
68
+ dep.set_info :status, :cleaned
69
+ end
70
+
71
+ job.clean if job.task_name.to_s == clean_task.to_s
72
+ end
73
+ end
47
74
 
48
- if options[:provenance]
75
+ if provenance
49
76
  puts Step.prov_report(job)
50
77
  else
51
- job.run unless job.done?
78
+ job.run(true) unless job.done?
52
79
 
53
- if options[:print_filepath]
80
+ if print_filepath
81
+ job.join
54
82
  path = job.path
55
83
  path = path.find if Path === path
56
84
  puts path
57
85
  else
58
- if ! ((c = Open.consume_stream(job.get_stream, false, STDOUT, false)) && c.end_with?("\n"))
86
+ if ! ((c = Open.consume_stream(job.stream, false, STDOUT, false)) && c.end_with?("\n"))
59
87
  puts
60
88
  end
61
89
  end
@@ -656,12 +656,12 @@ when (defined?(RemoteStep) and RemoteStep)
656
656
  end
657
657
  when Step
658
658
  if res.streaming?
659
- io = TSV.get_stream res
659
+ io = TSV.stream res
660
660
  Misc.consume_stream(io, false, out)
661
661
  io.join if io.respond_to? :join
662
662
  elsif IO === res.result
663
663
  begin
664
- io = res.get_stream
664
+ io = res.stream
665
665
  Misc.consume_stream(io, false, out)
666
666
  io.join if io.respond_to? :join
667
667
  rescue Aborted, Interrupt
@@ -5,7 +5,7 @@ require 'scout/path'
5
5
  require 'scout/open'
6
6
 
7
7
  class TestOpenStream < Test::Unit::TestCase
8
- def test_consume_stream
8
+ def test_stream
9
9
  content =<<-EOF
10
10
  1
11
11
  2
@@ -334,63 +334,65 @@ row1 A B C
334
334
  assert_equal %w(## ## ## #Row row1 row2 row3), sorted.read.split("\n").collect{|l| l.split(" ").first}
335
335
  end
336
336
 
337
- # def test_collapse_stream
338
- # text=<<-EOF
339
- #row1 A B C
340
- #row1 a b c
341
- #row2 AA BB CC
342
- #row2 aa bb cc
343
- # EOF
344
- #
345
- # s = StringIO.new text
346
- # tsv = TSV.open Misc.collapse_stream(s,nil, " "), :sep => " "
347
- # assert_equal ["A", "a"], tsv["row1"][0]
348
- # assert_equal ["BB", "bb"], tsv["row2"][1]
349
- # end
350
- #
351
- # def test_collapse_sum
352
- # text=<<-EOF
353
- #row1 12
354
- #row1 4
355
- #row2 10
356
- #row2 6
357
- # EOF
358
- #
359
- # s = StringIO.new text
360
- # stream = Misc.collapse_stream(s,nil, " ") do |parts|
361
- # next nil if parts.empty?
362
- # parts.first.split("|").collect{|p| p.to_f}.inject(0){|acc,e| acc += e}.to_s
363
- # end
364
- # tsv = TSV.open stream, :sep => " "
365
- # ppp tsv.to_s
366
- # end
367
- #
368
- # def test_collapse_stream_gap
369
- # text=<<-EOF
370
- #row2 AA BB
371
- #row2 aa bb cc
372
- # EOF
373
- #
374
- # s = StringIO.new text
375
- # assert Misc.collapse_stream(s, nil, " ").read =~ /\|cc$/
376
- #
377
- # text=<<-EOF
378
- #row2 aa bb cc
379
- #row2 AA BB
380
- # EOF
381
- #
382
- # s = StringIO.new text
383
- # assert Misc.collapse_stream(s, nil, " ").read =~ /cc\|$/
384
- #
385
- # text=<<-EOF
386
- #row2 AA BB
387
- #row2 aa bb cc
388
- # EOF
389
- #
390
- # s = StringIO.new text
391
- # assert Misc.collapse_stream(s, nil, " ").read =~ /\|cc$/
392
- #
393
- # end
337
+ def test_collapse_stream
338
+ text=<<-EOF
339
+ row1 A B C
340
+ row1 a b c
341
+ row2 AA BB CC
342
+ row2 aa bb cc
343
+ EOF
344
+
345
+ s = StringIO.new text
346
+ stream = Open.collapse_stream(s, sep: " ")
347
+ txt = stream.read
348
+ assert_include txt, "A|a"
349
+ assert_include txt, "B|b"
350
+ assert_include txt, "C|c"
351
+ end
352
+
353
+
354
+ def test_collapse_sum
355
+ text=<<-EOF
356
+ row1 12
357
+ row1 4
358
+ row2 10
359
+ row2 6
360
+ EOF
361
+
362
+ s = StringIO.new text
363
+ stream = Open.collapse_stream(s, sep: " ") do |parts|
364
+ next nil if parts.empty?
365
+ parts.first.split("|").collect{|p| p.to_f}.inject(0){|acc,e| acc += e}.to_s
366
+ end
367
+ assert_include stream.read, "row1 16"
368
+ end
369
+
370
+
371
+ def test_collapse_stream_gap
372
+ text=<<-EOF
373
+ row2 AA BB
374
+ row2 aa bb cc
375
+ EOF
376
+
377
+ s = StringIO.new text
378
+ assert Open.collapse_stream(s, sep: " ").read =~ /\|cc$/
379
+
380
+ text=<<-EOF
381
+ row2 aa bb cc
382
+ row2 AA BB
383
+ EOF
384
+
385
+ s = StringIO.new text
386
+ assert Open.collapse_stream(s, sep: " ").read =~ /cc\|$/
387
+
388
+ text=<<-EOF
389
+ row2 AA BB
390
+ row2 aa bb cc
391
+ EOF
392
+
393
+ s = StringIO.new text
394
+ assert Open.collapse_stream(s, sep: " ").read =~ /\|cc$/
395
+ end
394
396
  #
395
397
  #
396
398
  # def test_paste_stream
@@ -433,7 +435,7 @@ row1 A B C
433
435
  # s = StringIO.new text
434
436
  # sorted = Misc.sort_stream(s)
435
437
  # assert_equal %w(## ## ## #Row row2 row3 row1), text.split("\n").collect{|l| l.split(" ").first}
436
- # assert_equal %w(## ## ## #Row row1 row2 row3), sorted.read.split("\n").collect{|l| l.split(" ").first}
438
+ # assert_equal %w(## ## ## #Row row1 row2 row3), sorted.read.split("\n").collect{|l| l.split(" ").first}
437
439
  # end
438
440
  #
439
441
  # def test_sort_long_stream
@@ -68,7 +68,6 @@ class TestPathFind < Test::Unit::TestCase
68
68
  p = Path.setup("/tmp/foo/bar")
69
69
  assert p.located?
70
70
  assert_equal_path p, p.find
71
-
72
71
  end
73
72
 
74
73
  def test_custom
@@ -106,5 +105,15 @@ class TestPathFind < Test::Unit::TestCase
106
105
  assert Open.exist?(tmpdir.somefile)
107
106
  end
108
107
  end
108
+
109
+ def test_with_extension
110
+ dir = tmpdir.directory[__method__]
111
+ list = %w(a b)
112
+ Misc.in_dir(dir) do
113
+ file = dir.foo
114
+ Open.write(file.set_extension('list'), list * "\n")
115
+ assert_equal list, file.list
116
+ end
117
+ end
109
118
  end
110
119
 
@@ -59,4 +59,19 @@ end
59
59
  assert_include File.open(TestResource.tmp.test.work.footest.bar.find).read, "OTHER"
60
60
  assert_include File.open(TestResource.tmp.test.work.footest.foo_bar.find).read, "OTHER"
61
61
  end
62
+
63
+ def test_produce_with_extension
64
+ dir = tmpdir.directory[__method__]
65
+ dir.pkgdir = Scout
66
+ list = %w(a b)
67
+
68
+ Scout.claim dir["foo.list"], :proc do
69
+ list
70
+ end
71
+
72
+ Misc.in_dir(dir) do
73
+ file = dir.foo
74
+ assert_equal list, file.list
75
+ end
76
+ end
62
77
  end