3 class PipelineInstance < ArvadosBase
4 attr_accessor :pipeline_template
6 def self.goes_in_projects?
10 def friendly_link_name lookup=nil
11 pipeline_name = self.name
12 if pipeline_name.nil? or pipeline_name.empty?
13 template = if lookup and lookup[self.pipeline_template_uuid]
14 lookup[self.pipeline_template_uuid]
16 PipelineTemplate.where(uuid: self.pipeline_template_uuid).first
30 PipelineTemplate.find(pipeline_template_uuid).name
36 def update_job_parameters(new_params)
37 self.components[:steps].each_with_index do |step, i|
38 step[:params].each do |param|
39 if new_params.has_key?(new_param_name = "#{i}/#{param[:name]}") or
40 new_params.has_key?(new_param_name = "#{step[:name]}/#{param[:name]}") or
41 new_params.has_key?(new_param_name = param[:name])
43 %w(hash data_locator).collect(&:to_sym).each do |ptype|
44 param_type = ptype if param.has_key? ptype
46 param[param_type] = new_params[new_param_name]
52 def editable_attributes
53 %w(name description components)
56 def attribute_editable?(name, ever=nil)
57 if name.to_s == "components"
58 (ever or %w(New Ready).include?(state)) and super
64 def attributes_for_display
65 super.reject { |k,v| k == 'components' }
72 def component_input_title(component_name, input_name)
73 component = components[component_name]
74 return nil if component.nil?
75 param_info = component[:script_parameters].andand[input_name.to_sym]
76 if param_info.is_a?(Hash) and param_info[:title]
79 "\"#{input_name.to_s}\" parameter for #{component[:script]} script in #{component_name} component"
83 def textile_attributes
88 components_map { |cspec| cspec[:job][:uuid] rescue nil }
92 components_map { |cspec| cspec[:job][:log] rescue nil }
96 components_map { |cspec| cspec[:job][:uuid] rescue nil }
99 def stderr_log_object_uuids
100 result = job_uuids.values.compact
104 def stderr_log_query(limit=nil)
106 where(event_type: "stderr",
107 object_uuid: stderr_log_object_uuids).
110 query = query.limit(limit)
115 def stderr_log_lines(limit=2000)
116 stderr_log_query(limit).results.reverse.
117 flat_map { |log| log.properties[:text].split("\n") rescue [] }
120 def has_readable_logs?
121 log_pdhs, log_uuids = job_log_ids.values.compact.partition do |loc_s|
122 Keep::Locator.parse(loc_s)
125 Collection.where(portable_data_hash: log_pdhs).limit(1).results.any?
127 elsif log_uuids.any? and
128 Collection.where(uuid: log_uuids).limit(1).results.any?
131 stderr_log_query(1).results.any?
135 def work_unit(label=nil)
136 PipelineInstanceWorkUnit.new(self, label || self.name)
142 Hash[components.map { |cname, cspec| [cname, yield(cspec)] }]