1 class ProxyWorkUnit < WorkUnit
6 attr_accessor :my_children
7 attr_accessor :unreadable_children
9 def initialize proxied, label, parent
27 def modified_by_user_uuid
28 get(:modified_by_user_uuid)
37 t = Time.parse(t) if (t.is_a? String)
43 t = Time.parse(t) if (t.is_a? String)
49 t = Time.parse(t) if (t.is_a? String)
55 t = Time.parse(t) if (t.is_a? String)
61 if ["Running", "RunningOnServer", "RunningOnClient"].include? state
70 def state_bootstrap_class
75 when 'Failed', 'Cancelled'
77 when 'Running', 'RunningOnServer', 'RunningOnClient'
86 if state == 'Complete'
88 elsif state == 'Failed' or state == 'Cancelled'
104 when 'Failed', 'Cancelled'
114 summary[:done] = done
115 summary[:failed] = failed
116 summary[:todo] = todo
117 summary[:running] = running
121 def child_summary_str
122 summary = child_summary
125 if state_label == 'Running'
126 done = summary[:done] || 0
127 running = summary[:running] || 0
128 failed = summary[:failed] || 0
129 todo = summary[:todo] || 0
130 total = done + running + failed + todo
133 summary_txt += "#{summary[:done]} #{'child'.pluralize(summary[:done])} done,"
134 summary_txt += "#{summary[:failed]} failed,"
135 summary_txt += "#{summary[:running]} running,"
136 summary_txt += "#{summary[:todo]} pending"
144 if state == 'Complete'
146 elsif state == 'Failed' or state == 'Cancelled'
150 summary = child_summary
151 return 0.0 if summary.nil?
153 done = summary[:done] || 0
154 running = summary[:running] || 0
155 failed = summary[:failed] || 0
156 todo = summary[:todo] || 0
157 total = done + running + failed + todo
159 (done+failed).to_f / total
177 def has_unreadable_children
182 if state_label != "Queued"
184 ((if finished_at then finished_at else Time.now() end) - started_at)
196 (runtime_constraints.andand[:min_nodes] || 1).to_i * ((finished_at || Time.now()) - started_at)
204 if state_label == "Queued"
205 Time.now - Time.parse(created_at.to_s)
210 state_label == 'Running'
214 state_label == 'Paused'
218 state_label.in? ["Complete", "Failed", "Cancelled"]
222 state_label == 'Failed'
225 def runtime_contributors
228 children.each{|c| contributors << c.runtime_contributors}
236 ApplicationController.helpers.determine_wallclock_runtime runtime_contributors
241 running_time = runningtime
243 walltime = if finished_at then (finished_at - started_at) else (Time.now - started_at) end
248 resp << "This #{title} started at "
249 resp << ApplicationController.helpers.render_localized_date(started_at)
251 if state_label == 'Complete'
252 resp << "completed in "
253 elsif state_label == 'Failed'
254 resp << "failed after "
256 resp << "has been active for "
259 resp << ApplicationController.helpers.render_time(walltime, 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."
281 resp << "It has runtime of "
285 resp << ApplicationController.helpers.render_time(running_time, false)
286 if (walltime - running_time) > 0
288 resp << ApplicationController.helpers.render_time(walltime - running_time, false)
295 resp << ApplicationController.helpers.render_time(cpu_time, false)
296 resp << " of node allocation time ("
297 resp << (cpu_time/running_time).round(1).to_s
298 resp << "⨯ scaling)."
310 def live_log_lines(limit)
311 Log.where(object_uuid: log_object_uuids).
312 order("created_at DESC").
315 select { |log| log.properties[:text].is_a? String }.
317 flat_map { |log| log.properties[:text].split("\n") }
322 def get key, obj=@proxied
323 if obj.respond_to? key
325 elsif obj.is_a?(Hash)
326 obj[key] || obj[key.to_s]