1 module PipelineInstancesHelper
3 if @object.components[:steps].is_a? Array
4 pipeline_jobs_oldschool
5 elsif @object.components.is_a? Hash
6 pipeline_jobs_newschool
12 def pipeline_jobs_newschool
15 @object.components.each do |cname, c|
17 pj = {index: i, name: cname}
18 pj[:job] = c[:job].is_a?(Hash) ? c[:job] : {}
20 pj[:percent_running] = 0
24 pj[:percent_done] = 100
29 if pj[:job][:tasks_summary]
31 ts = pj[:job][:tasks_summary]
32 denom = ts[:done].to_f + ts[:running].to_f + ts[:todo].to_f
33 pj[:progress] = (ts[:done].to_f + ts[:running].to_f/2) / denom
34 pj[:percent_done] = 100.0 * ts[:done].to_f / denom
35 pj[:percent_running] = 100.0 * ts[:running].to_f / denom
36 pj[:progress_detail] = "#{ts[:done]} done #{ts[:running]} run #{ts[:todo]} todo"
39 pj[:percent_done] = 0.0
40 pj[:percent_running] = 100.0
48 pj[:result] = 'complete'
51 elsif pj[:job][:finished_at]
52 pj[:result] = 'failed'
54 elsif pj[:job][:started_at]
55 pj[:result] = 'running'
57 pj[:result] = 'queued'
60 pj[:job_id] = pj[:job][:uuid]
61 pj[:job_link] = link_to_if_arvados_object pj[:job][:uuid]
62 pj[:script_version] = pj[:job][:script_version]
63 pj[:output] = pj[:job][:output]
64 pj[:finished_at] = (Time.parse(pj[:job][:finished_at]) rescue nil)
65 pj[:progress_bar] = raw("<div class=\"progress\" style=\"width:100px\"><div class=\"bar bar-success\" style=\"width:#{pj[:percent_done]}%\"></div><div class=\"bar\" style=\"width:#{pj[:percent_running]}%\"></div></div>")
66 pj[:output_link] = link_to_if_arvados_object pj[:output]
72 def pipeline_jobs_oldschool
74 @object.components[:steps].each_with_index do |step, i|
75 pj = {index: i, name: step[:name]}
76 if step[:complete] and step[:complete] != 0
77 if step[:output_data_locator]
83 if step[:progress] and
84 (re = step[:progress].match /^(\d+)\+(\d+)\/(\d+)$/)
85 pj[:progress] = (((re[1].to_f + re[2].to_f/2) / re[3].to_f) rescue 0.5)
90 pj[:result] = 'failed'
94 if step[:warehousejob]
96 pj[:result] = 'complete'
99 elsif step[:warehousejob][:finishtime]
100 pj[:result] = 'failed'
102 elsif step[:warehousejob][:starttime]
103 pj[:result] = 'running'
105 pj[:result] = 'queued'
108 pj[:progress_detail] = (step[:progress] rescue nil)
109 pj[:job_id] = (step[:warehousejob][:id] rescue nil)
110 pj[:job_link] = pj[:job_id]
111 pj[:script] = step[:function]
112 pj[:script_version] = (step[:warehousejob][:revision] rescue nil)
113 pj[:output] = step[:output_data_locator]
114 pj[:finished_at] = (Time.parse(step[:warehousejob][:finishtime]) rescue nil)
115 pj[:progress_bar] = raw("<div class=\"progress\" style=\"width:100px\"><div class=\"bar\" style=\"width:#{pj[:progress]*100}%\"></div></div>")
116 pj[:output_link] = link_to_if_arvados_object pj[:output]