rbbt-util 5.21.109 → 5.21.110

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75212596904098b73851ec84788f599725a8cdf4
4
- data.tar.gz: c353b207e28eaca9646f9102118c2bdeca997040
3
+ metadata.gz: 76533fd3b7702e342b7d237102246b920f687fb2
4
+ data.tar.gz: 2c2ab122805de8b07a901e001294b56f65c49eed
5
5
  SHA512:
6
- metadata.gz: 6edbc878612e5727dbbd263e069f1e88330559b899ff90619c780fec660ce7ac1724f8f79722eb617158b479b3202ca28a116a8dd5cadbd517c016faed975356
7
- data.tar.gz: 451774f390d7dbffa6a0f1ecd62b8cfac200129c31399f4ac9997297a58f2ee3c93192c16b15eee027349def00216f3c5c4cc5feef600f54b1f8b6c21b3501b1
6
+ metadata.gz: d2b46293054ceca952bff6da1f9c5200f278645911b55dd8b235b634ff0170f193fac20f5797d52d946f910eec894b44bae3a79b457c3c02cc8e0d011cd85f82
7
+ data.tar.gz: f3f15bb7057ea0521bdcbec6290cdde7e3dcd891abe2832008a6d17f944580a6a2fc284a9c442d421501be023c347f0003b01e1838911f363302c6059057c60e
@@ -81,8 +81,8 @@ class WorkflowRESTClient
81
81
  params = fix_params params
82
82
  res = capture_exception do
83
83
  Misc.insist(2, 0.5) do
84
- Log.debug{ "RestClient get_raw: #{ url } - #{Misc.fingerprint params}" }
85
84
  raise "No url" if url.nil?
85
+ Log.debug{ "RestClient get_raw: #{ url } - #{Misc.fingerprint params}" }
86
86
  res = RestClient.get(self.encode(url), :params => params)
87
87
  raise TryAgain if res.code == 202
88
88
  res.to_s
@@ -130,12 +130,7 @@ class WorkflowRESTClient
130
130
  @done = @info && @info[:status] && @info[:status].to_sym == :done
131
131
  @info = Persist.memory("RemoteSteps Info", :url => @url, :persist => true, :update => !@done) do
132
132
  init_job unless @url
133
- info = begin
134
- WorkflowRESTClient.get_json(File.join(@url, 'info'))
135
- rescue
136
- clean
137
- raise $!
138
- end
133
+ info = WorkflowRESTClient.get_json(File.join(@url, 'info'))
139
134
  info = WorkflowRESTClient.fix_hash(info)
140
135
  info[:status] = info[:status].to_sym if String === info[:status]
141
136
  info
@@ -150,13 +145,15 @@ class WorkflowRESTClient
150
145
  status = info[:status]
151
146
  @done = true if status and status.to_sym == :done
152
147
  status
148
+ rescue
149
+ nil
153
150
  ensure
154
151
  @info = nil
155
152
  end
156
153
  end
157
154
 
158
155
  def started?
159
- @result != nil or @started or @streaming or @url
156
+ @result != nil || @started || @streaming
160
157
  end
161
158
 
162
159
  def done?
@@ -216,7 +213,7 @@ class WorkflowRESTClient
216
213
  end
217
214
 
218
215
  def running?
219
- ! %w(done error aborted).include? status.to_s
216
+ ! %w(done error aborted noinfo).include? status.to_s
220
217
  end
221
218
 
222
219
  def path
@@ -361,8 +358,7 @@ class WorkflowRESTClient
361
358
  self
362
359
  end
363
360
 
364
- def clean
365
- init_job
361
+ def _clean
366
362
  begin
367
363
  params = {:_update => :clean}
368
364
  WorkflowRESTClient.clean_url(url, params) if @url
@@ -370,8 +366,17 @@ class WorkflowRESTClient
370
366
  rescue Exception
371
367
  Log.exception $!
372
368
  end
369
+ end
370
+
371
+ def clean
372
+ init_job
373
+ _clean
373
374
  self
374
375
  end
376
+
377
+ def input_checks
378
+ []
379
+ end
375
380
  end
376
381
  end
377
382
 
data/lib/rbbt/util/log.rb CHANGED
@@ -13,8 +13,8 @@ module Log
13
13
 
14
14
 
15
15
  #ToDo: I'm not sure if using a Mutex here really gives troubles in CPU concurrency
16
- #LOG_MUTEX = MockMutex.new
17
- LOG_MUTEX = Mutex.new
16
+ LOG_MUTEX = MockMutex.new
17
+ #LOG_MUTEX = Mutex.new
18
18
 
