rbbt-util 5.21.126 → 5.21.127

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: b25c57ba759c64c90f84606b1903060f3551cf20
4
- data.tar.gz: d11206948af6273c56a6ac051a1ca3e064214a72
3
+ metadata.gz: 2b39b4950994d49ab0541d19a8e7d3ac45245c1e
4
+ data.tar.gz: 28ac4746e480b19a5c9005671f15a29a97586f46
5
5
  SHA512:
6
- metadata.gz: a79b14310fb16641876d4b84629f3af35a783a42c7785019ff7bdd9c44492930f80c3293e36fb966b66e4ff86c668a2823c48465da7ad011e0bf7bb6958e625b
7
- data.tar.gz: 78ef5d0e917fe5c5be16b453cb94a757397c46c3d20d38fe2a67b0c2ea26800cdb3f33e0e223444b0b5c2371e173c0d6a654f5005d9f0e6b21997178bd56fc49
6
+ metadata.gz: 1722d689b494dedf1095a53f288b063dd12c2aa1ce01a05c3e92b17172266facd7445879d10e75d7aac65ebe22c502d37398e9345e19ffaf7297d680400b84df
7
+ data.tar.gz: 57e25447236ba7c6e5f28be95c687513c1259f742ddbdbe0d7957b695b9c17177e3c0105c821638871afec07e2249a3a9b2ff6c5015c9288ff0c018664fc4765
data/lib/rbbt/monitor.rb CHANGED
@@ -146,7 +146,7 @@ module Rbbt
146
146
  task = File.basename(taskdir)
147
147
  next if tasks and not tasks.include? task
148
148
 
149
- cmd = "find -L '#{ taskdir }/' -not -type d -not -path '*/*.files/*' -not -path '*/*.pid' 2>/dev/null"
149
+ cmd = "find -L '#{ taskdir }/' -not \\( -path \"#{taskdir}/*.files\" -prune \\) -not -path '*/*.pid' -not -type d 2>/dev/null"
150
150
  files = CMD.cmd(cmd, :pipe => true)
151
151
  TSV.traverse files, :type => :array, :into => jobs, :_bar => "Finding jobs in #{ taskdir }" do |file|
152
152
  _files << file
data/lib/rbbt/workflow.rb CHANGED
@@ -4,6 +4,7 @@ require 'rbbt/workflow/step'
4
4
  require 'rbbt/workflow/accessor'
5
5
  require 'rbbt/workflow/doc'
6
6
  require 'rbbt/workflow/examples'
7
+ require 'rbbt/workflow/archive'
7
8
 
8
9
  module Workflow
9
10
 
@@ -813,8 +813,10 @@ module Workflow
813
813
  next if d.nil?
814
814
  if Hash === d
815
815
  d[:workflow] ||= wf
816
- d[:task] = task_name
817
- inputs = assign_dep_inputs({}, options.merge(d[:inputs] || {}), real_dependencies, d[:workflow].task_info(d[:task]))
816
+ d[:task] ||= task_name
817
+ task_info = d[:workflow].task_info(d[:task])
818
+
819
+ inputs = assign_dep_inputs({}, options.merge(d[:inputs] || {}), real_dependencies, task_info)
818
820
  d = d[:workflow].job(d[:task], d[:jobname], inputs)
819
821
  end
820
822
  ComputeDependency.setup(d, compute) if compute
@@ -0,0 +1,49 @@
1
+ class Step
2
+ def self.link_job(path, target_dir, task = nil, workflow = nil)
3
+ Path.setup(target_dir)
4
+
5
+ name = File.basename(path)
6
+ task = File.basename(File.dirname(path)) if task.nil?
7
+ workflow = File.basename(File.dirname(File.dirname(path))) if workflow.nil?
8
+
9
+ FileUtils.mkdir_p target_dir[workflow][task]
10
+ FileUtils.ln_s path, target_dir[workflow][task][name].find
11
+ FileUtils.ln_s path + '.files', target_dir[workflow][task][name].find + '.files' if File.exists?(path + '.files')
12
+ FileUtils.ln_s path + '.info', target_dir[workflow][task][name].find + '.info' if File.exists?(path + '.info')
13
+ end
14
+
15
+ def archive(target = nil)
16
+ target = self.path + '.tar.gz' if target.nil?
17
+ target = File.expand_path(target)
18
+ TmpFile.with_file do |tmpdir|
19
+ Step.link_job self.path, tmpdir
20
+ rec_dependencies = Set.new
21
+ deps = [self.path]
22
+ seen = Set.new
23
+ while deps.any?
24
+ path = deps.shift
25
+ dep = Step.new path
26
+ seen << dep.path
27
+ dep.info[:dependencies].each do |task, name, path|
28
+ dep = Step.new path
29
+ next if seen.include? dep.path
30
+ deps << dep.path
31
+ rec_dependencies << dep.path
32
+ end if dep.info[:dependencies]
33
+ end
34
+
35
+ rec_dependencies.each do |path|
36
+ Step.link_job path, tmpdir
37
+ end
38
+
39
+ Misc.in_dir(tmpdir) do
40
+ io = CMD.cmd("tar cvhzf '#{target}' ./*", :pipe => true)
41
+ while line = io.gets
42
+ Log.debug line
43
+ end
44
+ io.join if io.respond_to? :join
45
+ end
46
+ Log.debug "Archive finished at: #{target}"
47
+ end
48
+ end
49
+ end
@@ -51,9 +51,8 @@ module Workflow
51
51
 
