Class: CF::Run
Instance Attribute Summary collapse
-
#errors ⇒ Object
Contains Error Message if any.
-
#file ⇒ Object
File attribute to upload for Production Run.
-
#input ⇒ Object
Input to be passed for Production Run.
-
#line ⇒ Object
Line attribute with which run is associated.
-
#title ⇒ Object
Title of the “run” object.
Class Method Summary collapse
-
.add_units(options = {}) ⇒ Object
Adds units to an existing production Run ===Usage Example: units = CF::Run.add_units(=> “title”, :file => “path_of_file”).
-
.all(options = {}) ⇒ Object
Returns all runs of a line ===Usage Example: progress = CF::Run.all({:line_title => “line_title”, :page => 1).
-
.create(line, title, file, gold_standards = nil) ⇒ Object
Creates a new Run ===Usage Example:.
-
.destroy(run_title) ⇒ Object
Deletes the production run ===Usage Example: delete_run = CF::Run.destroy(“run_title”).
-
.final_output(title) ⇒ Object
Returns Final Output of production Run ===Usage Example: CF::Run.final_output(“run_title”).
-
.find(title) ⇒ Object
Searches Run for the given “run_title” ===Usage Example: CF::Run.find(“run_title”).
-
.output(options = {}) ⇒ Object
Returns Output of production Run for any specific Station and for given Run Title ===Usage Example: CF::Run.output(=> “run_title”, :station => 2) Will return output of second station.
-
.progress(run_title) ⇒ Object
Returns progress of the production run ===Usage Example: progress = CF::Run.progress(“run_title”).
-
.progress_details(run_title) ⇒ Object
Returns progress details of the production run ===Usage Example: progress = CF::Run.progress_details(“run_title”).
-
.resume(run_title) ⇒ Object
Resumes the paused production run ===Usage Example: resume_run = CF::Run.resume(“run_title”).
Instance Method Summary collapse
-
#final_output ⇒ Object
Returns Final Output of production Run ===Usage Example: run_object.final_output.
-
#initialize(line, title, input, gold_standards = nil) ⇒ Run
constructor
Initializes a new Run ===Usage Example:.
-
#output(options = {}) ⇒ Object
Returns Output of Run object for any specific Station ===Usage Example: run_object.output(:station => 2) Will return output of second station.
-
#progress ⇒ Object
:nodoc:.
-
#progress_details ⇒ Object
:nodoc:.
Constructor Details
#initialize(line, title, input, gold_standards = nil) ⇒ Run
Initializes a new Run
Usage Example:
run = CF::Run.new("line_title", "run name", file_path)
OR
You can pass line object instead of passing line title:
run = CF::Run.new(line_object, "run name", file_path)
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/cf/run.rb', line 29 def initialize(line, title, input, gold_standards = nil) if line.class == CF::Line || line.class == Hashie::Mash @line = line @line_title = line.title elsif line.class == String if line.split("/").count == 2 @account = line.split("/").first @line_title = line.split("/").last elsif line.split("/").count == 1 @line_title = line end end @title = title if File.exist?(input.to_s) @file = input @gold_standards = gold_standards @param_data = File.new(input, 'rb') @param_for_input = :file if line.class == String && line.split("/").count == 2 resp = self.class.post("/lines/#{@account}/#{@line_title.downcase}/runs.json", {:data => {:run => {:title => @title, :gold_standards => @gold_standards }}, @param_for_input => @param_data}) else resp = self.class.post("/lines/#{CF.account_name}/#{@line_title.downcase}/runs.json", {:data => {:run => {:title => @title, :gold_standards => @gold_standards}}, @param_for_input => @param_data}) end self.errors = resp['error']['message'] if resp['code'] != 200 else @input = input @param_data = input @param_for_input = :inputs = { :body => { :api_key => CF.api_key, :data =>{:run => { :title => @title, :gold_standards => @gold_standards }, :inputs => @param_data} } } if line.class == String && line.split("/").count == 2 run = HTTParty.post("#{CF.api_url}#{CF.api_version}/lines/#{@account}/#{@line_title.downcase}/runs.json",) else run = HTTParty.post("#{CF.api_url}#{CF.api_version}/lines/#{CF.account_name}/#{@line_title.downcase}/runs.json",) end if run.code != 200 self.errors = run.parsed_response['error']['message'] end end end |
Instance Attribute Details
#errors ⇒ Object
Contains Error Message if any
19 20 21 |
# File 'lib/cf/run.rb', line 19 def errors @errors end |
#file ⇒ Object
File attribute to upload for Production Run
10 11 12 |
# File 'lib/cf/run.rb', line 10 def file @file end |
#input ⇒ Object
Input to be passed for Production Run
13 14 15 |
# File 'lib/cf/run.rb', line 13 def input @input end |
#line ⇒ Object
Line attribute with which run is associated
16 17 18 |
# File 'lib/cf/run.rb', line 16 def line @line end |
#title ⇒ Object
Title of the “run” object
7 8 9 |
# File 'lib/cf/run.rb', line 7 def title @title end |
Class Method Details
.add_units(options = {}) ⇒ Object
Adds units to an existing production Run
Usage Example:
units = CF::Run.add_units({:run_title => "title", :file => "path_of_file"})
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/cf/run.rb', line 91 def self.add_units(={}) units = [:units].nil? ? nil : [:units] run_title = [:run_title].presence file = [:file].presence if units request = { :body => { :api_key => CF.api_key, :data => units } } resp = HTTParty.post("#{CF.api_url}#{CF.api_version}/runs/#{CF.account_name}/#{run_title.downcase}/units.json",request) @errors = resp['error']['message'] if resp.code != 200 return resp.parsed_response elsif file if File.exist?(file.to_s) file_upload = File.new(file, 'rb') resp = post("/runs/#{CF.account_name}/#{run_title.downcase}/units.json", {:file => file_upload}) @errors = resp['error']['message'] if resp['code'] != 200 return resp.to_hash end end end |
.all(options = {}) ⇒ Object
Returns all runs of a line
Usage Example:
progress = CF::Run.all({:line_title => "line_title", :page => 1)
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/cf/run.rb', line 200 def self.all(={}) page = [:page].presence line_title = [:line_title].presence if line_title.nil? if page.nil? resp = get("/runs/#{CF.account_name}.json") else resp = get("/runs/#{CF.account_name}.json", :page => page) end else if page.nil? resp = get("/lines/#{CF.account_name}/#{line_title}/list_runs.json") else resp = get("/lines/#{CF.account_name}/#{line_title}/list_runs.json", :page => page) end end if resp['code'] != 200 send_resp = {"error" => resp['error']['message']} return send_resp else return resp end end |
.create(line, title, file, gold_standards = nil) ⇒ Object
Creates a new Run
Usage Example:
run = CF::Run.new("line_title", "run name", file_path)
OR
You can pass line object instead passing line title:
run = CF::Run.new(line_object, "run name", file_path)
84 85 86 |
# File 'lib/cf/run.rb', line 84 def self.create(line, title, file, gold_standards = nil) Run.new(line, title, file, gold_standards) end |
.destroy(run_title) ⇒ Object
Deletes the production run
Usage Example:
delete_run = CF::Run.destroy("run_title")
238 239 240 241 242 |
# File 'lib/cf/run.rb', line 238 def self.destroy(run_title) resp = delete("/runs/#{CF.account_name}/#{run_title}.json") @errors = resp['error']['message'] if resp['code'] != 200 return resp end |
.final_output(title) ⇒ Object
Returns Final Output of production Run
Usage Example:
CF::Run.final_output("run_title")
128 129 130 131 132 |
# File 'lib/cf/run.rb', line 128 def self.final_output(title) resp = get("/runs/#{CF.account_name}/#{title.downcase}/output.json") @errors = resp['error']['message'] if resp['code'] != 200 return resp['output'] end |
.find(title) ⇒ Object
Searches Run for the given “run_title”
Usage Example:
CF::Run.find("run_title")
160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/cf/run.rb', line 160 def self.find(title) resp = get("/runs/#{CF.account_name}/#{title.downcase}.json") if resp['code'] != 200 @errors = resp['error']['message'] resp['error'] = resp['error']['message'] resp.merge!('errors' => "#{resp['error']}") resp.delete('error') return nil else return resp end end |
.output(options = {}) ⇒ Object
Returns Output of production Run for any specific Station and for given Run Title
Usage Example:
CF::Run.output({:title => "run_title", :station => 2})
Will return output of second station
138 139 140 141 142 143 144 |
# File 'lib/cf/run.rb', line 138 def self.output(={}) station_no = [:station] title = [:title] resp = get("/runs/#{CF.account_name}/#{title.downcase}/output/#{station_no}.json") @errors = resp['error']['message'] if resp['code'] != 200 return resp['output'] end |
.progress(run_title) ⇒ Object
Returns progress of the production run
Usage Example:
progress = CF::Run.progress("run_title")
176 177 178 |
# File 'lib/cf/run.rb', line 176 def self.progress(run_title) get("/runs/#{CF.account_name}/#{run_title}/progress.json") end |
.progress_details(run_title) ⇒ Object
Returns progress details of the production run
Usage Example:
progress = CF::Run.progress_details("run_title")
187 188 189 190 |
# File 'lib/cf/run.rb', line 187 def self.progress_details(run_title) resp = get("/runs/#{CF.account_name}/#{run_title}/progress.json") return resp['progress'] end |
.resume(run_title) ⇒ Object
Resumes the paused production run
Usage Example:
resume_run = CF::Run.resume("run_title")
229 230 231 232 233 |
# File 'lib/cf/run.rb', line 229 def self.resume(run_title) resp = post("/runs/#{CF.account_name}/#{run_title}/resume.json") @errors = resp['error']['message'] if resp['code'] != 200 return resp end |
Instance Method Details
#final_output ⇒ Object
Returns Final Output of production Run
Usage Example:
run_object.final_output
119 120 121 122 123 |
# File 'lib/cf/run.rb', line 119 def final_output resp = self.class.get("/runs/#{CF.account_name}/#{self.title.downcase}/output.json") self.errors = resp['error']['message'] if resp['code'] != 200 return resp['output'] end |
#output(options = {}) ⇒ Object
Returns Output of Run object for any specific Station
Usage Example:
run_object.output(:station => 2)
Will return output of second station
150 151 152 153 154 155 |
# File 'lib/cf/run.rb', line 150 def output(={}) station_no = [:station] resp = self.class.get("/runs/#{CF.account_name}/#{self.title.downcase}/output/#{station_no}.json") self.errors = resp['error']['message'] if resp['code'] != 200 return resp['output'] end |
#progress ⇒ Object
:nodoc:
180 181 182 |
# File 'lib/cf/run.rb', line 180 def progress # :nodoc: self.class.get("/runs/#{CF.account_name}/#{self.title}/progress.json") end |
#progress_details ⇒ Object
:nodoc:
192 193 194 195 |
# File 'lib/cf/run.rb', line 192 def progress_details # :nodoc: resp = self.class.get("/runs/#{CF.account_name}/#{self.title}/progress.json") return resp['progress'] end |