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.is_a? String)
34 t = Time.parse(t) if (t.is_a? String)
40 t = Time.parse(t) if (t.is_a? String)
46 t = Time.parse(t) if (t.is_a? String)
52 if ["Running", "RunningOnServer", "RunningOnClient"].include? state
59 def state_bootstrap_class
64 when 'Failed', 'Cancelled'
66 when 'Running', 'RunningOnServer', 'RunningOnClient'
75 if state == 'Complete'
77 elsif state == 'Failed' or state == 'Cancelled'
93 when 'Failed', 'Cancelled'
103 summary[:done] = done
104 summary[:failed] = failed
105 summary[:todo] = todo
106 summary[:running] = running
110 def child_summary_str
111 summary = child_summary
114 if state_label == 'Running'
115 done = summary[:done] || 0
116 running = summary[:running] || 0
117 failed = summary[:failed] || 0
118 todo = summary[:todo] || 0
119 total = done + running + failed + todo
122 summary_txt += "#{summary[:done]} #{'child'.pluralize(summary[:done])} done,"
123 summary_txt += "#{summary[:failed]} failed,"
124 summary_txt += "#{summary[:running]} running,"
125 summary_txt += "#{summary[:todo]} pending"
133 if state == 'Complete'
135 elsif state == 'Failed' or state == 'Cancelled'
139 summary = child_summary
140 return 0.0 if summary.nil?
142 done = summary[:done] || 0
143 running = summary[:running] || 0
144 failed = summary[:failed] || 0
145 todo = summary[:todo] || 0
146 total = done + running + failed + todo
148 (done+failed).to_f / total
166 def has_unreadable_children
171 resource_class = ArvadosBase::resource_class_for_uuid(uuid)
172 resource_class.where(uuid: [uuid]).first rescue nil
176 if state_label.in? ["Complete", "Failed", "Cancelled"]
179 logCollection = Collection.find? lc
181 ApplicationController.helpers.link_to("Log", "#{uri}#Log")
186 elsif state_label == "Running"
188 ApplicationController.helpers.link_to("Log", "#{uri}#Log")
196 if state_label != "Queued"
198 ((if finished_at then finished_at else Time.now() end) - started_at)
204 if state_label != "Queued"
206 (runtime_constraints.andand[:min_nodes] || 1) * ((finished_at || Time.now()) - started_at)
212 if state_label == "Queued"
213 Time.now - Time.parse(created_at.to_s)
218 state_label == 'Running'
222 state_label == 'Paused'
226 state_label.in? ["Complete", "Failed", "Cancelled"]
230 state_label == 'Failed'
234 runningtime = ApplicationController.helpers.determine_wallclock_runtime(if children.any? then children else [self] end)
238 walltime = if finished_at then (finished_at - started_at) else (Time.now - started_at) end
244 resp << "This #{title} started at "
245 resp << ApplicationController.helpers.render_localized_date(started_at)
247 if state_label == 'Complete'
248 resp << "completed in "
249 elsif state_label == 'Failed'
250 resp << "failed after "
252 resp << "has been active for "
255 if walltime > runningtime
256 resp << ApplicationController.helpers.render_time(walltime, false)
258 resp << ApplicationController.helpers.render_time(runningtime, false)
263 resp << ApplicationController.helpers.render_localized_date(finished_at)
268 resp << "This #{title} is "
269 resp << if state_label == 'Running' then 'active' else state_label.downcase end
275 resp << " Check the Log tab for more detail about why it failed."
282 if state_label == 'Running'
291 cpu_time = children.map { |c|
293 (c.runtime_constraints.andand[:min_nodes] || 1) * ((c.finished_at || Time.now()) - c.started_at)
300 cpu_time = (runtime_constraints.andand[:min_nodes] || 1) * ((finished_at || Time.now()) - started_at)
304 resp << ApplicationController.helpers.render_time(runningtime, false)
305 if (walltime - runningtime) > 0
307 resp << ApplicationController.helpers.render_time(walltime - runningtime, false)
314 resp << ApplicationController.helpers.render_time(cpu_time, false)
315 resp << " of node allocation time ("
316 resp << (cpu_time/runningtime).round(1).to_s
317 resp << "⨯ scaling)."
327 def get key, obj=@proxied
328 if obj.respond_to? key
330 elsif obj.is_a?(Hash)