1 class ProxyWorkUnit < WorkUnit
6 attr_accessor :my_children
7 attr_accessor :unreadable_children
9 def initialize proxied, label
22 def modified_by_user_uuid
23 get(:modified_by_user_uuid)
28 t = Time.parse(t) if (t.andand.class == String)
34 t = Time.parse(t) if (t.andand.class == String)
40 t = Time.parse(t) if (t.andand.class == String)
46 if ["Running", "RunningOnServer", "RunningOnClient"].include? state
53 def state_bootstrap_class
58 when 'Failed', 'Cancelled'
60 when 'Running', 'RunningOnServer', 'RunningOnClient'
69 if state == 'Complete'
71 elsif state == 'Failed' or state == 'Cancelled'
87 when 'Failed', 'Cancelled'
98 summary[:failed] = failed
100 summary[:running] = running
104 def child_summary_str
105 summary = child_summary
108 if state_label == 'Running'
109 done = summary[:done] || 0
110 running = summary[:running] || 0
111 failed = summary[:failed] || 0
112 todo = summary[:todo] || 0
113 total = done + running + failed + todo
116 summary_txt += "#{summary[:done]} #{'child'.pluralize(summary[:done])} done,"
117 summary_txt += "#{summary[:failed]} failed,"
118 summary_txt += "#{summary[:running]} running,"
119 summary_txt += "#{summary[:todo]} pending"
127 if state == 'Complete'
129 elsif state == 'Failed' or state == 'Cancelled'
133 summary = child_summary
134 return 0.0 if summary.nil?
136 done = summary[:done] || 0
137 running = summary[:running] || 0
138 failed = summary[:failed] || 0
139 todo = summary[:todo] || 0
140 total = done + running + failed + todo
142 (done+failed).to_f / total
155 items << c.output if c.output
158 items << get(:output) if get(:output)
167 def has_unreadable_children
172 resource_class = ArvadosBase::resource_class_for_uuid(uuid)
173 resource_class.where(uuid: [uuid]).first rescue nil
177 if state_label.in? ["Complete", "Failed", "Cancelled"]
180 logCollection = Collection.find? lc
182 ApplicationController.helpers.link_to("Log", "#{uri}#Log")
187 elsif state_label == "Running"
189 ApplicationController.helpers.link_to("Log", "#{uri}#Log")
197 if state_label != "Queued"
199 ((if finished_at then finished_at else Time.now() end) - started_at)
205 if state_label != "Queued"
207 (runtime_constraints.andand[:min_nodes] || 1) * ((finished_at || Time.now()) - started_at)
213 if state_label == "Queued"
214 Time.now - Time.parse(created_at.to_s)
219 state_label == 'Running'
223 state_label == 'Paused'
227 state_label.in? ["Complete", "Failed", "Cancelled"]
231 state_label == 'Failed'
235 runningtime = ApplicationController.helpers.determine_wallclock_runtime(if children.any? then children else [@proxied] end)
239 walltime = if finished_at then (finished_at - started_at) else (Time.now - started_at) end
245 resp << "This #{title} started at "
246 resp << ApplicationController.helpers.render_localized_date(started_at)
248 if state_label == 'Complete'
249 resp << "completed in "
250 elsif state_label == 'Failed'
251 resp << "failed after "
253 resp << "has been active for "
256 if walltime > runningtime
257 resp << ApplicationController.helpers.render_time(walltime, false)
259 resp << ApplicationController.helpers.render_time(runningtime, false)
264 resp << ApplicationController.helpers.render_localized_date(finished_at)
269 resp << "This #{title} is "
270 resp << if state_label == 'Running' then 'active' else state_label.downcase end
276 resp << " Check the Log tab for more detail about why it failed."
283 if state_label == 'Running'
292 cpu_time = children.map { |c|
294 (c.runtime_constraints.andand[:min_nodes] || 1) * ((c.finished_at || Time.now()) - c.started_at)
301 cpu_time = (runtime_constraints.andand[:min_nodes] || 1) * ((finished_at || Time.now()) - started_at)
305 resp << ApplicationController.helpers.render_time(runningtime, false)
306 if (walltime - runningtime) > 0
308 resp << ApplicationController.helpers.render_time(walltime - runningtime, false)
315 resp << ApplicationController.helpers.render_time(cpu_time, false)
316 resp << " of node allocation time ("
317 resp << (cpu_time/runningtime).round(1).to_s
318 resp << "⨯ scaling)."
329 if @proxied.respond_to? key
331 elsif @proxied.is_a?(Hash)