18562: Add upgrade note about new config key.
[arvados.git] / apps / workbench / app / views / pipeline_instances / _running_component.html.erb
1 <%# Copyright (C) The Arvados Authors. All rights reserved.
2
3 SPDX-License-Identifier: AGPL-3.0 %>
4
5 <% current_job = pj[:job] if pj[:job] != {} and pj[:job][:uuid] %>
6 <div class="panel panel-default">
7   <div class="panel-heading">
8     <div class="container-fluid">
9       <div class="row-fluid">
10         <%# column offset 0 %>
11         <div class="col-md-2" style="word-break:break-all;">
12           <h4 class="panel-title">
13             <a data-toggle="collapse" href="#collapse<%= i %>">
14               <%= pj[:name] %> <span class="caret"></span>
15             </a>
16           </h4>
17         </div>
18
19         <%# column offset 2 %>
20         <div class="col-md-2 pipeline-instance-spacing">
21           <%= pj[:progress_bar] %>
22         </div>
23
24         <%# column offset 4 %>
25         <% if not current_job %>
26           <div class="col-md-8"></div>
27         <% else %>
28           <div class="col-md-1">
29             <% if (pipeline_display rescue nil) %>
30               <% if current_job[:state].in? ["Complete", "Failed", "Cancelled"] %>
31                 <% if current_job[:log] %>
32                   <% logCollection = Collection.find? current_job[:log] %>
33                   <% if logCollection %>
34                     <%= link_to "Log", job_path(current_job[:uuid], anchor: "Log") %>
35                   <% else %>
36                     Log unavailable
37                   <% end %>
38                 <% end %>
39               <% elsif current_job[:state] == "Running" %>
40                 <% job = Job.find? current_job[:uuid] %>
41                 <% if job %>
42                   <%= link_to "Log", job_path(current_job[:uuid], anchor: "Log") %>
43                 <% else %>
44                   Log unavailable
45                 <% end %>
46               <% end %>
47             <% end %>
48           </div>
49
50           <%# column offset 5 %>
51           <% if current_job[:state] != "Queued" %>
52           <div class="col-md-3">
53             <% if current_job[:started_at] %>
54               <% walltime = ((if current_job[:finished_at] then current_job[:finished_at] else Time.now() end) - current_job[:started_at]) %>
55               <% cputime = (current_job[:runtime_constraints].andand[:min_nodes] || 1).to_i *
56                            ((current_job[:finished_at] || Time.now()) - current_job[:started_at]) %>
57               <%= render_runtime(walltime, false) %>
58               <% if cputime > 0 %> / <%= render_runtime(cputime, false) %> (<%= (cputime/walltime).round(1) %>&Cross;)<% end %>
59             <% end %>
60           </div>
61           <% end %>
62
63           <% if current_job[:state] == "Queued" %>
64             <%# column offset 5 %>
65             <div class="col-md-6">
66               <% queuetime = Time.now - Time.parse(current_job[:created_at].to_s) %>
67               Queued for <%= render_runtime(queuetime, false) %>.
68             </div>
69           <% elsif current_job[:state] == "Running" %>
70             <%# column offset 8 %>
71             <div class="col-md-3">
72               <span class="task-summary-status">
73                 <%= current_job[:tasks_summary][:done] %>&nbsp;<%= "task".pluralize(current_job[:tasks_summary][:done]) %> done,
74                 <%= current_job[:tasks_summary][:failed] %>&nbsp;failed,
75                 <%= current_job[:tasks_summary][:running] %>&nbsp;running,
76                 <%= current_job[:tasks_summary][:todo] %>&nbsp;pending
77               </span>
78             </div>
79           <% elsif current_job[:state].in? ["Complete", "Failed", "Cancelled"] %>
80             <%# column offset 8 %>
81             <div class="col-md-4 text-overflow-ellipsis">
82               <% if pj[:output_uuid] %>
83                 <%= link_to_arvados_object_if_readable(pj[:output_uuid], "#{pj[:output_uuid]} (Unavailable)", friendly_name: true) %>
84               <% elsif current_job[:output] %>
85                 <%= link_to_arvados_object_if_readable(current_job[:output], "#{current_job[:output]} (Unavailable)", link_text: "Output of #{pj[:name]}") %>
86               <% else %>
87                 No output.
88               <% end %>
89             </div>
90           <% end %>
91
92           <% if current_job[:state].in? ["Queued", "Running"] and @object.editable? %>
93             <%# column offset 11 %>
94             <div class="col-md-1 pipeline-instance-spacing">
95               <%= form_tag "/jobs/#{current_job[:uuid]}/cancel", remote: true, style: "display:inline; padding-left: 1em" do |f| %>
96                 <%= hidden_field_tag :return_to, url_for(@object) %>
97                 <%= button_tag "Cancel", {class: 'btn btn-xs btn-danger', id: "cancel-job-button"} %>
98               <% end %>
99             </div>
100           <% end %>
101         <% end %>
102       </div>
103     </div>
104   </div>
105
106   <div id="collapse<%= i %>" class="panel-collapse collapse <%= if expanded then 'in' end %>">
107     <div class="panel-body">
108       <div class="container">
109         <% current_component = (if current_job then current_job else pj end) %>
110         <div class="row">
111           <div class="col-md-6">
112             <table>
113               <% # link to repo tree/file only if the repo is readable
114                  # and the commit is a sha1...
115                  repo =
116                  (/^[0-9a-f]{40}$/ =~ current_component[:script_version] and
117                  Repository.where(name: current_component[:repository]).first)
118
119                  # ...and the api server provides an http:// or https:// url
120                  repo = nil unless repo.andand.http_fetch_url
121                  %>
122               <% [:script, :repository, :script_version, :supplied_script_version, :nondeterministic].each do |k| %>
123                 <tr>
124                   <td style="padding-right: 1em">
125                     <%= k.to_s %>:
126                   </td>
127                   <td>
128                     <% if current_component[k].nil? %>
129                       (none)
130                     <% elsif repo and k == :repository %>
131                       <%= link_to current_component[k], show_repository_tree_path(id: repo.uuid, commit: current_component[:script_version], path: '/') %>
132                     <% elsif repo and k == :script %>
133                       <%= link_to current_component[k], show_repository_blob_path(id: repo.uuid, commit: current_component[:script_version], path: 'crunch_scripts/'+current_component[:script]) %>
134                     <% elsif repo and k == :script_version %>
135                       <%= link_to current_component[k], show_repository_commit_path(id: repo.uuid, commit: current_component[:script_version]) %>
136                     <% else %>
137                       <%= current_component[k] %>
138                     <% end %>
139                   </td>
140                 </tr>
141               <% end %>
142               <% if current_component[:runtime_constraints].andand[:docker_image] and current_component[:docker_image_locator] %>
143                 <tr>
144                   <td style="padding-right: 1em">
145                     docker_image:
146                   </td>
147                   <td>
148                     <%= current_component[:runtime_constraints][:docker_image] %>
149                   </td>
150                 </tr>
151                 <tr>
152                   <td style="padding-right: 1em">
153                     docker_image_locator:
154                   </td>
155                   <td>
156                     <%= link_to_arvados_object_if_readable(current_component[:docker_image_locator],
157                       current_component[:docker_image_locator], friendly_name: true) %>
158                   </td>
159                 </tr>
160               <% else %>
161                 <tr>
162                   <td style="padding-right: 1em">
163                     docker_image:
164                   </td>
165                   <td>
166                     Not run in Docker
167                   </td>
168                 </tr>
169               <% end %>
170             </table>
171           </div>
172           <div class="col-md-5">
173             <table>
174               <% [:uuid, :modified_by_user_uuid, :priority, :created_at, :started_at, :finished_at].each do |k| %>
175                 <tr>
176                   <td style="padding-right: 1em">
177                     <%= k.to_s %>:
178                   </td>
179                   <td>
180                     <% if k == :uuid %>
181                       <%= link_to_arvados_object_if_readable(current_component[k], current_component[k], link_text: current_component[k]) %>
182                     <% elsif k.to_s.end_with? 'uuid' %>
183                       <%= link_to_arvados_object_if_readable(current_component[k], current_component[k], friendly_name: true) %>
184                     <% elsif k.to_s.end_with? '_at' %>
185                       <%= render_localized_date(current_component[k]) %>
186                     <% else %>
187                       <%= current_component[k] %>
188                     <% end %>
189                   </td>
190                 </tr>
191               <% end %>
192             </table>
193           </div>
194         </div>
195         <div class="row">
196           <div class="col-md-12">
197             <p>script_parameters:</p>
198             <pre><%= JSON.pretty_generate(current_component[:script_parameters]) rescue nil %></pre>
199           </div>
200         </div>
201       </div>
202     </div>
203   </div>
204 </div>