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