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
156 def has_unreadable_children
161 resource_class = ArvadosBase::resource_class_for_uuid(uuid)
162 resource_class.where(uuid: [uuid]).first rescue nil
166 if state_label.in? ["Complete", "Failed", "Cancelled"]
169 logCollection = Collection.find? lc
171 ApplicationController.helpers.link_to("Log", "#{uri}#Log")
176 elsif state_label == "Running"
178 ApplicationController.helpers.link_to("Log", "#{uri}#Log")
186 if state_label != "Queued"
188 ((if finished_at then finished_at else Time.now() end) - started_at)
194 if state_label != "Queued"
196 (runtime_constraints.andand[:min_nodes] || 1) * ((finished_at || Time.now()) - started_at)
202 if state_label == "Queued"
203 Time.now - Time.parse(created_at.to_s)
207 def show_child_summary
208 if state_label == "Running"
216 state_label == 'Running'
220 state_label == 'Paused'
224 state_label.in? ["Complete", "Failed", "Cancelled"]
228 state_label == 'Failed'
235 if state_label == 'Running'
245 def started_and_active_for_str
249 active_for_1 = "This #{title} started at "
251 if state_label == 'Complete'
252 active_for_2 << "completed in "
253 elsif state_label == 'Failed'
254 active_for_2 << "failed after "
256 active_for_2 << "has been active for "
258 [active_for_1, active_for_2]
263 runningtime = ApplicationController.helpers.determine_wallclock_runtime(children)
267 walltime = if finished_at then (finished_at - started_at) else (Time.now - started_at) end
273 resp << "This #{title} started at "
274 resp << ApplicationController.helpers.render_localized_date(started_at)
276 if state_label == 'Complete'
277 resp << "completed in "
278 elsif state_label == 'Failed'
279 resp << "failed after "
281 resp << "has been active for "
284 if walltime > runningtime
285 resp << ApplicationController.helpers.render_time(walltime, false)
287 resp << ApplicationController.helpers.render_time(runningtime, false)
292 resp << ApplicationController.helpers.render_localized_date(finished_at)
297 resp << "This #{title} is "
298 resp << if state_label == 'Running' then 'active' else state_label.downcase end
304 resp << " Check the Log tab for more detail about why it failed."
311 if state_label == 'Running'
318 cpu_time = children.map { |c|
320 (c.runtime_constraints.andand[:min_nodes] || 1) * ((c.finished_at || Time.now()) - c.started_at)
326 resp << ApplicationController.helpers.render_time(runningtime, false)
327 if (walltime - runningtime) > 0
329 resp << ApplicationController.helpers.render_time(walltime - runningtime, false)
336 resp << ApplicationController.helpers.render_time(cpu_time, false)
337 resp << " of node allocation time ("
338 resp << (cpu_time/runningtime).round(1).to_s
339 resp << "⨯ scaling)."
350 if @proxied.respond_to? key
352 elsif @proxied.is_a?(Hash)