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)
208 state_label == 'Running'
212 state_label == 'Paused'
216 state_label.in? ["Complete", "Failed", "Cancelled"]
220 state_label == 'Failed'
224 runningtime = ApplicationController.helpers.determine_wallclock_runtime(if children.any? then children else [self] end)
228 walltime = if finished_at then (finished_at - started_at) else (Time.now - started_at) end
234 resp << "This #{title} started at "
235 resp << ApplicationController.helpers.render_localized_date(started_at)
237 if state_label == 'Complete'
238 resp << "completed in "
239 elsif state_label == 'Failed'
240 resp << "failed after "
242 resp << "has been active for "
245 if walltime > runningtime
246 resp << ApplicationController.helpers.render_time(walltime, false)
248 resp << ApplicationController.helpers.render_time(runningtime, false)
253 resp << ApplicationController.helpers.render_localized_date(finished_at)
258 resp << "This #{title} is "
259 resp << if state_label == 'Running' then 'active' else state_label.downcase end
265 resp << " Check the Log tab for more detail about why it failed."
272 if state_label == 'Running'
281 cpu_time = children.map { |c|
283 (c.runtime_constraints.andand[:min_nodes] || 1) * ((c.finished_at || Time.now()) - c.started_at)
290 cpu_time = (runtime_constraints.andand[:min_nodes] || 1) * ((finished_at || Time.now()) - started_at)
294 resp << ApplicationController.helpers.render_time(runningtime, false)
295 if (walltime - runningtime) > 0
297 resp << ApplicationController.helpers.render_time(walltime - runningtime, false)
304 resp << ApplicationController.helpers.render_time(cpu_time, false)
305 resp << " of node allocation time ("
306 resp << (cpu_time/runningtime).round(1).to_s
307 resp << "⨯ scaling)."
318 if @proxied.respond_to? key
320 elsif @proxied.is_a?(Hash)