Class: Cnvrg::JobCli
Instance Method Summary
collapse
banner, subcommand_prefix
Instance Method Details
#install_reqs ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/cnvrg/job_cli.rb', line 38
def install_reqs
cli = Cnvrg::CLI.new
cli.log_start(__method__, args, options)
@project = Project.new(nil, owner: ENV['CNVRG_OWNER'], slug: ENV['CNVRG_PROJECT'])
@executer = Helpers::Executer.new(project: @project, job_type: ENV['CNVRG_JOB_TYPE'], job_id: ENV['CNVRG_JOB_ID'])
commands = @executer.get_requirements_commands
@executer.execute_cmds(commands)
end
|
#log(*logs) ⇒ Object
8
9
10
11
12
13
14
15
16
|
# File 'lib/cnvrg/job_cli.rb', line 8
def log(*logs)
Cnvrg::CLI.new.log_start(__method__, args, options)
@project = Project.new(owner: ENV['CNVRG_OWNER'], slug: ENV['CNVRG_PROJECT'])
if options['restart'] == @project.check_job_pod_restart[0] or options['step'] == "ready"
@project.job_log(logs, level: options['level'], step: options['step'])
else
@project.job_log(nil, level: options['level'], step: options['step'])
end
end
|
#poll_commands ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/cnvrg/job_cli.rb', line 48
def poll_commands
cli = Cnvrg::CLI.new
cli.log_start(__method__, args, options)
@project = Project.new(nil, owner: ENV['CNVRG_OWNER'], slug: ENV['CNVRG_PROJECT'])
@executer = Helpers::Executer.new(project: @project, job_type: ENV['CNVRG_JOB_TYPE'], job_id: ENV['CNVRG_JOB_ID'])
while true
begin
commands = @executer.get_commands
@executer.execute_cmds(commands)
rescue => e
Cnvrg::Logger.log_error(e)
end
sleep 10
end
end
|
#pre_pod_restart ⇒ Object
86
87
88
89
90
|
# File 'lib/cnvrg/job_cli.rb', line 86
def pre_pod_restart
Cnvrg::CLI.new.log_start(__method__, args, options)
@project = Project.new(owner: ENV['CNVRG_OWNER'], slug: ENV['CNVRG_PROJECT'])
@project.pre_job_pod_restart
end
|
#requirements ⇒ Object
30
31
32
33
34
35
|
# File 'lib/cnvrg/job_cli.rb', line 30
def requirements
cli = Cnvrg::CLI.new
cli.log_start(__method__, args, options)
project_dir = cli.get_project_home
@project = Project.new(project_dir, owner: ENV['CNVRG_OWNER'], slug: ENV['CNVRG_PROJECT'])
end
|
#run_command ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/cnvrg/job_cli.rb', line 66
def run_command
Cnvrg::Logger.info("in run command")
cli = Cnvrg::CLI.new
cli.log_start(__method__, args, options)
command_slug = options['command_slug']
@project = Project.new(nil, owner: ENV['CNVRG_OWNER'], slug: ENV['CNVRG_PROJECT'])
@executer = Helpers::Executer.new(project: @project, job_type: ENV['CNVRG_JOB_TYPE'], job_id: ENV['CNVRG_JOB_ID'])
command = @executer.get_command(command_slug)
@executer.monitor_command(command, command_slug)
end
|
#set_pod_restart ⇒ Object
79
80
81
82
83
|
# File 'lib/cnvrg/job_cli.rb', line 79
def set_pod_restart
Cnvrg::CLI.new.log_start(__method__, args, options)
@project = Project.new(owner: ENV['CNVRG_OWNER'], slug: ENV['CNVRG_PROJECT'])
@project.set_job_pod_restart
end
|
#start(*logs) ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/cnvrg/job_cli.rb', line 20
def start(*logs)
cli = Cnvrg::CLI.new
cli.log_start(__method__, args, options)
@project = Project.new(nil, owner: ENV['CNVRG_OWNER'], slug: ENV['CNVRG_PROJECT'])
@executer = Helpers::Executer.new(project: @project, job_type: ENV['CNVRG_JOB_TYPE'], job_id: ENV['CNVRG_JOB_ID'])
commands = @executer.fetch_commands
@executer.execute_cmds(commands)
end
|
#started ⇒ Object
93
94
95
96
97
|
# File 'lib/cnvrg/job_cli.rb', line 93
def started
Cnvrg::CLI.new.log_start(__method__, args, options)
@project = Project.new(owner: ENV['CNVRG_OWNER'], slug: ENV['CNVRG_PROJECT'])
@project.set_job_started
end
|