f5eb17b63584acc244e69695e91bab7c9810c51c
[arvados.git] / apps / workbench / app / views / pipeline_instances / _show_components_running.html.erb
1 <%# Summary %>
2
3 <% if @object.state == 'Paused' %>
4   <p>
5     This pipeline is paused.  Jobs that are
6     already running will continue to run, but no new jobs will be submitted.
7   </p>
8 <% end %>
9
10 <p>
11   This pipeline
12   <% if @object.started_at %>
13     started at <span data-utc-date="<%= @object.started_at %>"><%= @object.started_at %></span> and
14   <% else %>
15     has not started.
16   <% end %>
17
18   <% if @object.state == 'Complete' %>
19     completed in
20   <% elsif @object.state == 'Failed' %>
21     failed after
22   <% else %>
23     and has been active for
24   <% end %>
25
26   <% walltime = if @object.started_at
27         if @object.finished_at
28           @object.finished_at - @object.started_at
29         else
30           Time.now - @object.started_at
31         end
32       else
33         0
34       end
35       %>
36
37   <%= runtime(walltime, true) %><% if @object.finished_at %> at <span data-utc-date="<%= @object.finished_at %>"><%= @object.finished_at %></span><% end %>.
38 </p>
39
40 <p>
41   This pipeline
42     <% tasks = JobTask.filter([['job_uuid', 'in', render_pipeline_jobs.map { |j| j[:job].andand[:uuid] }]]).results %>
43     <% runningtime = determine_wallclock_runtime(render_pipeline_jobs.map {|j| j[:job]}) %>
44
45     <% if @object.state.start_with? == 'Running' %>
46       has run
47       <% else %>
48       ran
49     <% end %>
50     for
51     <%= runtime(runningtime, true) %><% if tasks.size == 0 %>.<% else %> (<%= runtime(walltime - runningtime, true) %> queued),
52       and used
53       <% cputime = tasks.map { |task|
54            puts "started at #{task.started_at}"
55                   if task.started_at
56                     (if task.finished_at then task.finished_at else Time.now() end) - task.started_at
57                   else
58                     0
59                   end
60                 }.reduce(:+) %>
61     <%= runtime(cputime, true) %>
62     of CPU time (<%= (cputime/runningtime).round(1) %>&Cross; scaling).
63     <% end %>
64 </p>
65
66 <%# Components %>
67
68 <% render_pipeline_jobs.each_index do |i| %>
69   <% pj = render_pipeline_jobs[i] %>
70   <% current_job = pj[:job] if pj[:job] != {} %>
71   <div class="panel panel-default">
72     <div class="panel-heading">
73       <div class="container-fluid">
74         <div class="row">
75           <div class="col-md-3">
76             <h4 class="panel-title">
77               <a data-toggle="collapse" data-parent="#accordion" href="#collapse<%= i %>">
78                 <%= pj[:name] %> <span class="caret"></span>
79               </a>
80             </h4>
81           </div>
82
83           <% puts current_job.inspect %>
84
85           <% if current_job %>
86             <div class="col-md-1">
87               <%= render(partial: 'job_status_label', locals: { j: current_job }) %>
88             </div>
89
90             <div class="col-md-3">
91               <% if current_job[:started_at] %>
92                 <% walltime = ((if current_job.finished_at then current_job.finished_at else Time.now() end) - current_job.started_at) %>
93                 <% cputime = tasks.map { |task|
94                      if task.started_at and task.job_uuid == current_job.uuid
95                        (if task.finished_at then task.finished_at else Time.now() end) - task.started_at
96                      else
97                        0
98                      end
99                    }.reduce(:+) %>
100                 <%= runtime(walltime, false) %> / <%= runtime(cputime, false) %> (<%= (cputime/walltime).round(1) %>&Cross;)
101               <% end %>
102             </div>
103
104             <% if Job::state(current_job).in? ["Completed", "Failed", "Canceled"] %>
105               <div class="col-md-3">
106                 <% if pj[:output_uuid] %>
107                   <%= link_to_if_arvados_object pj[:output_uuid] %>
108                 <% elsif current_job.andand[:output] %>
109                   <%= link_to_if_arvados_object current_job[:output], link_text: "Output of #{pj[:name]}" %>
110                 <% else %>
111                   No output.
112                 <% end %>
113               </div>
114             <% elsif Job::state(current_job) == "Running" %>
115               <div class="col-md-3 pipeline-instance-spacing">
116                 <%= pj[:progress_bar] %>
117               </div>
118               <div class="col-md-1 pipeline-instance-spacing">
119                 <%= form_tag "/jobs/#{current_job.uuid}/cancel", style: "display:inline; padding-left: 1em" do |f| %>
120                 <%= hidden_field_tag :return_to, url_for(@object) %>
121                 <%= button_tag "Cancel", {class: 'btn btn-xs btn-danger', id: "cancel-job-button"} %>
122             </div>
123             <% end %>
124           <% elsif Job::state(current_job) == "Queued" %>
125             <div class="col-md-5">
126               <% queuetime = Time.now - current_job[:created_at] %>
127               Queued for <%= runtime(queuetime, true) %>.
128               <% if current_job.queue_position == 0 %>
129                 This job is next in the queue to run.
130               <% elsif current_job.queue_position == 1 %>
131                 There is 1 job in the queue ahead of this one.
132               <% else  %>
133                 There are <%= current_job.queue_position %> jobs in the queue ahead of this one.
134               <% end %>
135             </div>
136           <% end %>
137         <% else %>
138           <div class="col-md-3 col-md-offset-3">
139             <span class="label label-default">Not ready</span>
140           </div>
141 <% end %>
142 </div>
143 </div>
144 </div>
145
146 <div id="collapse<%= i %>" class="panel-collapse collapse">
147   <div class="panel-body">
148     <div class="container">
149         <% current_component = (if current_job then current_job else pj end) %>
150         <div class="row">
151           <div class="col-md-6">
152             <table>
153               <% [:script, :repository, :supplied_script_version, :script_version, :nondeterministic].each do |k| %>
154                 <tr>
155                   <td style="padding-right: 1em">
156                     <%= k.to_s %>:
157                   </td>
158                   <td>
159                     <%= current_component[k] %>
160                   </td>
161                 </tr>
162               <% end %>
163               <% if current_component[:runtime_constraints].andand[:docker_image] and current_component[:docker_image_locator] %>
164                 <tr>
165                   <td style="padding-right: 1em">
166                     docker_image:
167                   </td>
168                   <td>
169                     <%= current_component[:runtime_constraints][:docker_image] %>
170                   </td>
171                 </tr>
172                 <tr>
173                   <td style="padding-right: 1em">
174                     docker_image_locator:
175                   </td>
176                   <td>
177                     <%= link_to_if_arvados_object current_component[:docker_image_locator] %>
178                   </td>
179                 </tr>
180               <% else %>
181                 <tr>
182                   <td style="padding-right: 1em">
183                     docker_image:
184                   </td>
185                   <td>
186                     Not run in Docker
187                   </td>
188                 </tr>
189               <% end %>
190             </table>
191           </div>
192           <div class="col-md-5">
193             <table>
194               <% [:uuid, :modified_by_user_uuid, :priority, :created_at, :started_at, :finished_at].each do |k| %>
195                 <tr>
196                   <td style="padding-right: 1em">
197                     <%= k.to_s %>:
198                   </td>
199                   <td>
200                     <% if k.to_s.end_with? 'uuid' %>
201                       <%= link_to_if_arvados_object current_component[k], friendly_name: true %>
202                     <% elsif k.to_s.end_with? '_at' %>
203                       <span data-utc-date="<%= current_component[k] %>"><%= current_component[k] %></span>
204                     <% else %>
205                       <%= current_component[k] %>
206                     <% end %>
207                   </td>
208                 </tr>
209               <% end %>
210             </table>
211           </div>
212         </div>
213         <div class="row">
214           <div class="col-md-6">
215             <p>script_parameters:</p>
216             <pre><%= JSON.pretty_generate(current_component[:script_parameters]) rescue nil %></pre>
217           </div>
218           <% if current_component[:tasks_summary] %>
219           <div class="col-md-3">
220             <table>
221               <% [:done, :running, :failed, :todo].each do |d| %>
222               <tr>
223                 <td style="padding-right: 1em"><%= 'tasks:' if d == :done %></td>
224                 <td style="padding-right: 1em"><%= d.to_s %></td>
225                 <td><%= current_component[:tasks_summary][d] %></td>
226               </tr>
227               <% end %>
228             </table>
229           </div>
230           <% end %>
231         </div>
232     </div>
233   </div>
234 </div>
235 </div>
236 <% end %>