rbbt-util 5.25.45 → 5.25.46

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: 1fec18b4fe1096cc53f3f100a2caabdf0fa52c17
4
- data.tar.gz: e484faf85e964516add9d7c9be0f0a7e37b172f8
3
+ metadata.gz: d7a6bfb0c182d36d1323ddefe70c93f57e173c55
4
+ data.tar.gz: fff96627b902d989f53d92a4fe6f327502f75c89
5
5
  SHA512:
6
- metadata.gz: 7b199196a490f4a6a3ffcc4fae923afc7802548bbf3463f64b1e76dc03f6e53ec4052b527acce38d10d62c55d5b2d19f89e6e738ff0a615007d48f1dda133aab
7
- data.tar.gz: 072d28fb2a80c8b39bb26db1f5c607daa4c136f5763bbf6e79c19f2cbf4e486b9bc9ceaf4ac6e7b5aebf4aa6db9ee7fdfd40bfd8dd22f45d0afdab1782d9b864
6
+ metadata.gz: 9cd88404da356142456ea01f3efdb78ec784613a4b7670a4826ca40a4a8d74275632c7cf7ba521437b1554332e713b02904da2735fc30489bdaed9cc858f5e9e
7
+ data.tar.gz: 26d5b2fc59d6cd3446dfb7de5094c5dec73b44ab9e438e451f160bee3b9a3eddbdb3b49f5614bfc4fb40048bafe7b745360185a203147c0a9d9f2b23b441ae15
@@ -94,10 +94,12 @@ module TSV
94
94
 
95
95
  module XLS
96
96
  def self.read(file, options = {})
97
- options = Misc.add_defaults options, :sep2 => /[,|]\s?/
97
+ options = Misc.add_defaults options, :sep2 => /[,|]\s?/, :skip_rows => 0
98
98
  sheet = Misc.process_options options, :sheet
99
99
  header = Misc.process_options options, :header
100
100
  text = Misc.process_options options, :text
101
+ skip_rows = Misc.process_options options, :skip_rows
102
+ skip_rows = skip_rows.to_i
101
103
 
102
104
  header = true unless header == false
103
105
  sheet ||= "0"
@@ -117,6 +119,11 @@ module TSV
117
119
  rows = []
118
120
 
119
121
  sheet.each do |row|
122
+ if skip_rows > 0
123
+ skip_rows -= 1
124
+ next
125
+ end
126
+
120
127
  rows << row.values_at(0..(row.size - 1)).collect{|c| String === c ? c.gsub("\n", ' ') : c }
121
128
  end
122
129
 
@@ -159,10 +166,12 @@ module TSV
159
166
 
160
167
  module XLSX
161
168
  def self.read(file, options = {})
162
- options = Misc.add_defaults options, :sep2 => /[,|]\s?/
169
+ options = Misc.add_defaults options, :sep2 => /[,|]\s?/, :skip_rows => 0
163
170
  sheet = Misc.process_options options, :sheet
164
171
  header = Misc.process_options options, :header
165
172
  text = Misc.process_options options, :text
173
+ skip_rows = Misc.process_options options, :skip_rows
174
+ skip_rows = skip_rows.to_i
166
175
 
167
176
  header = true unless header == false
168
177
 
@@ -182,6 +191,11 @@ module TSV
182
191
 
183
192
  sheet.each do |row|
184
193
  next if row.nil?
194
+ if skip_rows > 0
195
+ skip_rows -= 1
196
+ next
197
+ end
198
+
185
199
  rows << row.cells.collect{|c| c.nil? ? nil : c.value}.collect{|c| String === c ? c.gsub("\n", ' ') : c }
186
200
  end
187
201
 
data/lib/rbbt/util/cmd.rb CHANGED
@@ -139,7 +139,7 @@ module CMD
139
139
  pid = io.pids.first
140
140
 
141
141
  while c = io.getc
142
- STDERR << c
142
+ STDERR << c if Log.severity == 0
143
143
  if c == "\n"
