1 class PipelineInstance < ArvadosModel
4 include CommonApiTemplate
5 serialize :components, Hash
6 serialize :properties, Hash
7 belongs_to :pipeline_template, :foreign_key => :pipeline_template_uuid, :primary_key => :uuid
8 attr_accessor :pipeline_template
10 before_validation :bootstrap_components
11 before_validation :update_success
13 api_accessible :user, extend: :common do |t|
14 t.add :pipeline_template_uuid
15 t.add :pipeline_template, :if => :pipeline_template
25 dependency_search(self.components).keys
32 components['steps'].collect do |step|
34 row = [nrow, step['name']]
35 if step['complete'] and step['complete'] != 0
36 if step['output_data_locator']
47 row << (step['warehousejob']['id'] rescue nil)
48 row << (step['warehousejob']['revision'] rescue nil)
49 row << step['output_data_locator']
50 row << (Time.parse(step['warehousejob']['finishtime']) rescue nil)
60 return 0 if t.size < 1
61 t.collect { |r| r[2] }.inject(0.0) { |sum,a| sum += a } / t.size
65 self.where('active = true')
69 def bootstrap_components
70 if pipeline_template and (!components or components.empty?)
71 self.components = pipeline_template.components
76 if components and progress_ratio == 1.0
81 def dependency_search(haystack)
82 if haystack.is_a? String
83 if (re = haystack.match /^([0-9a-f]{32}(\+[^,]+)*)+/)
88 elsif haystack.is_a? Array
90 haystack.each do |value|
91 deps.merge! dependency_search(value)
94 elsif haystack.respond_to? :keys
96 haystack.each do |key, value|
97 deps.merge! dependency_search(value)