Merge branch 'master' into 6219-fuse-performance-testing
[arvados.git] / apps / workbench / app / views / pipeline_instances / _show_components_running.html.erb
1 <%# Summary %>
2
3 <div class="pull-right" style="padding-left: 1em">
4   Current state: <span class="badge badge-info" data-pipeline-state="<%= @object.state %>">
5     <% if @object.state == "RunningOnServer" %>
6       Active
7     <% else %>
8       <%= @object.state %>
9     <% end %>
10   </span>&nbsp;
11 </div>
12
13 <% pipeline_jobs = render_pipeline_jobs %>
14 <% job_uuids = pipeline_jobs.map { |j| j[:job].andand[:uuid] }.compact %>
15 <% job_uuids_finished = {}; pipeline_jobs.map { |j| job_uuids_finished[j[:job].andand[:uuid]] = j[:job].andand[:finished_at] } %>
16
17 <% if @object.state == 'Paused' %>
18   <p>
19     This pipeline is paused.  Jobs that are
20     already running will continue to run, but no new jobs will be submitted.
21   </p>
22 <% end %>
23
24 <% tasks = JobTask.filter([['job_uuid', 'in', job_uuids]]).results %>
25 <% runningtime = determine_wallclock_runtime(pipeline_jobs.map {|j| j[:job]}.compact) %>
26
27 <p>
28   <% if @object.started_at %>
29     This pipeline started at <%= render_localized_date(@object.started_at) %>.
30     It
31     <% if @object.state == 'Complete' %>
32       completed in
33     <% elsif @object.state == 'Failed' %>
34       failed after
35     <% else %>
36       has been active for
37     <% end %>
38
39     <% walltime = if @object.finished_at then
40                     @object.finished_at - @object.started_at
41                   else
42                     Time.now - @object.started_at
43                   end %>
44
45     <%= if walltime > runningtime
46           render_runtime(walltime, true, false)
47         else
48           render_runtime(runningtime, true, false)
49         end %><% if @object.finished_at %> at <%= render_localized_date(@object.finished_at) %><% end %>.
50     <% else %>
51       This pipeline is <%= if @object.state.start_with? 'Running' then 'active' else @object.state.downcase end %>.
52         <% walltime = 0%>
53     <% end %>
54
55   <% if @object.state == 'Failed' %>
56     Check the Log tab for more detail about why this pipeline failed.
57   <% end %>
58 </p>
59
60 <p>
61     This pipeline
62     <% if @object.state.start_with? 'Running' %>
63       has run
64     <% else %>
65       ran
66     <% end %>
67     for
68     <% cputime = tasks.map { |task|
69         if task.started_at
70           finished_at = task.finished_at || job_uuids_finished[task.job_uuid] || Time.now()
71           finished_at - task.started_at
72         else
73           0
74         end
75        }.reduce(:+) || 0 %>
76     <%= render_runtime(runningtime, true, false) %><% if (walltime - runningtime) > 0 %>
77       (<%= render_runtime(walltime - runningtime, true, false) %> queued)<% end %><% if cputime == 0 %>.<% else %>
78       and used
79     <%= render_runtime(cputime, true, false) %>
80     of CPU time (<%= (cputime/runningtime).round(1) %>&Cross; scaling).
81     <% end %>
82 </p>
83
84 <%# Components %>
85
86 <%
87   job_uuids = pipeline_jobs.collect {|j| j[:job][:uuid]}.compact
88   if job_uuids.any?
89     resource_class = resource_class_for_uuid(job_uuids.first, friendly_name: true)
90     preload_objects_for_dataclass resource_class, job_uuids
91   end
92
93   job_collections = pipeline_jobs.collect {|j| j[:job][:output]}.compact
94   job_collections.concat pipeline_jobs.collect {|j| j[:job][:docker_image_locator]}.uniq.compact
95   job_collections_pdhs = job_collections.select {|x| !(m = CollectionsHelper.match(x)).nil?}.uniq.compact
96   job_collections_uuids = job_collections - job_collections_pdhs
97   preload_collections_for_objects job_collections_uuids if job_collections_uuids.any?
98   preload_for_pdhs job_collections_pdhs if job_collections_pdhs.any?
99 %>
100
101 <% pipeline_jobs.each_with_index do |pj, i| %>
102   <%= render partial: 'running_component', locals: {tasks: tasks, pj: pj, i: i, expanded: false} %>
103 <% end %>