rbbt-util 5.32.1 → 5.32.7

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
  SHA256:
3
- metadata.gz: 4491182540571f16f4059ec742f210152862e77bda8c31355285c81daf8bfd8e
4
- data.tar.gz: 313a4e9252f8b443fef52b4267e94b177f9cacd36a89d6db63010b4ae7fb275f
3
+ metadata.gz: b989d145b1a34baab93f351ea9944e73dde157e9973a9443717b84a43e7b41d5
4
+ data.tar.gz: d6e8f5a7e8cb2d2f0e9a99f36a7594e4fc3655dd1d4f9b571f73f0f947b19fd3
5
5
  SHA512:
6
- metadata.gz: 81b4b06eac8a44027a0c0f97510c75a2b0f3daf6594da4cd977c5d197318ee7e22db35e0c12f68dced5ab5aa0c1f0c152be77ed7bafe8c5588f2d274292b2035
7
- data.tar.gz: 5ea83c058de9bde5bbae17b1c08308a7311c5c48d1c589f236300c3f437b667bd7012ad48a2c4890ab0c924168916809569367155b3a9300723a9c6596837d52
6
+ metadata.gz: da60531d5e35efd54b0c4de7e9ad6b034ef05e8d58d6a6b0a1b15422b324dd6eb5a4cb01b21ba60c091616d512106c278ef794088f87f844bd96e86d8f61d7da
7
+ data.tar.gz: 2327575017d9dbb301b8c0ba36ee691bc8be00175712e2121da019251c3735d0348cae6d18e8112b00c952e233eb806a19f2275563310360ed745a9b868a6021
data/lib/rbbt/hpc/lsf.rb CHANGED
@@ -8,7 +8,7 @@ module HPC
8
8
  def self.batch_system_variables
9
9
  <<-EOF
10
10
  let TOTAL_PROCESORS="$(cat /proc/cpuinfo|grep ^processor |wc -l)"
11
- let MAX_MEMORY_DEFAULT="$(grep MemTotal /proc/meminfo|grep -o "[[:digit:]]*") / ( (1024 * $TOTAL_PROCESORS) / $SLURM_CPUS_PER_TASK )"
11
+ let MAX_MEMORY_DEFAULT="$(grep MemTotal /proc/meminfo|grep -o "[[:digit:]]*") / ( (1024 * $TOTAL_PROCESORS) / $LSB_MAX_NUM_PROCESSORS )"
12
12
  [ ! -z $LSB_MAX_MEM_RUSAGE ] && let MAX_MEMORY="$LSB_MAX_MEM_RUSAGE" || MAX_MEMORY="$MAX_MEMORY_DEFAULT"
13
13
  export MAX_MEMORY_DEFAULT
14
14
  export MAX_MEMORY
@@ -132,7 +132,7 @@ module Persist
132
132
 
133
133
  def read_lock
134
134
  read if closed?
135
- if read?
135
+ if read? || write?
136
136
  return yield
137
137
  end
138
138
 
data/lib/rbbt/resource.rb CHANGED
@@ -6,6 +6,7 @@ require 'set'
6
6
 
7
7
 
8
8
  module Resource
9
+ class ResourceNotFound < RbbtException; end
9
10
 
10
11
  class << self
11
12
  attr_accessor :lock_dir
@@ -154,16 +155,18 @@ module Resource
154
155
  rake_dir, content = rake_for(path)
155
156
  rake_dir = Path.setup(rake_dir.dup, self.pkgdir, self)
156
157
  else
157
- begin
158
- if path !~ /\.(gz|bgz)$/
158
+ if path !~ /\.(gz|bgz)$/
159
+ begin
160
+ produce(path.annotate(path + '.gz'), force)
161
+ rescue ResourceNotFound
159
162
  begin
160
- produce(path.annotate(path + '.gz'), force)
161
- rescue
162
163
  produce(path.annotate(path + '.bgz'), force)
164
+ rescue ResourceNotFound
165
+ raise ResourceNotFound, "Resource is missing and does not seem to be claimed: #{ self } -- #{ path } "
163
166
  end
164
167
  end
165
- rescue
166
- raise "Resource is missing and does not seem to be claimed: #{ self } -- #{ path } "
168
+ else
169
+ raise ResourceNotFound, "Resource is missing and does not seem to be claimed: #{ self } -- #{ path } "
167
170
  end
168
171
  end
169
172
 
@@ -174,7 +177,7 @@ module Resource
174
177
  end
175
178
 
176
179
  if type and not File.exist?(final_path) or force
177
- Log.medium "Producing: #{ final_path }"
180
+ Log.medium "Producing: (#{self.to_s}) #{ final_path }"
178
181
  lock_filename = Persist.persistence_path(final_path, {:dir => Resource.lock_dir})
179
182
 
180
183
  Misc.lock lock_filename do
@@ -310,7 +313,10 @@ url='#{url}'
310
313
  def identify(path)
311
314
  path = File.expand_path(path)
312
315
  resource ||= Rbbt
313
- (Path::STANDARD_SEARCH + resource.search_order + resource.search_paths.keys).uniq.each do |name|
316
+ locations = (Path::STANDARD_SEARCH + resource.search_order + resource.search_paths.keys)
317
+ locations -= [:current, "current"]
318
+ locations << :current
319
+ locations.uniq.each do |name|
314
320
  pattern = resource.search_paths[name]
315
321
  next if pattern.nil?
316
322
  pattern = pattern.sub('{PWD}', Dir.pwd)
@@ -40,7 +40,7 @@ module TSV
40
40
  # Process fields line
41
41
 
42
42
  preamble << line if line