19
19
  SEVERITY_NAMES ||= begin
20
20
  names = %w(DEBUG LOW MEDIUM HIGH INFO WARN ERROR NONE )
@@ -122,7 +122,7 @@ module Log
122
122
  end
123
123
 
124
124
  def self.color(severity, str = nil, reset = false)
125
- return str || "" if nocolor
125
+ return str.dup || "" if nocolor
126
126
  color = reset ? Term::ANSIColor.reset : ""
127
127
  color << SEVERITY_COLOR[severity] if Integer === severity
128
128
  color << Term::ANSIColor.send(severity) if Symbol === severity and Term::ANSIColor.respond_to? severity
@@ -185,12 +185,7 @@ module Misc
185
185
  rescue IOError
186
186
  end
187
187
 
188
- in_pipes.each do |sin|
189
- sin.close unless sin.closed?
190
- end
191
-
192
- stream.join if stream.respond_to? :join
193
-
188
+ in_pipes.first.close
194
189
  rescue Aborted, Interrupt
195
190
  stream.abort if stream.respond_to? :abort
196
191
  out_pipes.each do |sout|
@@ -212,11 +207,12 @@ module Misc
212
207
  ConcurrentStream.setup sout, :threads => splitter_thread, :filename => filename, :_pair => stream
213
208
  end
214
209
 
215
- #abort_callback = Proc.new do
216
- # out_pipes.each do |s|
217
- # s.abort if s.respond_to? :abort
218
- # end
219
- #end
210
+ out_pipes.first.callback = Proc.new do
211
+ stream.join
212
+ in_pipes[1..-1].each do |sin|
213
+ sin.close unless sin.closed?
214
+ end
215
+ end
220
216
 
221
217
  out_pipes
222
218
  end
@@ -387,12 +383,12 @@ module Misc
387
383
  raise $! unless File.exist? path
388
384
  end
389
385
 
386
+ FileUtils.touch path if File.exist? path
390
387
  content.join if content.respond_to? :join and not (content.respond_to?(:joined?) and content.joined?)
391
388
 
392
389
  if Lockfile === lock_options[:lock] and lock_options[:lock].locked?
393
390
  lock_options[:lock].unlock
394
391
  end
395
- FileUtils.touch path if File.exist? path
396
392
  Open.notify_write(path)
397
393
  rescue Aborted
398
394
  Log.medium "Aborted sensiblewrite -- #{ Log.reset << Log.color(:blue, path) }"
@@ -358,7 +358,7 @@ class Step
358
358
  end
359
359
 
360
360
  def started?
361
- Open.exists?(path) or Open.exists?(pid_file) #or Open.exists?(info_file)
361
+ Open.exists?(path) or (Open.exists?(pid_file) && Open.exists?(info_file))
362
362
  end
363
363
 
364
364
  def waiting?
@@ -366,9 +366,12 @@ class Step
366
366
  end
367
367
 
368
368
  def dirty?
369
+ return true if Open.exists?(pid_file) && ! ( Open.exists?(info_file) || done? )
370
+ return false unless done? || status == :done
371
+
369
372
  status = self.status
370
373
 
371
- if done? and not status == :done and not status == :noinfo
374
+ if done? and not (status == :done or status == :ending) and not status == :noinfo
372
375
  return true
373
376
  end
374
377
  if status == :done and not done?
@@ -376,7 +379,9 @@ class Step
376
379
  end
377
380
 
378
381
  dirty_files = rec_dependencies.reject{|dep|
379
- (dep.path && Open.exists?(dep.path)) || (dep.error? && ! dep.recoverable_error?)
382
+ (defined?(WorkflowRESTClient) && WorkflowRESTClient::RemoteStep === dep) ||
383
+ (dep.path && (Open.exists?(dep.path) || Open.remote?(dep.path))) ||
384
+ (dep.error? && ! dep.recoverable_error?)
380
385
  }
381
386
 
382
387
  if dirty_files.any?
@@ -82,8 +82,8 @@ class Step
82
82
 
83
83
  if (status == 'error' && (job.recoverable_error? || job.dirty?)) ||
84
84
  job.aborted? ||
85
- (job.done? && job.dirty?) ||
86
- (status == 'waiting' && ! job.running?)
85
+ (job.done? && job.dirty?) ||
86
+ (! (job.status == :waiting || job.status == :noinfo || job.done? || job.error? || job.aborted?) && ! job.running?)
87
87
 
88
88
  job.clean
