rbbt-util 5.23.35 → 5.23.36
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 +4 -4
- data/lib/rbbt/monitor.rb +34 -7
- data/lib/rbbt/persist/tsv/adapter.rb +0 -2
- data/lib/rbbt/util/open.rb +24 -8
- data/lib/rbbt/workflow/archive.rb +1 -1
- data/share/rbbt_commands/system/clean +2 -2
- data/share/rbbt_commands/system/status +48 -17
- data/share/rbbt_commands/workflow/prov +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a48bd703a6bcf70e3b03ea0a80df3d9e419d2a5d
|
4
|
+
data.tar.gz: e5ddc970668f140bd1923ce200b2754d352c8e61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2023508ca619102a57ecc4927e08b97c14b2429cea38c57e14c75ce743006772080ab8daad7e7d17a721a11646da7806a9376dbb17e6f25686129418b2fa04db
|
7
|
+
data.tar.gz: 5439545d3471476c701f42c133398d8211bb1cfd5adc4a6d802954ece07fb0a509d0f0c59fa07085f9b7f4ec6097390d9c0cd527e2c90ff735eca8d7e84c0ad4
|
data/lib/rbbt/monitor.rb
CHANGED
@@ -138,18 +138,45 @@ module Rbbt
|
|
138
138
|
dirs.collect do |dir|
|
139
139
|
next unless Open.exists? dir
|
140
140
|
|
141
|
-
|
141
|
+
workflowdirs = if (dir_sub_path = Open.find_repo_dir(workflowdir))
|
142
|
+
repo_dir, sub_path = dir_sub_path
|
143
|
+
Open.list_repo_files(*dir_sub_path).collect{|f| f.split("/").first}.uniq.collect{|f| File.join(repo_dir, f)}.uniq
|
144
|
+
else
|
145
|
+
dir.glob("*")
|
146
|
+
end
|
147
|
+
|
148
|
+
workflowdirs.collect do |workflowdir|
|
142
149
|
workflow = File.basename(workflowdir)
|
143
150
|
next if workflows and not workflows.include? workflow
|
144
151
|
|
145
|
-
|
152
|
+
tasks_dirs = if (dir_sub_path = Open.find_repo_dir(workflowdir))
|
153
|
+
repo_dir, sub_path = dir_sub_path
|
154
|
+
Open.list_repo_files(*dir_sub_path).collect{|f| f.split("/").first}.uniq.collect{|f| File.join(repo_dir, f)}.uniq
|
155
|
+
else
|
156
|
+
workflowdir.glob("*")
|
157
|
+
end
|
158
|
+
|
159
|
+
tasks_dirs.collect do |taskdir|
|
146
160
|
task = File.basename(taskdir)
|
147
161
|
next if tasks and not tasks.include? task
|
148
162
|
|
149
|
-
#cmd = "find -L '#{ taskdir }/' -not \\( -path \"#{taskdir}/*.files/*\" -prune \\) -not -name '*.pid' -not -name '*.notify' -not -name '\\.*' 2>/dev/null"
|
150
|
-
cmd = "find -L '#{ taskdir }/' -not \\( -path \"#{taskdir}/.info/*\" -prune \\) -not \\( -path \"#{taskdir}/*.files/*\" -prune \\) -not -name '*.pid' -not -name '*.notify' -not -name '\\.*' \\( -not -type d -o -name '*.files' \\) 2>/dev/null"
|
151
163
|
|
152
|
-
files =
|
164
|
+
files = if (dir_sub_path = Open.find_repo_dir(taskdir))
|
165
|
+
repo_dir, sub_path = dir_sub_path
|
166
|
+
Open.list_repo_files(*dir_sub_path).reject do |f|
|
167
|
+
f.include?("/.info/") ||
|
168
|
+
f.include?(".files/") ||
|
169
|
+
f.include?(".pid/") ||
|
170
|
+
File.directory?(f)
|
171
|
+
end.collect do |f|
|
172
|
+
File.join(repo_dir, f)
|
173
|
+
end
|
174
|
+
else
|
175
|
+
#cmd = "find -L '#{ taskdir }/' -not \\( -path \"#{taskdir}/*.files/*\" -prune \\) -not -name '*.pid' -not -name '*.notify' -not -name '\\.*' 2>/dev/null"
|
176
|
+
cmd = "find -L '#{ taskdir }/' -not \\( -path \"#{taskdir}/.info/*\" -prune \\) -not \\( -path \"#{taskdir}/*.files/*\" -prune \\) -not -name '*.pid' -not -name '*.notify' -not -name '\\.*' \\( -not -type d -o -name '*.files' \\) 2>/dev/null"
|
177
|
+
|
178
|
+
CMD.cmd(cmd, :pipe => true)
|
179
|
+
end
|
153
180
|
TSV.traverse files, :type => :array, :into => jobs, :_bar => "Finding jobs in #{ taskdir }" do |file|
|
154
181
|
_files << file
|
155
182
|
if m = file.match(/(.*)\.(info|pid|files)$/)
|
@@ -167,10 +194,10 @@ module Rbbt
|
|
167
194
|
info[:task] = task
|
168
195
|
info[:name] = name
|
169
196
|
|
170
|
-
if
|
197
|
+
if Open.exists? file
|
171
198
|
info = info.merge(file_time(file))
|
172
199
|
info[:done] = true
|
173
|
-
info[:info_file] =
|
200
|
+
info[:info_file] = Open.exist?(info_file) ? info_file : nil
|
174
201
|
else
|
175
202
|
info = info.merge({:info_file => info_file, :done => false})
|
176
203
|
end
|
data/lib/rbbt/util/open.rb
CHANGED
@@ -207,6 +207,15 @@ module Open
|
|
207
207
|
end
|
208
208
|
end
|
209
209
|
|
210
|
+
def self.list_repo_files(dir, sub_path = nil)
|
211
|
+
repo = get_repo_from_dir(dir)
|
212
|
+
files = repo.keys
|
213
|
+
files.reject!{|f| f[0] == "."}
|
214
|
+
return files unless sub_path
|
215
|
+
|
216
|
+
files.select{|file| file.start_with?(sub_path) }
|
217
|
+
end
|
218
|
+
|
210
219
|
def self.exists_in_repo(dir, sub_path, content)
|
211
220
|
repo = get_repo_from_dir(dir)
|
212
221
|
repo.read_and_close do
|
@@ -219,7 +228,7 @@ module Open
|
|
219
228
|
dir = dir + '/' unless dir.chars[-1] == "/"
|
220
229
|
|
221
230
|
begin
|
222
|
-
if file.start_with? dir
|
231
|
+
if file.start_with?(dir) || file == dir[0..-2]
|
223
232
|
sub_path = file.to_s[dir.length..-1]
|
224
233
|
return [dir, sub_path]
|
225
234
|
else
|
@@ -376,10 +385,12 @@ module Open
|
|
376
385
|
repo_source = get_repo_from_dir(dir_sub_path_source[0])
|
377
386
|
repo_target = get_repo_from_dir(dir_sub_path_target[0])
|
378
387
|
|
379
|
-
repo_source.read_and_close do
|
380
|
-
repo_target
|
381
|
-
|
382
|
-
|
388
|
+
content = repo_source.read_and_close do
|
389
|
+
repo_target[dir_sub_path_target[1]]
|
390
|
+
end
|
391
|
+
|
392
|
+
repo_target.write_and_close do
|
393
|
+
repo_source[dir_sub_path_source[1]] = content
|
383
394
|
end
|
384
395
|
|
385
396
|
return nil
|
@@ -410,10 +421,15 @@ module Open
|
|
410
421
|
repo_source = get_repo_from_dir(dir_sub_path_source[0])
|
411
422
|
repo_target = get_repo_from_dir(dir_sub_path_target[0])
|
412
423
|
|
424
|
+
content = repo_source.read_and_close do
|
425
|
+
repo_target[dir_sub_path_target[1]]
|
426
|
+
end
|
427
|
+
|
428
|
+
repo_target.write_and_close do
|
429
|
+
repo_source[dir_sub_path_source[1]] = content
|
430
|
+
end
|
431
|
+
|
413
432
|
repo_source.write_and_close do
|
414
|
-
repo_target.write_and_close do
|
415
|
-
repo_source[dir_sub_path_source[1]] = repo_target[dir_sub_path_target[1]]
|
416
|
-
end
|
417
433
|
repo_source.delete dir_sub_path_source[1]
|
418
434
|
end
|
419
435
|
|
@@ -9,7 +9,7 @@ class Step
|
|
9
9
|
return if target_dir[workflow][task][name].exists? || File.symlink?(target_dir[workflow][task][name].find)
|
10
10
|
Log.debug "Linking #{ path }"
|
11
11
|
FileUtils.mkdir_p target_dir[workflow][task] unless target_dir[workflow][task].exists?
|
12
|
-
FileUtils.ln_s path, target_dir[workflow][task][name].find
|
12
|
+
FileUtils.ln_s path, target_dir[workflow][task][name].find if File.exists?(path)
|
13
13
|
FileUtils.ln_s path + '.files', target_dir[workflow][task][name].find + '.files' if File.exists?(path + '.files')
|
14
14
|
FileUtils.ln_s path + '.info', target_dir[workflow][task][name].find + '.info' if File.exists?(path + '.info')
|
15
15
|
end
|
@@ -118,8 +118,8 @@ TSV.traverse jobs, :_bar => "Checking job status" do |file,i|
|
|
118
118
|
status = status.to_s
|
119
119
|
end
|
120
120
|
|
121
|
-
if time and
|
122
|
-
old = Time.now -
|
121
|
+
if time and Open.exists?(file)
|
122
|
+
old = Time.now - Open.atime(file)
|
123
123
|
if old > time
|
124
124
|
status = 'old'
|
125
125
|
end
|
@@ -67,6 +67,35 @@ def status_msg(status)
|
|
67
67
|
end
|
68
68
|
Log.color(color, status.to_s)
|
69
69
|
end
|
70
|
+
|
71
|
+
def input_msg(file, inputs)
|
72
|
+
|
73
|
+
str = ""
|
74
|
+
job_inputs = Workflow.load_step(file).recursive_inputs.to_hash
|
75
|
+
IndiferentHash.setup(job_inputs)
|
76
|
+
|
77
|
+
inputs.each do |input|
|
78
|
+
value = job_inputs[input]
|
79
|
+
next if value.nil?
|
80
|
+
value_str = Misc.fingerprint(value)
|
81
|
+
str << "\t#{Log.color :magenta, input}=#{value_str}"
|
82
|
+
end
|
83
|
+
str
|
84
|
+
end
|
85
|
+
|
86
|
+
def info_msg(info, info_fields)
|
87
|
+
|
88
|
+
str = ""
|
89
|
+
info_fields.each do |field|
|
90
|
+
value = info[field]
|
91
|
+
next if value.nil?
|
92
|
+
value_str = Misc.fingerprint(value)
|
93
|
+
str << "\t#{Log.color :magenta, field}=#{value_str}"
|
94
|
+
end
|
95
|
+
str
|
96
|
+
end
|
97
|
+
|
98
|
+
|
70
99
|
puts Log.color(:magenta, "# System report")
|
71
100
|
puts
|
72
101
|
sort_files = Proc.new do |a,b|
|
@@ -143,6 +172,21 @@ workflows.sort.each do |workflow,tasks|
|
|
143
172
|
if options[:quick] and i[:done]
|
144
173
|
status = 'done'
|
145
174
|
str << " #{ status_msg status }"
|
175
|
+
if inputs and inputs.any?
|
176
|
+
str << input_msg(file, inputs)
|
177
|
+
end
|
178
|
+
|
179
|
+
if info_fields and info_fields.any?
|
180
|
+
info = begin
|
181
|
+
Open.open(i[:info_file]) do |f|
|
182
|
+
Step::INFO_SERIALIAZER.load(f)
|
183
|
+
end
|
184
|
+
rescue
|
185
|
+
{:status => :noinfo}
|
186
|
+
end
|
187
|
+
IndiferentHash.setup(info)
|
188
|
+
str << info_msg(info, info_fields)
|
189
|
+
end
|
146
190
|
else
|
147
191
|
info = begin
|
148
192
|
Open.open(i[:info_file]) do |f|
|
@@ -155,7 +199,7 @@ workflows.sort.each do |workflow,tasks|
|
|
155
199
|
|
156
200
|
pid = info[:pid]
|
157
201
|
status = info[:status]
|
158
|
-
status = :missing if status == :done and not
|
202
|
+
status = :missing if status == :done and not Open.exist? file
|
159
203
|
status = status.to_s
|
160
204
|
if status != "done" and pid and not Misc.pid_exists?(pid)
|
161
205
|
if File.exist? file
|
@@ -167,25 +211,12 @@ workflows.sort.each do |workflow,tasks|
|
|
167
211
|
str << " #{ status_msg status }"
|
168
212
|
str << " (dirty)" if status == 'done' && Workflow.load_step(file).dirty?
|
169
213
|
|
170
|
-
if inputs and inputs.any?
|
171
|
-
|
172
|
-
IndiferentHash.setup(job_inputs)
|
173
|
-
|
174
|
-
inputs.each do |input|
|
175
|
-
value = job_inputs[input]
|
176
|
-
next if value.nil?
|
177
|
-
value_str = Misc.fingerprint(value)
|
178
|
-
str << "\t#{Log.color :magenta, input}=#{value_str}"
|
179
|
-
end
|
214
|
+
if inputs and inputs.any?
|
215
|
+
str << input_msg(file, inputs)
|
180
216
|
end
|
181
217
|
|
182
218
|
if info_fields and info_fields.any?
|
183
|
-
|
184
|
-
value = info[field]
|
185
|
-
next if value.nil?
|
186
|
-
value_str = Misc.fingerprint(value)
|
187
|
-
str << "\t#{Log.color :magenta, field}=#{value_str}"
|
188
|
-
end
|
219
|
+
str << info_msg(info, info_fields)
|
189
220
|
end
|
190
221
|
end
|
191
222
|
str << "; #{pid_msg pid}" unless status == "done"
|
@@ -22,6 +22,7 @@ $ rbbt workflow prov <job-result>
|
|
22
22
|
-p--plot* draw the dependency plot into <file.png>
|
23
23
|
-i--inputs* List of inputs to print
|
24
24
|
-if--info_fields* List of info fields to print
|
25
|
+
-t--touch Update modification times to be consistent
|
25
26
|
EOF
|
26
27
|
|
27
28
|
SOPT.usage if options[:help]
|
@@ -106,6 +107,18 @@ def report_msg(status, name, path, info = nil)
|
|
106
107
|
str << "\n"
|
107
108
|
end
|
108
109
|
|
110
|
+
def touch(step)
|
111
|
+
return unless File.exists?(step.path)
|
112
|
+
step.dependencies.each do |dep|
|
113
|
+
next unless Open.exists?(dep.path)
|
114
|
+
touch(dep)
|
115
|
+
if Open.mtime(step.path) < Open.mtime(dep.path)
|
116
|
+
Log.debug("Updating #{step.path} to #{dep.path}")
|
117
|
+
CMD.cmd("touch -r '#{dep.path}' '#{step.path}'")
|
118
|
+
end
|
119
|
+
end if step.dependencies
|
120
|
+
end
|
121
|
+
|
109
122
|
def report(step, offset = 0, task = nil)
|
110
123
|
info = step.info || {}
|
111
124
|
info[:task_name] = task
|
@@ -164,6 +177,10 @@ def adjacency(step)
|
|
164
177
|
[id, edges, node_info]
|
165
178
|
end
|
166
179
|
|
180
|
+
if options[:touch]
|
181
|
+
touch(step)
|
182
|
+
end
|
183
|
+
|
167
184
|
if options[:plot]
|
168
185
|
id, edges, node_info = adjacency(step)
|
169
186
|
node_info[id][:color] = 'red'
|
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.23.
|
4
|
+
version: 5.23.36
|
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-11-
|
11
|
+
date: 2018-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|