52
52
  def example_inputs(task_name, example)
53
53
  inputs = {}
54
- IndiferentHash.setup(input)
54
+ IndiferentHash.setup(inputs)
55
55
  example(task_name, example).each do |input,type,file|
56
- next if new_inputs.include? input
57
56
 
58
57
  case type
59
58
  when :tsv, :array, :text
@@ -50,14 +50,16 @@ def status_msg(status)
50
50
  when :error, :aborted, :missing, :dead
51
51
  :red
52
52
  when :streaming, :started
53
- :yellow
53
+ :cyan
54
54
  when :done
55
55
  :green
56
+ when :dependencies, :waiting, :setyp
57
+ :yellow
56
58
  else
57
59
  if status.to_s.index ">"
58
- :yellow
60
+ :cyan
59
61
  else
60
- nil
62
+ :cyan
61
63
  end
62
64
  end
63
65
  Log.color(color, status.to_s)
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rbbt/workflow'
4
+
5
+ require 'rbbt-util'
6
+ require 'fileutils'
7
+ require 'rbbt/util/simpleopt'
8
+ require 'rbbt/workflow/step'
9
+ require 'rbbt/util/misc'
10
+
11
+ require 'rbbt-util'
12
+ require 'rbbt/util/simpleopt'
13
+
14
+ $0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands
15
+
16
+ options = SOPT.setup <<EOF
17
+ Examine the provenance of a job result
18
+
19
+ $ rbbt workflow archive <job> [target]
20
+
21
+ Archive job and all dependencies into the target tar gz file. If no target is specified
22
+ it defaults to a <job>.tar.gz
23
+
24
+ -h--help Help
25
+ EOF
26
+
27
+ SOPT.usage if options[:help]
28
+
29
+ file, target = ARGV
30
+
31
+ Step.new(File.expand_path(file)).archive(target)
@@ -31,17 +31,23 @@ def get_step(file)
31
31
  end
32
32
 
33
33
  def status_msg(status)
34
- color = case status
35
- when :error, :aborted, :missing
34
+ color = case status.to_sym
35
+ when :error, :aborted, :missing, :dead
36
36
  :red
37
- when :streaming
38
- :yellow
37
+ when :streaming, :started
38
+ :cyan
39
39
  when :done
40
40
  :green
41
+ when :dependencies, :waiting, :setyp
42
+ :yellow
41
43
  else
42
- nil
44
+ if status.to_s.index ">"
45
+ :cyan
46
+ else
47
+ :cyan
48
+ end
43
49
  end
44
- Log.color(color, status)
50
+ Log.color(color, status.to_s)
45
51
  end
46
52
 
47
53
  def pid_msg(pid, done = false)
@@ -34,15 +34,23 @@ def get_step(file)
34
34
  end
35
35
 
36
36
  def status_msg(status)
37
- color = case status
38
- when :error, :aborted, :missing
37
+ color = case status.to_sym
38
+ when :error, :aborted, :missing, :dead
39
39
  :red
40
- when :streaming
41
- :yellow
40
+ when :streaming, :started
41
+ :cyan
42
42
  when :done
43
43
  :green
44
+ when :dependencies, :waiting, :setyp
45
+ :yellow
46
+ else
47
+ if status.to_s.index ">"
48
+ :cyan
49
+ else
50
+ :cyan
51
+ end
44
52
  end
45
- Log.color(color, status)
53
+ Log.color(color, status.to_s)
46
54
  end
47
55
 
48
56
  def report_msg(status, name, path)
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.126
4
+ version: 5.21.127
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-01 00:00:00.000000000 Z
11
+ date: 2018-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -316,6 +316,7 @@ files:
316
316
  - lib/rbbt/workflow.rb
317
317
  - lib/rbbt/workflow/accessor.rb
318
318
  - lib/rbbt/workflow/annotate.rb
319
+ - lib/rbbt/workflow/archive.rb
319
320
  - lib/rbbt/workflow/definition.rb
320
321
  - lib/rbbt/workflow/doc.rb
321
322
  - lib/rbbt/workflow/examples.rb
@@ -387,6 +388,7 @@ files:
387
388
  - share/rbbt_commands/tsv/write_excel
388
389
  - share/rbbt_commands/tsv/zip
389
390
  - share/rbbt_commands/watch
391
+ - share/rbbt_commands/workflow/archive
390
392
  - share/rbbt_commands/workflow/cmd
391
393
  - share/rbbt_commands/workflow/example
392
394
  - share/rbbt_commands/workflow/info