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 }
95 def stderr_log_object_uuids
96 result = job_uuids.values.compact
100 def stderr_log_query(limit=nil)
102 where(event_type: "stderr",
103 object_uuid: stderr_log_object_uuids).
106 query = query.limit(limit)
111 def stderr_log_lines(limit=2000)
112 stderr_log_query(limit).results.reverse.
113 flat_map { |log| log.properties[:text].split("\n") rescue [] }
116 def has_readable_logs?
117 log_pdhs, log_uuids = job_log_ids.values.compact.partition do |loc_s|
118 Keep::Locator.parse(loc_s)
121 Collection.where(portable_data_hash: log_pdhs).limit(1).results.any?
123 elsif log_uuids.any? and
124 Collection.where(uuid: log_uuids).limit(1).results.any?
127 stderr_log_query(1).results.any?
134 Hash[components.map { |cname, cspec| [cname, yield(cspec)] }]