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)
200 def has_unreadable_children
201 self.unreadable_children
205 resource_class = ArvadosBase::resource_class_for_uuid(uuid)
206 resource_class.where(uuid: [uuid]).first rescue nil
210 if state_label.in? ["Complete", "Failed", "Cancelled"]
213 logCollection = Collection.find? lc
215 ApplicationController.helpers.link_to("Log", "#{uri}#Log")
220 elsif state_label == "Running"
222 ApplicationController.helpers.link_to("Log", "#{uri}#Log")
230 if state_label != "Queued"
232 ((if finished_at then finished_at else Time.now() end) - started_at)
238 if state_label != "Queued"
240 (runtime_constraints.andand[:min_nodes] || 1) *
241 ((finished_at || Time.now()) - started_at)
247 if state_label == "Queued"
248 Time.now - Time.parse(created_at.to_s)
252 def show_child_summary
253 if state_label == "Running"
261 state_label == 'Running'
265 state_label == 'Paused'
269 state_label.in? ["Complete", "Failed", "Cancelled"]
273 state_label == 'Failed'
277 state_label.in? ["Queued", "Running"] and can_cancel?
284 if state_label == 'Running'
294 def started_and_active_for_str
298 active_for_1 = "This #{title} started at "
300 if state_label == 'Complete'
301 active_for_2 << "completed in "
302 elsif state_label == 'Failed'
303 active_for_2 << "failed after "
305 active_for_2 << "has been active for "
307 [active_for_1, active_for_2]
314 if self.proxied.respond_to? key
315 self.proxied.send(key)
316 elsif self.proxied.is_a?(Hash)