89
89
  end
@@ -124,8 +124,7 @@ class Step
124
124
  return
125
125
  end
126
126
 
127
- if dependency.aborted? or (dependency.error? and dependency.recoverable_error?) or dependency.missing?
128
- log_dependency_exec(dependency, "aborted (clean)")
127
+ if dependency.aborted? or (dependency.error? and dependency.recoverable_error?) or (!Open.remote?(dependency.path) && dependency.missing?)
129
128
  dependency.clean
130
129
  raise TryAgain
131
130
  end
@@ -221,8 +220,8 @@ class Step
221
220
  end
222
221
  end
223
222
  end
224
- nil
225
223
  end
224
+ nil
226
225
  when :bootstrap
227
226
  cpus = rest.nil? ? nil : rest.first
228
227
  cpus = 5 if cpus.nil?
@@ -370,11 +369,20 @@ class Step
370
369
  def stop_dependencies
371
370
  return if dependencies.nil?
372
371
  dependencies.each do |dep|
372
+ if dep.nil?
373
+ Log.warn "Dependency is nil #{Misc.fingerprint step} -- #{Misc.fingerprint dependencies}"
374
+ next
375
+ end
376
+
373
377
  begin
374
378
  next if dep.done? or dep.aborted?
375
379
  rescue
376
380
  end
377
- dep.abort
381
+
382
+ begin
383
+ dep.abort if dep.running?
384
+ rescue
385
+ end
378
386
  end
379
387
  kill_children
380
388
  end
@@ -88,13 +88,12 @@ class Step
88
88
  def dependency_checks
89
89
  rec_dependencies.
90
90
  select{|dependency| ! (defined? WorkflowRESTClient and WorkflowRESTClient::RemoteStep === dependency) }.
91
- select{|dependency| ! dependency.error? }.
92
- collect{|dependency| dependency.path }.uniq
91
+ select{|dependency| ! Open.remote?(dependency.path) }.
92
+ select{|dependency| ! dependency.error? }
93
93
  end
94
94
 
95
95
  def input_checks
96
- inputs.select{|i| Step === i && i.done?}.
97
- collect{|dependency| dependency.path }.uniq
96
+ inputs.select{|i| Step === i && i.done? }
98
97
  end
99
98
 
100
99
  def checks
@@ -102,7 +101,20 @@ class Step
102
101
  end
103
102
 
104
103
  def updated?
105
- done? and checks.select{|path| File.mtime(path) > File.mtime(self.path) }.empty?
104
+ return true unless done?
105
+ outdated_time = []
106
+ outdated_dep = []
107
+ checks.each do |dep|
108
+ if File.mtime(dep.path) > File.mtime(self.path)
109
+ outdated_time << dep
110
+ end
111
+ if ! dep.updated?
112
+ outdated_dep << dep
113
+ end
114
+ end
115
+
116
+ outdated = outdated_time + outdated_dep
117
+ outdated.empty?
106
118
  end
107
119
 
108
120
  def kill_children
@@ -133,7 +145,7 @@ class Step
133
145
  no_load = :stream if no_load
134
146
 
135
147
  Open.write(pid_file, Process.pid.to_s) unless Open.exists?(path) or Open.exists?(pid_file)
136
- result = Persist.persist "Job", @task.result_type, :file => path, :check => checks, :no_load => no_load do
148
+ result = Persist.persist "Job", @task.result_type, :file => path, :check => checks.collect{|dep| dep.path}, :no_load => no_load do
137
149
  if Step === Step.log_relay_step and not self == Step.log_relay_step
138
150
  relay_log(Step.log_relay_step) unless self.respond_to? :relay_step and self.relay_step
139
151
  end
@@ -152,10 +164,10 @@ class Step
152
164
  :workflow => (@workflow || @task.workflow).to_s,
153
165
  :task_name => @task.name,
154
166
  :result_type => @task.result_type,
155
- :result_description => @task.result_description
167
+ :result_description => @task.result_description,
168
+ :dependencies => dependencies.collect{|dep| [dep.task_name, dep.name, dep.path]}
156
169
  })
157
170
 
158
- set_info :dependencies, dependencies.collect{|dep| [dep.task_name, dep.name, dep.path]}
159
171
 
160
172
  begin
161
173
  run_dependencies
@@ -270,9 +282,11 @@ class Step
270
282
  status = self.status
271
283
  if status != :done and status != :error and status != :aborted
272
284
  Misc.insist do
