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