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