144
144
  if pid
145
145
  Log.logn "STDOUT [#{pid}]: ", 0
@@ -74,6 +74,10 @@ module Log
74
74
  Log::LAST.replace "remove_bar" if Log::LAST == "progress"
75
75
  end
76
76
 
77
+ def remove(error = false)
78
+ Log::ProgressBar.remove_bar self, error
79
+ end
80
+
77
81
  def self.with_bar(max, options = {})
78
82
  bar = new_bar(max, options)
79
83
  begin
@@ -257,7 +257,7 @@ module Open
257
257
  if (dir_sub_path = find_repo_dir(file))
258
258
  remove_from_repo(*dir_sub_path)
259
259
  else
260
- FileUtils.rm(file) if File.exists?(file)
260
+ FileUtils.rm(file) if File.exists?(file) or Open.broken_link?(file)
261
261
  end
262
262
  end
263
263
 
@@ -793,4 +793,8 @@ module Open
793
793
  FileUtils.touch(file)
794
794
  end
795
795
  end
796
+
797
+ def self.broken_link?(path)
798
+ File.symlink?(path) && ! File.exists?(File.readlink(path))
799
+ end
796
800
  end
@@ -303,14 +303,15 @@ class Step
303
303
  return
304
304
  end
305
305
 
306
- if Open.exists?(path) or Open.exists?(pid_file) or Open.exists?(info_file) or Open.exists?(files_dir)
306
+ if (Open.exists?(path) or Open.broken_link?(path)) or Open.exists?(pid_file) or Open.exists?(info_file) or Open.exists?(files_dir)
307
307
 
308
308
  @result = nil
309
309
  @pid = nil
310
310
 
311
311
  Misc.insist do
312
312
  Open.rm info_file if Open.exists? info_file
313
- Open.rm path if Open.exists? path
313
+ Open.rm path if (Open.exists?(path) or Open.broken_link?(path))
314
+ Open.rm path if (Open.exists?(path) or Open.broken_link?(path))
314
315
  Open.rm_rf files_dir if Open.exists? files_dir
315
316
  Open.rm pid_file if Open.exists? pid_file
316
317
  end
@@ -82,7 +82,7 @@ puts
82
82
  jobs = Rbbt.job_info workflow, task
83
83
  workflows = {}
84
84
 
85
- TSV.traverse jobs, :_bar => "Checking job status" do |file,i|
85
+ TSV.traverse jobs do |file,i|
86
86
  if options[:quick] and i[:done]
87
87
  status = 'done'
88
88
  else
@@ -94,7 +94,7 @@ TSV.traverse jobs, :_bar => "Checking job status" do |file,i|
94
94
  {:status => :noinfo}
95
95
  end
96
96
 
97
- done = Open.exists?(file)
97
+ done = Open.exists?(file) && ! Open.broken_link?(file)
98
98
  pid = info[:pid] || (Open.exists?(file + '.pid') && Open.read(file + '.pid')) unless done
99
99
 
100
100
  status = info[:status].to_s
@@ -48,7 +48,7 @@ end
48
48
 
49
49
  def status_msg(status)
50
50
  color = case status.to_sym
51
- when :error, :aborted, :missing, :dead
51
+ when :error, :aborted, :missing, :dead, :broken
52
52
  :red
53
53
  when :streaming, :started
54
54
  :cyan
@@ -56,7 +56,7 @@ def status_msg(status)
56
56
  :green
57
57
  when :noinfo
58
58
  :blue
59
- when :dependencies, :waiting, :setyp
59
+ when :dependencies, :waiting, :setup
60
60
  :yellow
61
61
  else
62
62
  if status.to_s.index ">"
@@ -199,7 +199,8 @@ workflows.sort.each do |workflow,tasks|
199
199
 
200
200
  pid = info[:pid]
201
201
  status = info[:status]
