Class: Dplyr::Cli
Instance Attribute Summary collapse
Instance Method Summary
collapse
#debug?, #logger, stderr, #stderr
Constructor Details
#initialize(stage, argv) ⇒ Cli
Returns a new instance of Cli.
11
12
13
14
|
# File 'lib/dplyr/cli.rb', line 11
def initialize(stage, argv)
@stage = stage
@argv = argv
end
|
Instance Attribute Details
#argv ⇒ Object
Returns the value of attribute argv.
10
11
12
|
# File 'lib/dplyr/cli.rb', line 10
def argv
@argv
end
|
#stage ⇒ Object
Returns the value of attribute stage.
10
11
12
|
# File 'lib/dplyr/cli.rb', line 10
def stage
@stage
end
|
Instance Method Details
#argv_str ⇒ Object
61
62
63
|
# File 'lib/dplyr/cli.rb', line 61
def argv_str
@argv_str ||= argv.join(' ')
end
|
#env_str ⇒ Object
53
54
55
56
57
58
59
|
# File 'lib/dplyr/cli.rb', line 53
def env_str
str = ""
stage_data[:env].each do |k,v|
str << %(DPLY_#{k.upcase}="#{v}" )
end
str
end
|
#hosts ⇒ Object
45
46
47
|
# File 'lib/dplyr/cli.rb', line 45
def hosts
stage_data[:hosts]
end
|
#parallel_jobs ⇒ Object
49
50
51
|
# File 'lib/dplyr/cli.rb', line 49
def parallel_jobs
stage_data[:parallel_runs]
end
|
#run ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/dplyr/cli.rb', line 16
def run
global_switches = []
global_switches << "--debug" if logger.debug?
case stage
when 'dev'
global_switches << "--no-config"
system "drake #{global_switches.join(" ")} #{argv_str}"
when 'local'
system "drake #{global_switches.join(" ")} #{argv_str}"
else
command = argv[0]
case command
when "list"
require 'pp'
pp hosts
when "first"
stage_data[:hosts] = [hosts.first] if hosts.size > 0
argv.shift
run_remote_task
else
run_remote_task
end
end
end
|
#run_remote_task ⇒ Object
65
66
67
68
|
# File 'lib/dplyr/cli.rb', line 65
def run_remote_task
task_runner = TaskRunner.new(hosts, argv_str, parallel_jobs: parallel_jobs)
task_runner.run
end
|
#stage_data ⇒ Object
41
42
43
|
# File 'lib/dplyr/cli.rb', line 41
def stage_data
@stage_data ||= StagesConfig.new.fetch(@stage).data
end
|