1 class PipelineInvocation < OrvosModel
4 include CommonApiTemplate
5 serialize :components, Hash
6 belongs_to :pipeline, :foreign_key => :pipeline_uuid, :primary_key => :uuid
7 attr_accessor :pipeline
9 before_validation :bootstrap_components
10 before_validation :update_success
12 api_accessible :superuser, :extend => :common do |t|
14 t.add :pipeline, :if => :pipeline
23 dependency_search(self.components).keys
30 components['steps'].collect do |step|
32 row = [nrow, step['name']]
33 if step['output_data_locator']
38 row << (step['warehousejob']['id'] rescue nil)
39 row << (step['warehousejob']['revision'] rescue nil)
40 row << step['output_data_locator']
41 row << (Time.parse(step['warehousejob']['finishtime']) rescue nil)
51 return 0 if t.size < 1
52 t.collect { |r| r[2] }.inject(0.0) { |sum,a| sum += a } / t.size
56 def bootstrap_components
57 if pipeline and (!components or components.empty?)
58 self.components = pipeline.components
63 if components and progress_ratio == 1.0
68 def dependency_search(haystack)
69 if haystack.is_a? String
70 if (re = haystack.match /^([0-9a-f]{32}(\+[^,]+)*)+/)
75 elsif haystack.is_a? Array
77 haystack.each do |value|
78 deps.merge! dependency_search(value)
81 elsif haystack.respond_to? :keys
83 haystack.each do |key, value|
84 deps.merge! dependency_search(value)