273
- set_info :done, (done_time = Time.now)
274
- set_info :total_time_elapsed, (total_time_elapsed = done_time - issue_time)
275
- set_info :time_elapsed, (time_elapsed = done_time - start_time)
285
+ merge_info({
286
+ :done => (done_time = Time.now),
287
+ :total_time_elapsed => (total_time_elapsed = done_time - issue_time),
288
+ :time_elapsed => (time_elapsed = done_time - start_time)
289
+ })
276
290
  log :done, "Completed step #{Log.color :yellow, task.name.to_s || ""} in #{time_elapsed.to_i}+#{(total_time_elapsed - time_elapsed).to_i} sec."
277
291
  end
278
292
  end
@@ -310,9 +324,11 @@ class Step
310
324
  raise exception
311
325
  end
312
326
  else
313
- set_info :done, (done_time = Time.now)
314
- set_info :total_time_elapsed, (total_time_elapsed = done_time - issue_time)
315
- set_info :time_elapsed, (time_elapsed = done_time - start_time)
327
+ merge_info({
328
+ :done => (done_time = Time.now),
329
+ :total_time_elapsed => (total_time_elapsed = done_time - issue_time),
330
+ :time_elapsed => (time_elapsed = done_time - start_time)
331
+ })
316
332
  log :ending
317
333
  Step.purge_stream_cache
318
334
  FileUtils.rm pid_file if File.exist?(pid_file)
@@ -595,7 +611,7 @@ class Step
595
611
  dependencies.each{|dep| dep.join }
596
612
  end
597
613
 
598
- until path.exists? or error? or aborted?
614
+ until (path.exists? && status == :done) or error? or aborted?
599
615
  sleep 1
600
616
  join_stream if streaming?
601
617
  end
@@ -17,6 +17,7 @@ $ rbbt system status <workflow> <task>
17
17
  -q--quick Quick check
18
18
  -a--all Print all jobs, not only uncompleted
19
19
  -i--inputs* List of inputs to print
20
+ -if--info_fields* List of info fields to print
20
21
  EOF
21
22
  rbbt_usage and exit 0 if options[:help]
22
23
 
@@ -29,6 +30,7 @@ task = task.split "," if task
29
30
  all = options.delete :all
30
31
 
31
32
  inputs = (options[:inputs] || "").split(",")
33
+ info_fields = (options[:info_fields] || "").split(",")
32
34
 
33
35
  def pid_msg(pid)
34
36
  color = if pid and Misc.pid_exists? pid
@@ -145,6 +147,7 @@ workflows.sort.each do |workflow,tasks|
145
147
  rescue
146
148
  {:status => :noinfo}
147
149
  end
150
+ IndiferentHash.setup(info)
148
151
 
149
152
  pid = info[:pid]
150
153
  status = info[:status]
@@ -163,15 +166,22 @@ workflows.sort.each do |workflow,tasks|
163
166
  job_inputs = info[:inputs]
164
167
  IndiferentHash.setup(job_inputs)
165
168
 
166
- iii inputs
167
169
  inputs.each do |input|
168
170
  value = job_inputs[input]
169
- iii [input, value]
170
171
  next if value.nil?
171
172
  value_str = Misc.fingerprint(value)
172
173
  str << " #{input}=#{value_str}"
173
174
  end
174
175
  end
176
+
177
+ if info_fields and info_fields.any?
178
+ info_fields.each do |field|
179
+ value = info[field]
180
+ next if value.nil?
181
+ value_str = Misc.fingerprint(value)
182
+ str << " #{field}=#{value_str}"
183
+ end
184
+ end
175
185
  end
176
186
  str << "; #{pid_msg pid}" unless status == "done"
177
187
  str
@@ -83,6 +83,11 @@ Returns numer * 2 lines containing TEST
83
83
  end
84
84
  end
85
85
 
86
+ dep :stream
87
+ task :stream2 => :array do
88
+ TSV.get_stream step(:stream)
89
+ end
90
+
86
91
  input :name, :string, "Name"
87
92
  task :input_dep => :text do |name|
88
93
  <<-EOF
@@ -207,5 +212,15 @@ class TestWorkflow < Test::Unit::TestCase
207
212
  nil
208
213
  end
209
214
 
215
+ def test_stream_order
216
+
217
+ Log.with_severity 0 do
218
+ job = TestWF.job(:stream2)
219
+ job.recursive_clean
220
+ job.produce
221
+
222
+ end
223
+ end
224
+
210
225
 
211
226
  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.21.109
4
+ version: 5.21.110
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-23 00:00:00.000000000 Z
11
+ date: 2017-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake