Class: Rukawa::Cli
- Inherits:
-
Thor
- Object
- Thor
- Rukawa::Cli
- Defined in:
- lib/rukawa/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #__print_version ⇒ Object
- #_run(job_net_name, *job_name) ⇒ Object
- #graph(job_net_name, *job_name) ⇒ Object
- #list ⇒ Object
- #list_job ⇒ Object
- #run_job(*job_name) ⇒ Object
Class Method Details
.base_options ⇒ Object
8 9 10 11 |
# File 'lib/rukawa/cli.rb', line 8 def self. method_option :config, type: :string, default: nil, desc: "If this options is not set, try to load ./rukawa.rb" method_option :job_dirs, type: :array, default: [], desc: "Load job directories", banner: "JOB_DIR1 JOB_DIR2" end |
.run_options ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rukawa/cli.rb', line 13 def self. method_option :concurrency, aliases: "-c", type: :numeric, default: nil, desc: "Default: cpu count" method_option :variables, aliases: "--var", type: :hash, default: {}, banner: "KEY:VALUE KEY:VALUE" method_option :varfile, type: :string, default: nil, desc: "variable definition file. ex (variables.yml, variables.json)" method_option :batch, aliases: "-b", type: :boolean, default: false, desc: "If batch mode, not display running status" method_option :log, aliases: "-l", type: :string, desc: "Default: ./rukawa.log" method_option :stdout, type: :boolean, default: false, desc: "Output log to stdout" method_option :syslog, type: :boolean, default: false, desc: "Output log to syslog" method_option :dot, aliases: "-d", type: :string, default: nil, desc: "Output job status by dot format" method_option :format, aliases: "-f", type: :string, desc: "Output job status format: png, svg, pdf, ... etc" method_option :refresh_interval, aliases: "-r", type: :numeric, default: 3, desc: "Refresh interval for running status information" end |
Instance Method Details
#__print_version ⇒ Object
107 108 109 |
# File 'lib/rukawa/cli.rb', line 107 def __print_version puts "rukawa #{Rukawa::VERSION}" end |
#_run(job_net_name, *job_name) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rukawa/cli.rb', line 30 def _run(job_net_name, *job_name) load_config set_logger set_concurrency load_job_definitions job_net_class = get_class(job_net_name) job_classes = job_name.map { |name| get_class(name) } job_net = job_net_class.new(variables: variables, resume_job_classes: job_classes) result = Runner.run(job_net, [:batch], [:refresh_interval]) if [:dot] job_net.output_dot([:dot], format: [:format]) end unless result puts "\nIf you want to retry, run following command." failed_jobs = job_net.dag.jobs.each_with_object([]) { |j, arr| arr << j.class.to_s if j.state == Rukawa::State::Error } puts " rukawa run #{job_net_name} #{failed_jobs.join(" ")}" exit 1 end end |
#graph(job_net_name, *job_name) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/rukawa/cli.rb', line 57 def graph(job_net_name, *job_name) load_config load_job_definitions job_net_class = get_class(job_net_name) job_classes = job_name.map { |name| get_class(name) } job_net = job_net_class.new(resume_job_classes: job_classes) job_net.output_dot([:output], format: [:format]) end |
#list ⇒ Object
91 92 93 94 95 |
# File 'lib/rukawa/cli.rb', line 91 def list load_config load_job_definitions Rukawa::Overview.list_job_net(with_jobs: [:jobs]) end |
#list_job ⇒ Object
99 100 101 102 103 |
# File 'lib/rukawa/cli.rb', line 99 def list_job load_config load_job_definitions Rukawa::Overview.list_job end |
#run_job(*job_name) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/rukawa/cli.rb', line 70 def run_job(*job_name) load_config set_logger set_concurrency load_job_definitions job_classes = job_name.map { |name| get_class(name) } job_net_class = anonymous_job_net_class(*job_classes) job_net = job_net_class.new result = Runner.run(job_net, [:batch], [:refresh_interval]) if [:dot] job_net.output_dot([:dot]) end exit 1 unless result end |