Class: Hasta::Tasks::Runner
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Hasta::Tasks::Runner
- Includes:
- Rake::DSL
- Defined in:
- lib/hasta/tasks/runner.rb
Overview
Rakes task that runs a local test of an EMR job
Instance Attribute Summary collapse
-
#definition_file ⇒ Object
Path to the AWS Data Pipeline definition file.
-
#job_id ⇒ Object
The id of the EMR job to perform.
-
#name ⇒ Object
Name of task.
-
#project_root ⇒ Object
The root directory of the project containing the EMR code that is being tested.
-
#scheduled_start_time ⇒ Object
The Scheduled Start Time to use when evaluating the definition.
-
#verbose ⇒ Object
Use verbose output.
Instance Method Summary collapse
-
#initialize(*args, &task_block) ⇒ Runner
constructor
A new instance of Runner.
- #run_task(verbose) ⇒ Object
- #setup_ivars(args) ⇒ Object
Constructor Details
#initialize(*args, &task_block) ⇒ Runner
Returns a new instance of Runner.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/hasta/tasks/runner.rb', line 45 def initialize(*args, &task_block) setup_ivars(args) desc "Runs the specified EMR job" task name, [:job_id, :scheduled_start_time] do |_, task_args| RakeFileUtils.send(:verbose, verbose) do if task_block task_block.call(*[self, task_args].slice(0, task_block.arity)) end run_task verbose end end end |
Instance Attribute Details
#definition_file ⇒ Object
Path to the AWS Data Pipeline definition file
24 25 26 |
# File 'lib/hasta/tasks/runner.rb', line 24 def definition_file @definition_file end |
#job_id ⇒ Object
The id of the EMR job to perform
33 34 35 |
# File 'lib/hasta/tasks/runner.rb', line 33 def job_id @job_id end |
#name ⇒ Object
Name of task.
default:
:runner
21 22 23 |
# File 'lib/hasta/tasks/runner.rb', line 21 def name @name end |
#project_root ⇒ Object
The root directory of the project containing the EMR code that is being tested
36 37 38 |
# File 'lib/hasta/tasks/runner.rb', line 36 def project_root @project_root end |
#scheduled_start_time ⇒ Object
The Scheduled Start Time to use when evaluating the definition
default:
Time.now
30 31 32 |
# File 'lib/hasta/tasks/runner.rb', line 30 def scheduled_start_time @scheduled_start_time end |
#verbose ⇒ Object
Use verbose output. If this is set to true, the task will print the local and remote paths of each step file it uploads to S3.
default:
true
43 44 45 |
# File 'lib/hasta/tasks/runner.rb', line 43 def verbose @verbose end |
Instance Method Details
#run_task(verbose) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/hasta/tasks/runner.rb', line 67 def run_task(verbose) Hasta.configure do |config| config.project_root = project_root end definition = Hasta::EmrJobDefinition.load(definition_file, job_id, scheduled_start_time) runner = Hasta::Runner.new(definition.id, definition.mapper, definition.reducer) result = runner.run( definition.data_sources, definition.data_sink, definition.ruby_files, definition.env ) end |
#setup_ivars(args) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/hasta/tasks/runner.rb', line 60 def setup_ivars(args) @name = args.shift || :runner @verbose = true @path = "definitions" @scheduled_start_time = Time.now end |