202
- status = :missing if status == :done and not Open.exist? file
202
+ status = :missing if status == :done and not (Open.exist?(file) && ! Open.broken_link?(file))
203
+ status = :broken if Open.broken_link?(file)
203
204
  status = status.to_s
204
205
  if status != "done" and pid and not Misc.pid_exists?(pid)
205
206
  if File.exist? file
@@ -21,6 +21,7 @@ Use - to read from STDIN
21
21
  -s2--sep2* Second level separator. Default /[,|]\\s?/
22
22
  -h--help Print this help
23
23
  -s--sheet* Sheet to extract
24
+ -skip--skip_rows* Initial rows to skip
24
25
 
25
26
  EOF
26
27
  if options[:help]
@@ -0,0 +1,90 @@
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/workflow/provenance'
10
+ require 'rbbt/util/misc'
11
+
12
+ require 'rbbt-util'
13
+ require 'rbbt/util/simpleopt'
14
+ require 'rbbt/util/R'
15
+
16
+ $0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands
17
+
18
+ options = SOPT.setup <<EOF
19
+ Examine the provenance of a job result
20
+
21
+ $ rbbt workflow trace <job-result> <file.png>
22
+
23
+ -h--help Help
24
+ -i--inputs* List of inputs to print
25
+ -if--info_fields* List of info fields to print
26
+ EOF
27
+
28
+ SOPT.usage if options[:help]
29
+
30
+ $inputs = (options[:inputs] || "").split(",")
31
+ $info_fields = (options[:info_fields] || "").split(",")
32
+
33
+ file = ARGV.shift || "/home/mvazque2/.rbbt/var/jobs/Sample/haplotype/NA12878"
34
+ plot = ARGV.shift || "/tmp/plot.png"
35
+
36
+ $seen = []
37
+ def get_step(file)
38
+ file = File.expand_path(file)
39
+ file = file.sub(/\.(info|files)/,'')
40
+ $seen << file
41
+ Workflow.load_step file
42
+ end
43
+
44
+ step = get_step file
45
+ $main_mtime = Open.exist?(step.path) ? Open.mtime(step.path) : nil
46
+
47
+ data = TSV.setup({}, "Job~Workflow,Task,Start,End#:type=:list")
48
+
49
+ jobs = step.rec_dependencies + [step]
50
+
51
+ jobs = jobs.select{|job| job.info[:done]}.sort_by{|job| job.info[:started]}
52
+
53
+ min_start = nil
54
+ max_done = nil
55
+ jobs.each do |job|
56
+ next unless job.done?
57
+ started = job.info[:started]
58
+ ddone = job.info[:done]
59
+ data[job.name] = [job.workflow.to_s, job.task_name,started,ddone]
60
+ if min_start.nil?
61
+ min_start = started
62
+ else
63
+ min_start = started if started < min_start
64
+ end
65
+
66
+ if max_done.nil?
67
+ max_done = ddone
68
+ else
69
+ max_done = ddone if ddone > max_done
70
+ end
71
+ end
72
+
73
+ #data.process "Start" do |value|
74
+ # value - min_start
75
+ #end
76
+ #
77
+ #data.process "End" do |value|
78
+ # value - min_start
79
+ #end
80
+
81
+ Log.severity = 0
82
+ data.R_interactive <<-EOF
83
+ rbbt.require('timevis')
84
+ data$id = rownames(data)
85
+ data$content = data$Task
86
+ data$start = data$Start
87
+ data$end = data$End
88
+
89
+ timevis(data)
90
+ EOF
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.25.45
4
+ version: 5.25.46
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-10 00:00:00.000000000 Z
11
+ date: 2019-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -411,6 +411,7 @@ files:
411
411
  - share/rbbt_commands/workflow/remote/remove
412
412
  - share/rbbt_commands/workflow/server
413
413
  - share/rbbt_commands/workflow/task
414
+ - share/rbbt_commands/workflow/trace
414
415
  - share/unicorn.rb
415
416
  - share/workflow_config.ru
416
417
  - test/rbbt/annotations/test_util.rb