1 class ContainerWorkUnit < ProxyWorkUnit
2 attr_accessor :container
4 def initialize proxied, label
6 if @proxied.is_a?(ContainerRequest)
7 container_uuid = get(:container_uuid)
9 @container = Container.where(uuid: container_uuid).first
15 return self.my_children if self.my_children
18 container_uuid = if @proxied.is_a?(Container) then uuid else get(:container_uuid) end
22 reqs = ContainerRequest.where(requesting_container_uuid: container_uuid).results
24 items << cr.work_unit(cr.name || 'this container')
28 self.my_children = items
38 return nil unless uuid
40 if @proxied.class.respond_to? :table_name
41 "/#{@proxied.class.table_name}/#{uuid}"
43 resource_class = ArvadosBase.resource_class_for_uuid(uuid)
44 "#{resource_class.table_name}/#{uuid}" if resource_class
49 @proxied.is_a?(ContainerRequest) && state_label.in?(["Queued", "Locked", "Running"]) && priority > 0
56 # For the following properties, use value from the @container if exists
57 # This applies to a ContainerRequest with container_uuid
60 t = get_combined(:started_at)
61 t = Time.parse(t) if (t.is_a? String)
66 t = get_combined(:modified_at)
67 t = Time.parse(t) if (t.is_a? String)
72 t = get_combined(:finished_at)
73 t = Time.parse(t) if (t.is_a? String)
78 exit_code = get_combined(:exit_code)
79 "Failed" if (exit_code && exit_code != 0)
84 get_combined(:container_image)
87 def runtime_constraints
88 get_combined(:runtime_constraints)
92 get_combined(:priority)
101 items << get_combined(:output) if get_combined(:output)
106 get_combined(:command)
114 env = get_combined(:environment)
115 env = nil if env.andand.empty?
120 mnt = get_combined(:mounts)
121 mnt = nil if mnt.andand.empty?
126 get_combined(:output_path)
130 [get_combined(:uuid), get(:uuid)].uniq
133 def live_log_lines(limit=2000)
134 event_types = ["stdout", "stderr", "arv-mount", "crunch-run"]
135 log_lines = Log.where(event_type: event_types, object_uuid: log_object_uuids).order("id DESC").limit(limit)
136 log_lines.results.reverse.
137 flat_map { |log| log.properties[:text].split("\n") rescue [] }
141 collection = Collection.find(log_collection) rescue nil
143 return {log: collection, partial: 'collections/show_files', locals: {object: collection, no_checkboxes: true}}
147 # End combined propeties
151 get(key, @container) || get(key, @proxied)