Class: ServerScripts::BatchJob
- Inherits:
-
Object
- Object
- ServerScripts::BatchJob
- Defined in:
- lib/server_scripts/batch_job.rb
Instance Attribute Summary collapse
-
#additional_commands ⇒ Object
Returns the value of attribute additional_commands.
-
#enable_intel_itac ⇒ Object
Returns the value of attribute enable_intel_itac.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#err_file ⇒ Object
Returns the value of attribute err_file.
-
#executable ⇒ Object
Returns the value of attribute executable.
-
#executor ⇒ Object
Returns the value of attribute executor.
-
#intel_vtune_fname ⇒ Object
Returns the value of attribute intel_vtune_fname.
-
#job_fname ⇒ Object
readonly
Returns the value of attribute job_fname.
-
#job_name ⇒ Object
Returns the value of attribute job_name.
-
#modules ⇒ Object
Returns the value of attribute modules.
-
#node_type ⇒ Object
Returns the value of attribute node_type.
-
#nodes ⇒ Object
Returns the value of attribute nodes.
-
#npernode ⇒ Object
Returns the value of attribute npernode.
-
#nprocs ⇒ Object
Returns the value of attribute nprocs.
-
#options ⇒ Object
Returns the value of attribute options.
-
#out_file ⇒ Object
Returns the value of attribute out_file.
-
#reservation_id ⇒ Object
Returns the value of attribute reservation_id.
-
#run_cmd ⇒ Object
Returns the value of attribute run_cmd.
-
#source_bashrc ⇒ Object
Returns the value of attribute source_bashrc.
-
#system ⇒ Object
readonly
Returns the value of attribute system.
-
#wall_time ⇒ Object
Returns the value of attribute wall_time.
Instance Method Summary collapse
-
#initialize(job_fname = "sample_job.sh") {|_self| ... } ⇒ BatchJob
constructor
A new instance of BatchJob.
- #set_env(var, value) ⇒ Object
- #submit! ⇒ Object
- #write_job_script! ⇒ Object
Constructor Details
#initialize(job_fname = "sample_job.sh") {|_self| ... } ⇒ BatchJob
Returns a new instance of BatchJob.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/server_scripts/batch_job.rb', line 24 def initialize job_fname="sample_job.sh" @job_fname = job_fname @job_name = "sample" @out_file = "sample_out.log" @err_file = "sample_err.log" @wall_time = "1:00:00" @node_type = NodeType::FULL @nodes = 1 @npernode = 1 @nprocs = nil @run_cmd = nil @executor = :vanilla @env = {} @executable = "./a.out" @job_script = nil @enable_intel_itac = false @additional_commands = [] @modules = [] @source_bashrc = true @reservation_id = nil yield self end |
Instance Attribute Details
#additional_commands ⇒ Object
Returns the value of attribute additional_commands.
13 14 15 |
# File 'lib/server_scripts/batch_job.rb', line 13 def additional_commands @additional_commands end |
#enable_intel_itac ⇒ Object
Returns the value of attribute enable_intel_itac.
14 15 16 |
# File 'lib/server_scripts/batch_job.rb', line 14 def enable_intel_itac @enable_intel_itac end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
20 21 22 |
# File 'lib/server_scripts/batch_job.rb', line 20 def env @env end |
#err_file ⇒ Object
Returns the value of attribute err_file.
5 6 7 |
# File 'lib/server_scripts/batch_job.rb', line 5 def err_file @err_file end |
#executable ⇒ Object
Returns the value of attribute executable.
12 13 14 |
# File 'lib/server_scripts/batch_job.rb', line 12 def executable @executable end |
#executor ⇒ Object
Returns the value of attribute executor.
12 13 14 |
# File 'lib/server_scripts/batch_job.rb', line 12 def executor @executor end |
#intel_vtune_fname ⇒ Object
Returns the value of attribute intel_vtune_fname.
15 16 17 |
# File 'lib/server_scripts/batch_job.rb', line 15 def intel_vtune_fname @intel_vtune_fname end |
#job_fname ⇒ Object (readonly)
Returns the value of attribute job_fname.
21 22 23 |
# File 'lib/server_scripts/batch_job.rb', line 21 def job_fname @job_fname end |
#job_name ⇒ Object
Returns the value of attribute job_name.
3 4 5 |
# File 'lib/server_scripts/batch_job.rb', line 3 def job_name @job_name end |
#modules ⇒ Object
Returns the value of attribute modules.
17 18 19 |
# File 'lib/server_scripts/batch_job.rb', line 17 def modules @modules end |
#node_type ⇒ Object
Returns the value of attribute node_type.
7 8 9 |
# File 'lib/server_scripts/batch_job.rb', line 7 def node_type @node_type end |
#nodes ⇒ Object
Returns the value of attribute nodes.
9 10 11 |
# File 'lib/server_scripts/batch_job.rb', line 9 def nodes @nodes end |
#npernode ⇒ Object
Returns the value of attribute npernode.
10 11 12 |
# File 'lib/server_scripts/batch_job.rb', line 10 def npernode @npernode end |
#nprocs ⇒ Object
Returns the value of attribute nprocs.
11 12 13 |
# File 'lib/server_scripts/batch_job.rb', line 11 def nprocs @nprocs end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/server_scripts/batch_job.rb', line 8 def @options end |
#out_file ⇒ Object
Returns the value of attribute out_file.
4 5 6 |
# File 'lib/server_scripts/batch_job.rb', line 4 def out_file @out_file end |
#reservation_id ⇒ Object
Returns the value of attribute reservation_id.
18 19 20 |
# File 'lib/server_scripts/batch_job.rb', line 18 def reservation_id @reservation_id end |
#run_cmd ⇒ Object
Returns the value of attribute run_cmd.
12 13 14 |
# File 'lib/server_scripts/batch_job.rb', line 12 def run_cmd @run_cmd end |
#source_bashrc ⇒ Object
Returns the value of attribute source_bashrc.
16 17 18 |
# File 'lib/server_scripts/batch_job.rb', line 16 def source_bashrc @source_bashrc end |
#system ⇒ Object (readonly)
Returns the value of attribute system.
22 23 24 |
# File 'lib/server_scripts/batch_job.rb', line 22 def system @system end |
#wall_time ⇒ Object
Returns the value of attribute wall_time.
6 7 8 |
# File 'lib/server_scripts/batch_job.rb', line 6 def wall_time @wall_time end |
Instance Method Details
#set_env(var, value) ⇒ Object
48 49 50 51 |
# File 'lib/server_scripts/batch_job.rb', line 48 def set_env var, value raise ArgumentError, "Env #{var} is already set to #{value}." if @env[var] @env[var] = value end |
#submit! ⇒ Object
58 59 60 61 62 63 |
# File 'lib/server_scripts/batch_job.rb', line 58 def submit! write_job_script! Kernel.system(@system.job_submit_cmd( batch_script: @job_fname, res_id: @reservation_id)) end |
#write_job_script! ⇒ Object
53 54 55 56 |
# File 'lib/server_scripts/batch_job.rb', line 53 def write_job_script! generate_job_script! unless @job_script File.write(@job_fname, @job_script) end |