rbbt-util 5.30.6 → 5.30.7

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
  SHA256:
3
- metadata.gz: 3a9ed1ed74562cdb81e14bb2b2213398646f76e532bdee48e67f9ff2f5330aad
4
- data.tar.gz: e54ecf83a0b4323ffe98f8968f4a65acc2aae2ee5437330f44f14dc17c450ec5
3
+ metadata.gz: 3275cafa7bc74ca88f5d487287ff736113dad5ee6e607bb13f283bb4aa5e0562
4
+ data.tar.gz: 1a7642c60ce3f3828790599c2522ad1e083bd877c53de10401b93735e952934d
5
5
  SHA512:
6
- metadata.gz: 4d2eb887a184e24d78e8c565cefc25f09246d14e0f22d9a9037447806489cb4148fb2d9d3aad4cfe9bca1f256c0ec43afcc343047f20f974e6facea3214f40c0
7
- data.tar.gz: 7f593e22911a501e353b6eb49830291a29b038474fd7bfc182e402f255219fc1eaf07311ad334118b43c275abc9ab2a5198d68ccbcdce7f3b4636c38dc698afd
6
+ metadata.gz: bc9717f6611646c099305587bdcf224243102a500ba68047e382df49e583a3c764489e09b7c9aa4993eab3953d72dc9ce206d5450213e1ae832b1622c96fd309
7
+ data.tar.gz: 791cdba47b74e1f1fd47c439bb3f2b025e540002ec2b1e18d846bab08c6fd858cc25a94f9c84056383c5125cca22c19f00d43ae0c53a8c77ef4de423c19f0d8c
@@ -8,7 +8,7 @@ module HPC
8
8
  task_name = job.overriden.to_s if Symbol === job.overriden
9
9
 
10
10
  defaults = rules["defaults"] || {}
11
- defaults.merge(rules[workflow]["defaults"] || {}) if rules[workflow]
11
+ defaults = defaults.merge(rules[workflow]["defaults"] || {}) if rules[workflow]
12
12
 
13
13
  job_rules = IndiferentHash.setup(defaults.dup)
14
14
 
@@ -53,50 +53,88 @@ module HPC
53
53
  job_rules
54
54
  end
55
55
 
56
- def self.get_job_dependencies(job, job_rules)
56
+ def self.get_job_dependencies(job, job_rules = nil)
57
57
  deps = job.dependencies || []
58
58
  deps += job.input_dependencies || []
59
59
  deps
60
60
  end
61
61
 
62
- def self.orchestrate_job(job, options, skip = false, seen = {}, chains = {})
63
- return if job.done?
64
- return unless job.path.split("/")[-4] == "jobs"
65
- seen[:orchestration_target_job] ||= job
66
-
67
- options.delete "recursive_clean"
68
- options.delete "clean_task"
69
- options.delete "clean"
70
- options.delete "tail"
71
- options.delete "printfile"
72
- options.delete "detach"
62
+ def self.get_recursive_job_dependencies(job)
63
+ deps = get_job_dependencies(job)
64
+ (deps + deps.collect{|dep| get_recursive_job_dependencies(dep) }).flatten
65
+ end
73
66
 
74
- rules = YAML.load(Open.read(options[:orchestration_rules])) if options[:orchestration_rules]
75
- rules ||= {}
76
- IndiferentHash.setup(rules)
67
+ def self.piggyback(job, job_rules, job_deps)
68
+ return false unless job_rules["skip"]
69
+ final_deps = job_deps - job_deps.collect{|dep| get_recursive_job_dependencies(dep)}.flatten.uniq
70
+ return final_deps.first if final_deps.length == 1
71
+ return false
72
+ end
77
73
 
74
+ def self.get_chains(job, rules, chains = {})
78
75
  job_rules = self.job_rules(rules, job)
76
+ job_deps = get_job_dependencies(job)
79
77
 
80
- deps = get_job_dependencies(job, job_rules)
78
+ input_deps = []
79
+ job.rec_dependencies.each do |dep|
80
+ input_deps.concat dep.input_dependencies
81
+ end
81
82
 
82
- chains[job.path] ||= []
83
- dep_ids = deps.collect do |dep|
84
- skip_dep = job_rules["chain_tasks"] &&
83
+ job_deps.each do |dep|
84
+ input_deps.concat dep.input_dependencies
85
+ get_chains(dep, rules, chains)
86
+ end
87
+
88
+ job_deps.select do |dep|
89
+ chained = job_rules["chain_tasks"] &&
85
90
  job_rules["chain_tasks"][job.workflow.to_s] && job_rules["chain_tasks"][job.workflow.to_s].include?(job.task_name.to_s) &&
