share/rbbt_commands/workflow/prov in rbbt-util-5.25.38 vs share/rbbt_commands/workflow/prov in rbbt-util-5.25.39
- old
+ new
@@ -4,10 +4,11 @@
require 'rbbt-util'
require 'fileutils'
require 'rbbt/util/simpleopt'
require 'rbbt/workflow/step'
+require 'rbbt/workflow/provenance'
require 'rbbt/util/misc'
require 'rbbt-util'
require 'rbbt/util/simpleopt'
@@ -38,78 +39,10 @@
file = file.sub(/\.(info|files)/,'')
$seen << file
Workflow.load_step file
end
-def status_msg(status)
- color = case status.to_sym
- when :error, :aborted, :missing, :dead
- :red
- when :streaming, :started
- :cyan
- when :done
- :green
- when :noinfo
- :blue
- when :dependencies, :waiting, :setyp
- :yellow
- else
- if status.to_s.index ">"
- :cyan
- else
- :cyan
- end
- end
- Log.color(color, status.to_s)
-end
-
-def report_msg(status, name, path, info = nil)
- parts = path.sub(/\{.*/,'').sub(/#{Regexp.quote(name)}$/,'').split "/"
-
- task = Log.color(:yellow, parts.pop)
- workflow = Log.color(:magenta, parts.pop)
- if status.to_s == 'noinfo' and parts.last != 'jobs'
- task, status, workflow = Log.color(:yellow, info[:task_name]), Log.color(:blue, "file"), Log.color(:magenta, "-")
- end
-
- path_mtime = begin
- Open.mtime(path)
- rescue
- nil
- end
- str = if not Open.remote?(path) and (Open.exists?(path) and $main_mtime and path_mtime and ($main_mtime - path_mtime) < -2)
- iii [path, path_mtime, $main_mtime, $main_mtime - path_mtime]
- status_msg(status.to_s) << " " << [workflow, task, path].compact * " " << " (#{Log.color(:red, "Mtime out of sync") })"
- else
- status_msg(status.to_s) << " " << [workflow, task, path].compact * " "
- end
-
- if $inputs and $inputs.any?
- job_inputs = Workflow.load_step(path).recursive_inputs.to_hash
- IndiferentHash.setup(job_inputs)
-
- $inputs.each do |input|
- value = job_inputs[input]
- next if value.nil?
- value_str = Misc.fingerprint(value)
- str << "\t#{Log.color :magenta, input}=#{value_str}"
- end
- end
-
- if $info_fields and $info_fields.any?
- $info_fields.each do |field|
- IndiferentHash.setup(info)
- value = info[field]
- next if value.nil?
- value_str = Misc.fingerprint(value)
- str << "\t#{Log.color :magenta, field}=#{value_str}"
- end
- end
-
- str << "\n"
-end
-
def touch(step)
return unless File.exists?(step.path)
step.dependencies.each do |dep|
next unless Open.exists?(dep.path)
if Open.mtime(dep.path) > Open.mtime(step.path) + 1
@@ -118,33 +51,10 @@
end
touch(dep)
end if step.dependencies
end
-def report(step, offset = 0, task = nil)
- info = step.info || {}
- info[:task_name] = task
- path = step.path
- status = info[:status] || :missing
- status = "remote" if Open.remote?(path)
- name = info[:name] || File.basename(path)
- status = :unsync if status == :done and not Open.exist? path
- str = " " * offset
- str << report_msg(status, name, path, info)
- step.dependencies.each do |dep|
- path = dep.path
- new = ! $seen.include?(path)
- if new
- $seen << path
- str << report(dep, offset + 1, task)
- else
- str << Log.color(:blue, Log.uncolor(report(dep, offset+1, task)))
- end
- end if step.dependencies
- str
-end
-
step = get_step file
$main_mtime = Open.exist?(step.path) ? Open.mtime(step.path) : nil
def adjacency(step)
@@ -218,8 +128,8 @@
EOF
end
end
else
- puts report(step).strip
+ puts Step.prov_report(step).strip
end