Class: AgentC::Batch
- Inherits:
-
Object
- Object
- AgentC::Batch
- Defined in:
- lib/agent_c/batch.rb
Instance Method Summary collapse
- #abort! ⇒ Object
- #add_task(record) ⇒ Object
- #call ⇒ Object
-
#initialize(store:, workspace: nil, repo: nil, session:, record_type:, pipeline:, git: ->(dir) { Utils::Git.new(dir) }) ⇒ Batch
constructor
A new instance of Batch.
- #report ⇒ Object
- #session ⇒ Object
- #store ⇒ Object
- #workspace ⇒ Object
Constructor Details
#initialize(store:, workspace: nil, repo: nil, session:, record_type:, pipeline:, git: ->(dir) { Utils::Git.new(dir) }) ⇒ Batch
Returns a new instance of Batch.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/agent_c/batch.rb', line 5 def initialize( store:, workspace: nil, repo: nil, session:, record_type:, pipeline:, git: ->(dir) { Utils::Git.new(dir) } ) # for context @store_config = store @workspace_config = workspace @repo_config = repo @session_config = session # for Batch @record_type = record_type @pipeline_class = pipeline @git = git end |
Instance Method Details
#abort! ⇒ Object
34 35 36 |
# File 'lib/agent_c/batch.rb', line 34 def abort! processor.abort! end |
#add_task(record) ⇒ Object
30 31 32 |
# File 'lib/agent_c/batch.rb', line 30 def add_task(record) processor.add_task(record, @record_type) end |
#call ⇒ Object
26 27 28 |
# File 'lib/agent_c/batch.rb', line 26 def call processor.call end |
#report ⇒ Object
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 |
# File 'lib/agent_c/batch.rb', line 38 def report out = StringIO.new tasks = store.task.all succeeded_count = tasks.count { |task| task.done? } pending_count = tasks.count { |task| task.pending? } failed_count = tasks.count { |task| task.failed? } out.puts "Succeeded: #{succeeded_count}" out.puts "Pending: #{pending_count}" out.puts "Failed: #{failed_count}" cost_data = session.cost out.puts "Run cost: $#{'%.2f' % cost_data.run}" out.puts "Project total cost: $#{'%.2f' % cost_data.project}" if failed_count > 0 out.puts "\nFirst #{[failed_count, 3].min} failed task(s):" tasks.select { |task| task.failed? }.first(3).each do |task| out.puts "- #{task.}" end end out.string end |
#session ⇒ Object
72 73 74 |
# File 'lib/agent_c/batch.rb', line 72 def session context.session end |
#store ⇒ Object
64 65 66 |
# File 'lib/agent_c/batch.rb', line 64 def store context.store end |
#workspace ⇒ Object
68 69 70 |
# File 'lib/agent_c/batch.rb', line 68 def workspace context.workspace end |