86
91
  job_rules["chain_tasks"][dep.workflow.to_s] && job_rules["chain_tasks"][dep.workflow.to_s].include?(dep.task_name.to_s)
87
92
 
88
- chains[job.path] << dep if skip_dep
93
+ dep_skip = dep.done? && ! input_deps.include?(dep) && self.job_rules(rules, dep)["skip"]
94
+ chained || dep_skip
95
+ end.each do |dep|
96
+ chains[job] ||= []
97
+ chains[job] << dep
98
+ chains[job].concat chains[dep] if chains[dep]
99
+ end
100
+
101
+ chains
102
+ end
89
103
 
90
- deps = seen[dep.path] ||= self.orchestrate_job(dep, options, skip_dep, seen, chains)
91
- if job.canfail_paths.include? dep.path
92
- [deps].flatten.compact.collect{|id| ['canfail', id] * ":"}
104
+ def self.workload(job, rules, chains, options, seen = nil)
105
+ return [] if job.done?
106
+ if seen.nil?
107
+ seen = {}
108
+ target_job = true
109
+ end
110
+
111
+ job_rules = self.job_rules(rules, job)
112
+ job_deps = get_job_dependencies(job)
113
+
114
+
115
+ chain = chains[job]
116
+ chain -= seen.keys if chain
117
+ piggyback = piggyback(job, job_rules, job_deps)
118
+ dep_ids = job_deps.collect do |dep|
119
+ seen[dep] = nil if chain && chain.include?(dep) #&& ! job.input_dependencies.include?(dep)
120
+ next_options = IndiferentHash.setup(options.dup)
121
+ if piggyback and piggyback == dep
122
+ next_options[:piggyback] ||= []
123
+ next_options[:piggyback].push job
124
+ ids = workload(dep, rules, chains, next_options, seen)
93
125
  else
94
- deps
126
+ next_options.delete :piggyback
127
+ ids = workload(dep, rules, chains, next_options, seen)
95
128
  end
96
- end.flatten.compact.uniq
97
129
 
98
- skip = true if job_rules[:skip]
99
- return dep_ids if skip and seen[:orchestration_target_job] != job
130
+ ids = [ids].flatten.compact.collect{|id| ['canfail', id] * ":"} if job.canfail_paths.include? dep.path
131
+
132
+ seen[dep] = ids
133
+ ids
134
+ end.compact.flatten.uniq
135
+
136
+ return seen[job] || dep_ids if seen.include?(job)
137
+ return seen[piggyback] if piggyback
100
138
 
101
139
  job_rules.delete :chain_tasks
102
140
  job_rules.delete :tasks
@@ -111,21 +149,48 @@ module HPC
111
149
  job_options[:config_keys] = job_options[:config_keys] ? config_keys + "," + job_options[:config_keys] : config_keys
112
150
  end
113
151
 
114
- manifest = []
115
- stack = [job]
116
- while dep = stack.pop
117
- manifest << dep
118
- stack += chains[dep.path] if chains[dep.path]
152
+
153
+ if options[:piggyback]
154
+ manifest = options[:piggyback].uniq
155
+ manifest += [job]
156
+ manifest.concat chain if chain
157
+ job = options[:piggyback].first
158
+ job_options.delete :piggyback
159
+ else
160
+ manifest = [job]
161
+ manifest.concat chain if chain
119
162
  end
120
163
 
121
- job_options[:manifest] = manifest.uniq.collect{|dep| dep.workflow_short_path}
164
+ manifest.uniq!
165
+
166
+ job_options[:manifest] = manifest.collect{|j| j.workflow_short_path }
122
167
 
123
168
  if options[:dry_run]
124
- puts Log.color(:yellow, "Manifest: ") + Log.color(:blue, job_options[:manifest] * ", ") + " - tasks: #{job_options[:task_cpus] || 1} - time: #{job_options[:time]} - config: #{job_options[:config_keys]}"
125
- []
169
+ puts Log.color(:magenta, "Manifest: ") + Log.color(:blue, job_options[:manifest] * ", ") + " - tasks: #{job_options[:task_cpus] || 1} - time: #{job_options[:time]} - config: #{job_options[:config_keys]}"
170
+ puts Log.color(:yellow, "Deps: ") + Log.color(:blue, job_options[:slurm_dependencies]*", ")
171
+ job_options[:manifest].first
126
172
  else