43
- while line and (TrueClass === @header_hash or (String === @header_hash and Misc.fixutf8(line) =~ /^#{@header_hash}/ ))
43
+ while line && (TrueClass === @header_hash || (String === @header_hash && Misc.fixutf8(line) =~ /^#{@header_hash}/ ))
44
44
  @fields = line.split(@sep, -1)
45
45
  @key_field = @fields.shift
46
46
  @key_field = @key_field[(0 + header_hash.length)..-1] if String === @header_hash
@@ -49,7 +49,7 @@ module TSV
49
49
  line = (@header_hash != "" ? stream.gets : nil)
50
50
  line = Misc.fixutf8 line.chomp if line
51
51
  preamble << line if line
52
- @header_hash = false if TrueClass === @header_hash
52
+ @header_hash = false if TrueClass === @header_hash || @header_hash == ""
53
53
  end
54
54
 
55
55
  @preamble = preamble[0..-3] * "\n"
@@ -56,6 +56,7 @@ module TSV
56
56
  preambles = []
57
57
 
58
58
  streams = streams.collect do |stream|
59
+
59
60
  parser = TSV::Parser.new stream, options.dup
60
61
  sfields = parser.fields
61
62
 
data/lib/rbbt/util/cmd.rb CHANGED
@@ -248,16 +248,26 @@ module CMD
248
248
  pid = io.pids.first
249
249
 
250
250
  line = "" if bar
251
+ starting = true
251
252
  while c = io.getc
252
- STDERR << c if Log.severity <= level
253
- line << c if bar
254
- if c == "\n"
255
- bar.process(line) if bar
253
+ if starting
256
254
  if pid
257
255
  Log.logn "STDOUT [#{pid}]: ", level
258
256
  else
259
257
  Log.logn "STDOUT: ", level
260
258
  end
259
+ starting = false
260
+ end
261
+ STDERR << c if Log.severity <= level
262
+ line << c if bar
263
+ if c == "\n"
264
+ bar.process(line) if bar
265
+ starting = true
266
+ #if pid
267
+ # Log.logn "STDOUT [#{pid}]: ", level
268
+ #else
269
+ # Log.logn "STDOUT: ", level
270
+ #end
261
271
  line = "" if bar
262
272
  end
263
273
  end
@@ -0,0 +1,118 @@
1
+ module Rbbt
2
+ def self.migrate_source_paths(path, resource = Rbbt, source = nil)
3
+ if source
4
+ lpath, *paths = Misc.ssh_run(source, <<-EOF).split("\n")
5
+ require 'rbbt-util'
6
+ path = "#{path}"
7
+ if Open.exists?(path)
8
+ path = #{resource.to_s}.identify(path)
9
+ else
10
+ path = Path.setup(path)
11
+ end
12
+ puts path
13
+ puts path.glob_all.collect{|p| File.directory?(p) ? p + "/" : p } * "\n"
14
+ EOF
15
+
16
+ [path, paths.collect{|p| [source, p] * ":"}, lpath]
17
+ else
18
+ if File.exists?(path)
19
+ path = resource.identify(path)
20
+ else
21
+ path = Path.setup(path)
22
+ end
23
+
24
+ [path, (path.directory? ? path.glob_all : path.find_all), path]
25
+ end
26
+ end
27
+
28
+ def self.migrate_target_path(path, search_path = 'user', resource = Rbbt, target = nil)
29
+ if target
30
+ Misc.ssh_run(target, <<-EOF).split("\n").first
31
+ require 'rbbt-util'
32
+ path = "#{path}"
33
+ resource = #{resource.to_s}
34
+ search_path = "#{search_path}"
35
+ puts resource[path].find(search_path)
36
+ EOF
37
+ else
38
+ resource[path].find(search_path)
39
+ end
40
+ end
41
+
42
+ def self.migrate_files(real_paths, target, options = {})
43
+ excludes = %w(.save .crap .source tmp filecache open-remote)
44
+ excludes += (options[:exclude] || "").split(/,\s*/)
45
+ excludes_str = excludes.collect{|s| "--exclude '#{s}'" } * " "
46
+
47
+ other = options[:other] || []
48
+
49
+ test_str = options[:test] ? '-nv' : ''
50
+
51
+ real_paths.each do |source_path|
52
+ if File.directory?(source_path) || source_path =~ /\/$/
53
+ source_path += "/" unless source_path[-1] == "/"
54
+ target += "/" unless target[-1] == "/"
55
+ end
56
+
57
+ next if source_path == target
58
+
59
+ if options[:target]
60
+ CMD.cmd("ssh #{options[:target]} mkdir -p '#{File.dirname(target)}'")
61
+ else
62
+ Open.mkdir File.dirname(target)
63
+ end
64
+
65
+ if options[:target]
66
+ target_path = [options[:target], "'" + target + "'"] * ":"
67
+ else
68
+ target_path = "'" + target + "'"
69
+ end
70
+
71
+ TmpFile.with_file do |tmp_files|
72
+ if options[:files]
73
+ Open.write(tmp_files, options[:files] * "\n")
74
+ files_from_str = "--files-from='#{tmp_files}'"
75
+ else
76
+ files_from_str = ""
77
+ end
78
+
79
+ cmd = "rsync -avztAXHP --copy-unsafe-links #{test_str} #{files_from_str} #{excludes_str} '#{source_path}' #{target_path} #{other * " "}"
80
+
81
+
82
+ cmd << " && rm -Rf #{source_path}" if options[:delete] && ! options[:files]
83
+
84
+ if options[:print]
85
+ puts cmd
86
+ exit 0
87
+ else
88
+ CMD.cmd_log(cmd, :log => Log::INFO)
89
+
90
+ if options[:delete] && options[:files]
91
+ remove_files = options[:files].collect{|f| File.join(source_path, f) }
92
+ dirs = remove_files.select{|f| File.directory? f }
93
+ remove_files.each do |file|
94
+ next if dirs.include? file
95
+ Open.rm file
96
+ end
97
+ dirs.each do |dir|
98
+ FileUtils.rmdir dir if Dir.glob(dir).empty?
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
105
+
106
+
107
+ def self.migrate(path, search_path, options = {})
108
+ search_path = 'user' if search_path.nil?
109
+
110
+ resource = Rbbt
111
+
112
+ path, real_paths, lpath = migrate_source_paths(path, resource, options[:source])
113
+
114
+ target = migrate_target_path(lpath, search_path, resource, options[:target])
115
+
116
+ migrate_files(real_paths, target, options)
117
+ end
118
+ end
@@ -43,7 +43,7 @@ module Misc
43
43
  File.mkfifo path
44
44
  yield path
45
45
  ensure
46
- FileUtils.rm path if erase
46
+ FileUtils.rm path if erase && File.exists?(path)
47
47
  end
48
48
  end
49
49
 
data/lib/rbbt/workflow.rb CHANGED
@@ -187,17 +187,21 @@ module Workflow
187
187
  clean_name = wf_name.sub(/::.*/,'')
188
188
  Log.info{"Looking for '#{wf_name}' in '#{clean_name}'"}
189
189
  require_workflow clean_name
190
- return Misc.string2const Misc.camel_case(wf_name)
190
+ workflow = Misc.string2const Misc.camel_case(wf_name)
191
+ workflow.load_documentation
192
+ return workflow
191
193
  end
192
194
 
193
195
  Log.high{"Loading workflow #{wf_name}"}
194
196
  require_local_workflow(wf_name) or
195
197
  (Workflow.autoinstall and `rbbt workflow install #{Misc.snake_case(wf_name)} || rbbt workflow install #{wf_name}` and require_local_workflow(wf_name)) or raise("Workflow not found or could not be loaded: #{ wf_name }")
196
- begin
197
- Misc.string2const Misc.camel_case(wf_name)
198
- rescue
199
- Workflow.workflows.last || true
200
- end
198
+ workflow = begin
199
+ Misc.string2const Misc.camel_case(wf_name)
200
+ rescue
201
+ Workflow.workflows.last || true
202
+ end
203
+ workflow.load_documentation
204
+ workflow
201
205
  end
202
206
 
203
207
  attr_accessor :description
@@ -596,6 +600,17 @@ module Workflow
596
600
  true
597
601
  end
598
602
  end
603
+
604
+ if ! Open.exists?(step.info_file)
605
+ begin
606
+ workflow = step.path.split("/")[-3]
607
+ task_name = step.path.split("/")[-2]
608
+ workflow = Kernel.const_get workflow
609
+ step.task = workflow.tasks[task_name.to_sym]
610
+ rescue
611
+ Log.exception $!
612
+ end
613
+ end
599
614
  step
600
615
  end
601
616
 
@@ -74,6 +74,7 @@ module Workflow
74
74
  def dep_task(name, workflow, oname, *rest, &block)
75
75
  dep(workflow, oname, *rest, &block)
76
76
  extension workflow.tasks[oname].extension if workflow.tasks.include?(oname) unless @extension
77
+ returns workflow.tasks[oname].result_description if workflow.tasks.include?(oname) unless @result_description
77
78
  task name do
78
79
  raise RbbtException, "dependency not found in dep_task" if dependencies.empty?
79
80
  dep = dependencies.last
@@ -45,10 +45,25 @@ module Workflow
45
45
  end
46
46
 
47
47
  def load_documentation
48
- @documentation = Workflow.parse_workflow_doc documentation_markdown
48
+ return if @documentation
49
+ @documentation ||= Workflow.parse_workflow_doc documentation_markdown
49
50
  @documentation[:tasks].each do |task, description|
50
- raise "Documentation for #{ task }, but not a #{ self.to_s } task" unless tasks.include? task.to_sym
51
- tasks[task.to_sym].description = description
51
+ if task.include? "#"
52
+ workflow, task = task.split("#")
53
+ workflow = begin
54
+ Kernel.const_get workflow
55
+ rescue
56
+ next
57
+ end
58
+ else
59
+ workflow = self
60
+ end
61
+
62
+ if workflow.tasks.include? task.to_sym
63
+ workflow.tasks[task.to_sym].description = description
64
+ else
65
+ Log.low "Documentation for #{ task }, but not a #{ workflow.to_s } task"
66
+ end
52
67
  end
53
68
  end
54
69
 
@@ -122,7 +122,7 @@ module Workflow
122
122
  last = _prov_tasks(workflow.dep_tree(task_name))
123
123
 
124
124
  if child
125
- description << "->" << task_name.to_s
125
+ description << "-> " << task_name.to_s
126
126
  elsif first
127
127
  description << "" << task_name.to_s
128
128
  else
@@ -198,7 +198,7 @@ module Workflow
198
198
  puts Misc.format_definition_list_item(name.to_s, description, Log.terminal_width, 20, :yellow)
199
199
 
200
200
  prov_string = prov_string(dep_tree(name))
201
- puts Log.color :blue, " ->" + prov_string if prov_string && ! prov_string.empty?
201
+ puts Misc.format_paragraph Log.color(:blue, "-> " + prov_string) if prov_string && ! prov_string.empty?
202
202
  end
203
203
 
204
204
  else
@@ -1,3 +1,4 @@
1
+ require 'rbbt/util/migrate'
1
2
  class Step
2
3
 
3
4
  MAIN_RSYNC_ARGS="-avztAXHP --copy-links"
@@ -126,63 +127,48 @@ class Step
126
127
  end
127
128
  end
128
129
 
129
- def self.migrate(path, search_path, options = {})
130
- resource=Rbbt
131
-
132
- orig_path = path
133
- other_rsync_args = options[:rsync]
134
-
135
- recursive = options[:recursive]
130
+ def self.migrate_source_paths(path, resource = Rbbt, source = nil, recursive = true)
136
131
  recursive = false if recursive.nil?
137
-
138
- paths = if options[:source]
139
- Misc.ssh_run(options[:source], <<-EOF).split("\n")
132
+ if source
133
+ lpath, *paths = Misc.ssh_run(source, <<-EOF).split("\n")
140
134
  require 'rbbt-util'
141
135
  require 'rbbt/workflow'
142
136
 
143
- path = "#{path}"
144
137
  recursive = #{ recursive.to_s }
138
+ path = "#{path}"
145
139
 
146
- if File.exists?(path)
140
+ if Open.exists?(path)
147
141
  path = #{resource.to_s}.identify(path)
148
142
  else
149
143
  path = Path.setup(path)
150
144
  end
151
145
 
152
- files = path.glob_all
153
-
146
+ files = path.glob_all.collect{|p| File.directory?(p) ? p + "/" : p }
154
147
  files = Step.job_files_for_archive(files, recursive)
155
148
 
149
+ puts path
156
150
  puts files * "\n"
157
- EOF
158
-
159
- else
160
- if File.exists?(path)
161
- path = resource.identify(path)
162
- raise "Resource #{resource} could not identify #{orig_path}" if path.nil?
163
- else
164
- path = Path.setup(path)
165
- end
166
- files = path.glob_all
167
- files = Step.job_files_for_archive(files, recursive)
168
- files
169
- end
170
-
171
-
172
- target = if options[:target]
173
- target = Misc.ssh_run(options[:target], <<-EOF).split("\n").first
174
- require 'rbbt-util'
175
- path = "var/jobs"
176
- resource = #{resource.to_s}
177
- search_path = "#{search_path}"
178
- puts resource[path].find(search_path)
179
- EOF
180
- else
181
- resource['var/jobs'].find(search_path)
182
- end
151
+ EOF
152
+
153
+ [path, paths.collect{|p| [source, p] * ":"}, lpath]
154
+ else
155
+ path = Path.setup(path.dup)
156
+ files = path.glob_all
157
+ files = Step.job_files_for_archive(files, recursive)
158
+
159
+ [path, files, path]
160
+ end
161
+ end
162
+
163
+ def self.migrate(path, search_path, options = {})
164
+ search_path = 'user' if search_path.nil?
165
+
166
+ resource = Rbbt
167
+
168
+ path, real_paths, lpath = self.migrate_source_paths(path, resource, options[:source], options[:recursive])
183
169
 
184
170
  subpath_files = {}
185
- paths.sort.each do |path|
171
+ real_paths.sort.each do |path|
186
172
  parts = path.split("/")
187
173
  subpath = parts[0..-4] * "/" + "/"
188
174
 
@@ -190,73 +176,16 @@ puts resource[path].find(search_path)
190
176
  subpath = subpath_files.keys.last
191
177
  end
192
178
 
193
- source = path[subpath.length..-1]
179
+ source = path.chars[subpath.length..-1] * ""
194
180
 
195
181
  subpath_files[subpath] ||= []
196
182
  subpath_files[subpath] << source
197
183
  end
198
184
 
199
- synced_files = []
200
- subpath_files.each do |subpath, files|
201
- if options[:target]
202
- CMD.cmd("ssh #{options[:target]} mkdir -p '#{File.dirname(target)}'")
203
- else
204
- Open.mkdir File.dirname(target)
205
- end
185
+ target = Rbbt.migrate_target_path('var/jobs', search_path, resource, options[:target])
206
186
 
207
- if options[:source]
208
- source = [options[:source], subpath] * ":"
209
- else
210
- source = subpath
211
- end
212
- target = [options[:target], target] * ":" if options[:target]
213
-
214
- next if File.exists?(source) && File.exists?(target) && File.expand_path(source) == File.expand_path(target)
215
-
216
- files_and_dirs = Set.new( files )
217
- files.each do |file|
218
- synced_files << File.join(subpath, file)
219
-
220
- parts = file.split("/")[0..-2].reject{|p| p.empty?}
221
- while parts.any?
222
- files_and_dirs << parts * "/"
223
- parts.pop
224
- end
225
- end
226
-
227
- TmpFile.with_file(files_and_dirs.sort_by{|l| l.length}.to_a * "\n") do |tmp_include_file|
228
- test_str = options[:test] ? '-nv' : ''
229
-
230
- cmd = "rsync #{MAIN_RSYNC_ARGS} --progress #{test_str} --files-from='#{tmp_include_file}' #{source}/ #{target}/ #{other_rsync_args}"
231
-
232
- #cmd << " && rm -Rf #{source}" if options[:delete]
233
- if options[:print]
234
- ppp Open.read(tmp_include_file)
235
- puts cmd
236
- else
237
- CMD.cmd_log(cmd, :log => Log::INFO)
238
- end
239
- end
240
- end
241
-
242
- if options[:delete] && synced_files.any?
243
- puts Log.color :magenta, "About to erase these files:"
244
- synced_files.each do |p|
245
- puts Log.color :red, p
246
- end
247
-
248
- if options[:non_interactive]
249
- response = 'yes'
250
- else
251
- puts Log.color :magenta, "Type 'yes' if you are sure:"
252
- response = STDIN.gets.chomp
253
- end
254
-
255
- if response == 'yes'
256
- synced_files.each do |p|
257
- Open.rm p
258
- end
259
- end
187
+ subpath_files.each do |subpath, files|
188
+ Rbbt.migrate_files([subpath], target, options.merge(:files => files))
260
189
  end
261
190
  end
262
191
 
@@ -10,6 +10,9 @@ module Workflow
10
10
  started = job.info[:started]
11
11
  ddone = job.info[:done]
12
12
 
13
+ started = Time.parse started if String === started
14
+ ddone = Time.parse ddone if String === ddone
15
+
13
16
  code = [job.workflow, job.task_name].compact.collect{|s| s.to_s} * " · "
14
17
  code = job.name + " - " + code
15
18
 
@@ -140,7 +143,13 @@ rbbt.png_plot('#{plot}', 'plot(timeline)', width=#{width}, height=#{height}, poi
140
143
  info = tasks_info[task] ||= IndiferentHash.setup({})
141
144
  dep_info = IndiferentHash.setup(dep.info)
142
145
 
143
- time = dep_info[:done] - dep_info[:started]
146
+ ddone = dep_info[:done]
147
+ started = dep_info[:started]
148
+
149
+ started = Time.parse started if String === started
150
+ ddone = Time.parse ddone if String === ddone
151
+
152
+ time = ddone - started
144
153
  info[:time] ||= []
145
154
  info[:time] << time
146
155
 
@@ -180,17 +189,23 @@ rbbt.png_plot('#{plot}', 'plot(timeline)', width=#{width}, height=#{height}, poi
180
189
  jobs += step.rec_dependencies + [step]
181
190
  step.info[:archived_info].each do |path,ainfo|
182
191
  archived_step = Step.new path
183
- class << archived_step
184
- self
185
- end.define_method :info do
192
+
193
+ archived_step.define_singleton_method :info do
186
194
  ainfo
187
195
  end
196
+
197
+ #class << archived_step
198
+ # self
199
+ #end.define_method :info do
200
+ # ainfo
201
+ #end
202
+
188
203
  jobs << archived_step
189
204
  end if step.info[:archived_info]
190
205
 
191
206
  end
192
207
 
193
- jobs = jobs.uniq.sort_by{|job| t = job.info[:started]; t || Open.mtime(job.path) || Time.now }
208
+ jobs = jobs.uniq.sort_by{|job| t = job.info[:started] || Open.mtime(job.path) || Time.now; Time === t ? t : Time.parse(t) }
194
209
 
195
210
  data = trace_job_times(jobs, options[:fix_gap])
196
211
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'rbbt-util'
4
4
  require 'rbbt/util/simpleopt'
5
- require 'rbbt/workflow/remote_workflow'
5
+ require 'rbbt/util/migrate'
6
6
 
7
7
  $0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands
8
8
 
@@ -30,83 +30,10 @@ if options[:help]
30
30
  exit 0
31
31
  end
32
32
 
33
- #excludes = %w(.save .crap .source tmp filecache open-remote workflows apps software jobs PCAWG)
34
- excludes = %w(.save .crap .source tmp filecache open-remote)
35
- excludes += (options[:exclude] || "").split(/,\s*/)
36
- excludes_str = excludes.collect{|s| "--exclude '#{s}'" } * " "
37
-
38
- test_str = options[:test] ? '-nv' : ''
39
-
40
33
  path, search_path, _sep, *other = ARGV
41
34
 
42
35
  search_path = 'user' if search_path.nil?
43
- resource = Rbbt
44
-
45
- path, real_paths, lpath = if options[:source]
46
- lpath, *paths = Misc.ssh_run(options[:source], <<-EOF).split("\n")
47
- require 'rbbt-util'
48
- path = "#{path}"
49
- if Open.exists?(path)
50
- path = #{resource.to_s}.identify(path)
51
- else
52
- path = Path.setup(path)
53
- end
54
- puts path
55
- puts path.glob_all.collect{|p| File.directory?(p) ? p + "/" : p } * "\n"
56
- EOF
57
- [path, paths.collect{|p| [options[:source], p] * ":"}, lpath]
58
- else
59
- if File.exists?(path)
60
-
61
- path = resource.identify(path)
62
- else
63
- path = Path.setup(path)
64
- end
65
- [path, path.glob_all, path]
66
- end
67
-
68
- target = if options[:target]
69
- target = Misc.ssh_run(options[:target], <<-EOF).split("\n").first
70
- require 'rbbt-util'
71
- path = "#{path}"
72
- resource = #{resource.to_s}
73
- search_path = "#{search_path}"
74
- puts resource[path].find(search_path)
75
- EOF
76
- else
77
- resource[lpath].find(search_path)
78
- end
79
-
80
- real_paths.each do |source|
81
-
82
-
83
- if File.directory?(source) || source =~ /\/$/
84
- source += "/" unless source[-1] == "/"
85
- target += "/" unless target[-1] == "/"
86
- end
87
36
 
88
- next if source == target
37
+ options[:other] = other
89
38
 
90
- if options[:target]
91
- CMD.cmd("ssh #{options[:target]} mkdir -p '#{File.dirname(target)}'")
92
- else
93
- Open.mkdir File.dirname(target)
94
- end
95
-
96
- if options[:target]
97
- target_path = [options[:target], target] * ":"
98
- else
99
- target_path = target
100
- end
101
-
102
- cmd = "rsync -avztAXHP --copy-unsafe-links #{test_str} #{excludes_str} #{source} #{target_path} #{other * " "}"
103
-
104
- cmd << " && rm -Rf #{source}" if options[:delete]
105
-
106
- if options[:print]
107
- puts cmd
108
- exit 0
109
- else
110
- CMD.cmd_log(cmd, :log => Log::INFO)
111
- end
112
- end
39
+ Rbbt.migrate(path, search_path, options)
@@ -8,9 +8,11 @@ $0 = "rbbt #{$previous_commands*" "} #{ File.basename(__FILE__) }" if $previous_
8
8
 
9
9
  options = SOPT.setup <<EOF
10
10
 
11
- Make a job forget all its dependencies and archive their meta-data
11
+ Make a job forget its dependencies and archive their meta-data
12
12
 
13
- $ #{$0} [options] <job_path>
13
+ $ #{$0} [options] <job_path> [<task_name>|<workflow>#<task_name>] ...
14
+
15
+ Specific dependencies can be specified as . Otherwise, all are forgoten.
14
16
 
15
17
  -h--help Print this help
16
18
  -p--purge Purge dependencies
@@ -26,7 +28,7 @@ if options[:help]
26
28
  exit 0
27
29
  end
28
30
 
29
- path = ARGV[0]
31
+ path, *remove = ARGV
30
32
 
31
33
  raise ParameterException, "No path given" if path.nil?
32
34
  step = Workflow.load_step path
@@ -34,10 +36,20 @@ step = Workflow.load_step path
34
36
  step.archive_deps
35
37
  step.copy_files_dir
36
38
  dependencies = step.dependencies
37
- step.set_info :dependencies, []
38
39
 
39
- if options[:purge]
40
+ if remove && remove.any?
41
+ remove_paths = dependencies.select do |dep|
42
+ remove.include?(dep.task_name) || remove.include?([dep.workflow.to_s, dep.task_name] * "#")
43
+ end.collect{|dep| dep.path }
44
+ else
45
+ remove_paths = dependencies.collect{|dep| dep.path }
46
+ end
47
+
48
+ step.set_info :dependencies, step.info[:dependencies].reject{|info| remove_paths.include? info.last}
49
+
50
+ if options[:purge] || options[:recursive_purge]
40
51
  dependencies.each do |dependency|
52
+ next unless remove_paths.include? dependency.path
41
53
  Step.purge(dependency.path, options[:recursive_purge])
42
54
  end
43
55
  end
@@ -51,7 +51,7 @@ class TestPersistTSVTC < Test::Unit::TestCase
51
51
  end
52
52
  end
53
53
 
54
- def test_annotation_persist_with_repeitions
54
+ def test_annotation_persist_with_repetitions
55
55
  TmpFile.with_file do |tmp|
56
56
  entity1 = "Entity 1"
57
57
  entity2 = "Entity 2"
@@ -0,0 +1,36 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helper.rb')
2
+ require 'rbbt-util'
3
+ require 'rbbt/util/migrate'
4
+
5
+ class TestMigrate < Test::Unit::TestCase
6
+ def _test_source_locate
7
+ assert_equal 'var/jobs/', Rbbt.migrate_source_paths(Rbbt.root['var/jobs'].find(:user)).last
8
+ assert Rbbt.migrate_source_paths(Rbbt.root['var/jobs'].find(:user))[1].include?(File.join(ENV["HOME"], '.rbbt/var/jobs/'))
9
+ end
10
+
11
+ def test_migrate
12
+ Open.rm_rf Rbbt.tmp.test.migration_test.find(:user)
13
+ test_file = Rbbt.tmp.test.migration_test.migration_test_file.find(:user)
14
+ Open.write(test_file, "TEST")
15
+ TmpFile.with_file do |tmpdir|
16
+ Misc.in_dir tmpdir do
17
+ Log.with_severity 0 do
18
+ Rbbt.migrate('tmp/test/migration_test/migration_test_file', :current)
19
+ end
20
+ end
21
+ assert_equal "TEST", Open.read(File.join(tmpdir, 'tmp/test/migration_test/migration_test_file'))
22
+ end
23
+ end
24
+
25
+ def __test_migrate_turbo
26
+ Log.with_severity 0 do
27
+ TmpFile.with_file do |tmpdir|
28
+ Misc.in_dir tmpdir do
29
+ Rbbt.migrate('etc/config', :current, :source => 'mn1')
30
+ end
31
+ assert_equal "TEST", Open.read(File.join(tmpdir, 'etc/config'))
32
+ end
33
+ end
34
+ end
35
+ end
36
+
@@ -0,0 +1,31 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb')
2
+ require 'rbbt-util'
3
+ require 'rbbt/workflow'
4
+ require 'rbbt/workflow/util/archive'
5
+
6
+ module ArchiveTestWF
7
+ extend Workflow
8
+ task :test_archive => :string do
9
+ Open.write(file(:file1), "Test file")
10
+ "TEST"
11
+ end
12
+ end
13
+
14
+ class TestClass < Test::Unit::TestCase
15
+ def test_migrate
16
+ job = ArchiveTestWF.job(:test_archive)
17
+ job.run
18
+
19
+ Log.with_severity 0 do
20
+ TmpFile.with_file do |tmpdir|
21
+ Misc.in_dir tmpdir do
22
+ Step.migrate(job.path, :current, :delete => false, :print => false)
23
+ end
24
+ assert_equal "TEST", Open.read(File.join(tmpdir, 'var/jobs/ArchiveTestWF/test_archive/Default'))
25
+ end
26
+ end
27
+
28
+
29
+ end
30
+ end
31
+
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.32.1
4
+ version: 5.32.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-21 00:00:00.000000000 Z
11
+ date: 2021-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -282,6 +282,7 @@ files:
282
282
  - lib/rbbt/util/log/progress.rb
283
283
  - lib/rbbt/util/log/progress/report.rb
284
284
  - lib/rbbt/util/log/progress/util.rb
285
+ - lib/rbbt/util/migrate.rb
285
286
  - lib/rbbt/util/misc.rb
286
287
  - lib/rbbt/util/misc/annotated_module.rb
287
288
  - lib/rbbt/util/misc/bgzf.rb
@@ -522,6 +523,7 @@ files:
522
523
  - test/rbbt/util/test_excel2tsv.rb
523
524
  - test/rbbt/util/test_filecache.rb
524
525
  - test/rbbt/util/test_log.rb
526
+ - test/rbbt/util/test_migrate.rb
525
527
  - test/rbbt/util/test_misc.rb
526
528
  - test/rbbt/util/test_open.rb
527
529
  - test/rbbt/util/test_procpath.rb
@@ -536,13 +538,14 @@ files:
536
538
  - test/rbbt/workflow/test_schedule.rb
537
539
  - test/rbbt/workflow/test_step.rb
538
540
  - test/rbbt/workflow/test_task.rb
541
+ - test/rbbt/workflow/util/test_archive.rb
539
542
  - test/rbbt/workflow/util/test_orchestrator.rb
540
543
  - test/test_helper.rb
541
544
  homepage: http://github.com/mikisvaz/rbbt-util
542
545
  licenses:
543
546
  - MIT
544
547
  metadata: {}
545
- post_install_message:
548
+ post_install_message:
546
549
  rdoc_options: []
547
550
  require_paths:
548
551
  - lib
@@ -557,101 +560,104 @@ required_rubygems_version: !ruby/object:Gem::Requirement
557
560
  - !ruby/object:Gem::Version
558
561
  version: '0'
559
562
  requirements: []
560
- rubygems_version: 3.1.4
561
- signing_key:
563
+ rubyforge_project:
564
+ rubygems_version: 2.7.6
565
+ signing_key:
562
566
  specification_version: 4
563
567
  summary: Utilities for the Ruby Bioinformatics Toolkit (rbbt)
564
568
  test_files:
569
+ - test/test_helper.rb
570
+ - test/rbbt/entity/test_identifiers.rb
571
+ - test/rbbt/test_resource.rb
572
+ - test/rbbt/test_association.rb
573
+ - test/rbbt/hpc/test_slurm.rb
574
+ - test/rbbt/hpc/test_batch.rb
575
+ - test/rbbt/persist/test_tsv.rb
576
+ - test/rbbt/persist/tsv/test_kyotocabinet.rb
577
+ - test/rbbt/persist/tsv/test_lmdb.rb
578
+ - test/rbbt/persist/tsv/test_tokyocabinet.rb
579
+ - test/rbbt/persist/tsv/test_cdb.rb
580
+ - test/rbbt/persist/tsv/test_leveldb.rb
581
+ - test/rbbt/persist/tsv/test_sharder.rb
582
+ - test/rbbt/test_packed_index.rb
565
583
  - test/rbbt/test_entity.rb
584
+ - test/rbbt/test_fix_width_table.rb
566
585
  - test/rbbt/workflow/test_remote_workflow.rb
567
- - test/rbbt/workflow/util/test_orchestrator.rb
568
586
  - test/rbbt/workflow/test_doc.rb
569
- - test/rbbt/workflow/test_schedule.rb
570
- - test/rbbt/workflow/test_step.rb
571
587
  - test/rbbt/workflow/step/test_dependencies.rb
588
+ - test/rbbt/workflow/test_schedule.rb
589
+ - test/rbbt/workflow/util/test_archive.rb
590
+ - test/rbbt/workflow/util/test_orchestrator.rb
572
591
  - test/rbbt/workflow/test_task.rb
573
- - test/rbbt/resource/test_path.rb
574
- - test/rbbt/util/test_colorize.rb
592
+ - test/rbbt/workflow/test_step.rb
593
+ - test/rbbt/test_tsv.rb
594
+ - test/rbbt/test_annotations.rb
595
+ - test/rbbt/test_knowledge_base.rb
596
+ - test/rbbt/util/test_migrate.rb
597
+ - test/rbbt/util/test_simpleDSL.rb
598
+ - test/rbbt/util/concurrency/processes/test_socket.rb
599
+ - test/rbbt/util/concurrency/test_processes.rb
600
+ - test/rbbt/util/concurrency/test_threads.rb
601
+ - test/rbbt/util/test_filecache.rb
602
+ - test/rbbt/util/simpleopt/test_get.rb
603
+ - test/rbbt/util/simpleopt/test_parse.rb
604
+ - test/rbbt/util/simpleopt/test_setup.rb
605
+ - test/rbbt/util/test_misc.rb
606
+ - test/rbbt/util/test_excel2tsv.rb
607
+ - test/rbbt/util/test_semaphore.rb
575
608
  - test/rbbt/util/test_procpath.rb
576
- - test/rbbt/util/misc/test_development.rb
577
- - test/rbbt/util/misc/test_omics.rb
578
- - test/rbbt/util/misc/test_pipes.rb
579
- - test/rbbt/util/misc/test_format.rb
580
- - test/rbbt/util/misc/test_lock.rb
581
- - test/rbbt/util/misc/test_multipart_payload.rb
582
- - test/rbbt/util/misc/test_bgzf.rb
583
- - test/rbbt/util/test_concurrency.rb
584
- - test/rbbt/util/test_cmd.rb
585
- - test/rbbt/util/R/test_plot.rb
586
- - test/rbbt/util/R/test_eval.rb
587
609
  - test/rbbt/util/R/test_model.rb
610
+ - test/rbbt/util/R/test_eval.rb
611
+ - test/rbbt/util/R/test_plot.rb
612
+ - test/rbbt/util/test_open.rb
613
+ - test/rbbt/util/test_tmpfile.rb
614
+ - test/rbbt/util/test_cmd.rb
615
+ - test/rbbt/util/test_concurrency.rb
616
+ - test/rbbt/util/test_colorize.rb
588
617
  - test/rbbt/util/test_config.rb
589
618
  - test/rbbt/util/test_log.rb
590
- - test/rbbt/util/test_simpleDSL.rb
591
- - test/rbbt/util/log/test_progress.rb
592
- - test/rbbt/util/test_tmpfile.rb
593
- - test/rbbt/util/test_R.rb
594
- - test/rbbt/util/test_excel2tsv.rb
595
- - test/rbbt/util/test_misc.rb
596
- - test/rbbt/util/test_open.rb
597
619
  - test/rbbt/util/test_simpleopt.rb
598
- - test/rbbt/util/simpleopt/test_parse.rb
599
- - test/rbbt/util/simpleopt/test_setup.rb
600
- - test/rbbt/util/simpleopt/test_get.rb
601
620
  - test/rbbt/util/test_python.rb
602
- - test/rbbt/util/test_filecache.rb
603
- - test/rbbt/util/concurrency/test_processes.rb
604
- - test/rbbt/util/concurrency/test_threads.rb
605
- - test/rbbt/util/concurrency/processes/test_socket.rb
606
- - test/rbbt/util/test_semaphore.rb
607
621
  - test/rbbt/util/test_chain_methods.rb
608
- - test/rbbt/test_resource.rb
609
- - test/rbbt/test_packed_index.rb
610
- - test/rbbt/tsv/test_change_id.rb
611
- - test/rbbt/tsv/test_attach.rb
612
- - test/rbbt/tsv/test_filter.rb
622
+ - test/rbbt/util/misc/test_omics.rb
623
+ - test/rbbt/util/misc/test_lock.rb
624
+ - test/rbbt/util/misc/test_multipart_payload.rb
625
+ - test/rbbt/util/misc/test_bgzf.rb
626
+ - test/rbbt/util/misc/test_development.rb
627
+ - test/rbbt/util/misc/test_format.rb
628
+ - test/rbbt/util/misc/test_pipes.rb
629
+ - test/rbbt/util/log/test_progress.rb
630
+ - test/rbbt/util/test_R.rb
631
+ - test/rbbt/test_workflow.rb
632
+ - test/rbbt/knowledge_base/test_entity.rb
633
+ - test/rbbt/knowledge_base/test_enrichment.rb
634
+ - test/rbbt/knowledge_base/test_traverse.rb
635
+ - test/rbbt/knowledge_base/test_syndicate.rb
636
+ - test/rbbt/knowledge_base/test_registry.rb
637
+ - test/rbbt/knowledge_base/test_query.rb
638
+ - test/rbbt/association/test_item.rb
639
+ - test/rbbt/association/test_util.rb
640
+ - test/rbbt/association/test_open.rb
641
+ - test/rbbt/association/test_database.rb
642
+ - test/rbbt/association/test_index.rb
643
+ - test/rbbt/annotations/test_util.rb
644
+ - test/rbbt/test_monitor.rb
645
+ - test/rbbt/resource/test_path.rb
646
+ - test/rbbt/test_hpc.rb
647
+ - test/rbbt/test_persist.rb
613
648
  - test/rbbt/tsv/test_parser.rb
614
649
  - test/rbbt/tsv/test_csv.rb
615
- - test/rbbt/tsv/test_accessor.rb
616
- - test/rbbt/tsv/test_matrix.rb
650
+ - test/rbbt/tsv/test_manipulate.rb
617
651
  - test/rbbt/tsv/test_field_index.rb
618
652
  - test/rbbt/tsv/test_util.rb
619
- - test/rbbt/tsv/test_index.rb
653
+ - test/rbbt/tsv/test_accessor.rb
654
+ - test/rbbt/tsv/test_filter.rb
655
+ - test/rbbt/tsv/test_stream.rb
620
656
  - test/rbbt/tsv/test_parallel.rb
621
- - test/rbbt/tsv/test_manipulate.rb
657
+ - test/rbbt/tsv/test_matrix.rb
658
+ - test/rbbt/tsv/test_attach.rb
622
659
  - test/rbbt/tsv/test_excel.rb
623
- - test/rbbt/tsv/parallel/test_through.rb
660
+ - test/rbbt/tsv/test_change_id.rb
661
+ - test/rbbt/tsv/test_index.rb
624
662
  - test/rbbt/tsv/parallel/test_traverse.rb
625
- - test/rbbt/tsv/test_stream.rb
626
- - test/rbbt/test_association.rb
627
- - test/rbbt/hpc/test_batch.rb
628
- - test/rbbt/hpc/test_slurm.rb
629
- - test/rbbt/association/test_database.rb
630
- - test/rbbt/association/test_item.rb
631
- - test/rbbt/association/test_open.rb
632
- - test/rbbt/association/test_util.rb
633
- - test/rbbt/association/test_index.rb
634
- - test/rbbt/test_knowledge_base.rb
635
- - test/rbbt/persist/tsv/test_kyotocabinet.rb
636
- - test/rbbt/persist/tsv/test_cdb.rb
637
- - test/rbbt/persist/tsv/test_lmdb.rb
638
- - test/rbbt/persist/tsv/test_sharder.rb
639
- - test/rbbt/persist/tsv/test_leveldb.rb
640
- - test/rbbt/persist/tsv/test_tokyocabinet.rb
641
- - test/rbbt/persist/test_tsv.rb
642
- - test/rbbt/test_tsv.rb
643
- - test/rbbt/test_annotations.rb
644
- - test/rbbt/test_fix_width_table.rb
645
- - test/rbbt/test_workflow.rb
646
- - test/rbbt/entity/test_identifiers.rb
647
- - test/rbbt/annotations/test_util.rb
648
- - test/rbbt/test_hpc.rb
649
- - test/rbbt/test_monitor.rb
650
- - test/rbbt/test_persist.rb
651
- - test/rbbt/knowledge_base/test_entity.rb
652
- - test/rbbt/knowledge_base/test_registry.rb
653
- - test/rbbt/knowledge_base/test_syndicate.rb
654
- - test/rbbt/knowledge_base/test_query.rb
655
- - test/rbbt/knowledge_base/test_enrichment.rb
656
- - test/rbbt/knowledge_base/test_traverse.rb
657
- - test/test_helper.rb
663
+ - test/rbbt/tsv/parallel/test_through.rb