1 class ProxyWorkUnit < WorkUnit
6 attr_accessor :my_children
7 attr_accessor :unreadable_children
9 def initialize proxied, label
11 self.proxied = proxied
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
149 get(:script_parameters)
164 def supplied_script_version
165 get(:supplied_script_version)
169 get(:docker_image_locator)
173 get(:nondeterministic)
176 def runtime_constraints
177 get(:runtime_constraints)
195 items << c.output if c.output
198 items << get(:output) if get(:output)
211 def has_unreadable_children
212 self.unreadable_children
216 resource_class = ArvadosBase::resource_class_for_uuid(uuid)
217 resource_class.where(uuid: [uuid]).first rescue nil
221 if state_label.in? ["Complete", "Failed", "Cancelled"]
224 logCollection = Collection.find? lc
226 ApplicationController.helpers.link_to("Log", "#{uri}#Log")
231 elsif state_label == "Running"
233 ApplicationController.helpers.link_to("Log", "#{uri}#Log")
241 if state_label != "Queued"
243 ((if finished_at then finished_at else Time.now() end) - started_at)
249 if state_label != "Queued"
251 (runtime_constraints.andand[:min_nodes] || 1) *
252 ((finished_at || Time.now()) - started_at)
258 if state_label == "Queued"
259 Time.now - Time.parse(created_at.to_s)
263 def show_child_summary
264 if state_label == "Running"
272 state_label == 'Running'
276 state_label == 'Paused'
280 state_label.in? ["Complete", "Failed", "Cancelled"]
284 state_label == 'Failed'
288 state_label.in? ["Queued", "Running"] and can_cancel?
295 if state_label == 'Running'
305 def started_and_active_for_str
309 active_for_1 = "This #{title} started at "
311 if state_label == 'Complete'
312 active_for_2 << "completed in "
313 elsif state_label == 'Failed'
314 active_for_2 << "failed after "
316 active_for_2 << "has been active for "
318 [active_for_1, active_for_2]
325 if self.proxied.respond_to? key
326 self.proxied.send(key)
327 elsif self.proxied.is_a?(Hash)