127
173
  run_job(job, job_options)
128
174
  end
129
175
  end
176
+
177
+
178
+ def self.orchestrate_job(job, options)
179
+ options.delete "recursive_clean"
180
+ options.delete "clean_task"
181
+ options.delete "clean"
182
+ options.delete "tail"
183
+ options.delete "printfile"
184
+ options.delete "detach"
185
+
186
+ rules = YAML.load(Open.read(options[:orchestration_rules])) if options[:orchestration_rules]
187
+ rules ||= {}
188
+ IndiferentHash.setup(rules)
189
+
190
+ chains = get_chains(job, rules)
191
+
192
+ workload(job, rules, chains, options)
193
+ end
194
+
130
195
  end
131
196
  end
@@ -717,7 +717,7 @@ module TSV
717
717
  def transpose(key_field = "Unkown ID")
718
718
  case type
719
719
  when :single, :flat
720
- transpose_list self.to_list, key_field
720
+ self.to_list.transpose_list key_field
721
721
  when :list
722
722
  transpose_list key_field
723
723
  when :double
data/lib/rbbt/workflow.rb CHANGED
@@ -379,7 +379,7 @@ module Workflow
379
379
  has_overriden_inputs = false
380
380
 
381
381
  inputs.each do |k,v|
382
- has_overriden_inputs = true if String === k and k.include? "#"
382
+ #has_overriden_inputs = true if String === k and k.include? "#"
383
383
  next unless (task_inputs.include?(k.to_sym) or task_inputs.include?(k.to_s))
384
384
  default = all_defaults[k]
385
385
  next if default == v
@@ -114,9 +114,13 @@ class Step
114
114
 
115
115
  def copy_files_dir
116
116
  if File.symlink?(self.files_dir)
117
- realpath = Open.realpath(self.files_dir)
118
- Open.rm self.files_dir
119
- Open.cp realpath, self.files_dir
117
+ begin
118
+ realpath = Open.realpath(self.files_dir)
119
+ Open.rm self.files_dir
120
+ Open.cp realpath, self.files_dir
121
+ rescue
122
+ Log.warn "Copy files_dir for #{self.workflow_short_path}: " + $!.message
123
+ end
120
124
  end
121
125
  end
122
126
 
@@ -168,6 +168,10 @@ class Step
168
168
  @task_name ||= task.name
169
169
  end
170
170
 
171
+ def task_signature
172
+ [workflow.to_s, task_name] * "#"
173
+ end
174
+
171
175
  # {{{ INFO
172
176
 
173
177
  def info_file
data/share/Rlib/util.R CHANGED
@@ -484,7 +484,7 @@ rbbt.model.inpute <- function(data, formula, ...){
484
484
  data
485
485
  }
486
486
 
487
- rbbt.tsv.melt <- function(tsv, variable = NULL, value = NULL, key.field = NULL){
487
+ rbbt.tsv.melt <- function(tsv, variable = NULL, value = NULL, key.field = NULL, ...){
488
488
  rbbt.require('reshape2')
489
489
  if (is.null(key.field)){ key.field = attributes(data)$key.field;}
490
490
  if (is.null(key.field)){ key.field = "ID" }
@@ -494,7 +494,7 @@ rbbt.tsv.melt <- function(tsv, variable = NULL, value = NULL, key.field = NULL){
494
494
 
495
495
  tsv[key.field] = rownames(tsv)
496
496
 
497
- m <- melt(tsv)
497
+ m <- melt(tsv, id.vars=c(key.field), ...)
498
498
 
499
499
  names(m) <- c(key.field, variable, value)
500
500
 
@@ -784,6 +784,12 @@ rbbt.plot.venn <- function(data, a=NULL, category=NULL, fill=NULL, ...) {
784
784
  return(out)
785
785
  }
786
786
 
787
+ rbbt.plot.upset <- function(data, variable = NULL, ...){
788
+ rbbt.require('UpSetR')
789
+ data[data == TRUE] = 1
790
+ return(upset(data, ...))
791
+ }
792
+
787
793
  rbbt.plot.pca <- function(data, center = TRUE, scale. = TRUE, ...) {
788
794
  rbbt.require('vqv/ggbiplot')
789
795
  data <- rbbt.impute(data)
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.30.6
4
+ version: 5.30.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-09 00:00:00.000000000 Z
11
+ date: 2021-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake