class ContainerWorkUnit < ProxyWorkUnit
attr_accessor :container
- def initialize proxied, label
+ def initialize proxied, label, parent
super
if @proxied.is_a?(ContainerRequest)
container_uuid = get(:container_uuid)
end
def children
- return self.my_children if self.my_children
+ return @my_children if @my_children
container_uuid = nil
container_uuid = if @proxied.is_a?(Container) then uuid else get(:container_uuid) end
end
end
- self.my_children = items
+ @my_children = items
end
def title
get(:container_uuid)
end
+ def requesting_container_uuid
+ get(:requesting_container_uuid)
+ end
+
def priority
@proxied.priority
end
def state_label
ec = exit_code
return "Failed" if (ec && ec != 0)
- get_combined(:state)
+
+ state = get_combined(:state)
+
+ return "Queued" if state == "Locked"
+ return "Cancelled" if ((priority == 0) and (state == "Queued"))
+ state
end
def exit_code
end
def log_collection
- get_combined(:log)
+ if @proxied.is_a?(ContainerRequest)
+ get(:log_uuid)
+ else
+ get(:log)
+ end
end
def outputs
items = []
- items << get_combined(:output) if get_combined(:output)
+ if @proxied.is_a?(ContainerRequest)
+ out = get(:output_uuid)
+ else
+ out = get(:output)
+ end
+ items << out if out
items
end
end
def log_object_uuids
- [get_combined(:uuid), get(:uuid)].uniq
- end
-
- def live_log_lines(limit=2000)
- event_types = ["stdout", "stderr", "arv-mount", "crunch-run"]
- log_lines = Log.where(event_type: event_types, object_uuid: log_object_uuids).order("id DESC").limit(limit)
- log_lines.results.reverse.
- flat_map { |log| log.properties[:text].split("\n") rescue [] }
+ [get(:uuid, @container), get(:uuid, @proxied)].compact
end
def render_log
def template_uuid
properties = get(:properties)
if properties
- properties[:workflow_uuid]
+ properties[:template_uuid]
end
end
protected
def get_combined key
- get(key, @container) || get(key, @proxied)
+ from_container = get(key, @container)
+ from_proxied = get(key, @proxied)
+
+ if from_container.is_a? Hash or from_container.is_a? Array
+ if from_container.any? then from_container else from_proxied end
+ else
+ from_container || from_proxied
+ end
end
end