Class: ServerScripts::BatchJob

Inherits:
Object
  • Object
show all
Defined in:
lib/server_scripts/batch_job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_fname = "sample_job.sh") {|_self| ... } ⇒ BatchJob

Returns a new instance of BatchJob.

Yields:

  • (_self)

Yield Parameters:



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_commandsObject

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_itacObject

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

#envObject (readonly)

Returns the value of attribute env.



20
21
22
# File 'lib/server_scripts/batch_job.rb', line 20

def env
  @env
end

#err_fileObject

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

#executableObject

Returns the value of attribute executable.



12
13
14
# File 'lib/server_scripts/batch_job.rb', line 12

def executable
  @executable
end

#executorObject

Returns the value of attribute executor.



12
13
14
# File 'lib/server_scripts/batch_job.rb', line 12

def executor
  @executor
end

#intel_vtune_fnameObject

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_fnameObject (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_nameObject

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

#modulesObject

Returns the value of attribute modules.



17
18
19
# File 'lib/server_scripts/batch_job.rb', line 17

def modules
  @modules
end

#node_typeObject

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

#nodesObject

Returns the value of attribute nodes.



9
10
11
# File 'lib/server_scripts/batch_job.rb', line 9

def nodes
  @nodes
end

#npernodeObject

Returns the value of attribute npernode.



10
11
12
# File 'lib/server_scripts/batch_job.rb', line 10

def npernode
  @npernode
end

#nprocsObject

Returns the value of attribute nprocs.



11
12
13
# File 'lib/server_scripts/batch_job.rb', line 11

def nprocs
  @nprocs
end

#optionsObject

Returns the value of attribute options.



8
9
10
# File 'lib/server_scripts/batch_job.rb', line 8

def options
  @options
end

#out_fileObject

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_idObject

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_cmdObject

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_bashrcObject

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

#systemObject (readonly)

Returns the value of attribute system.



22
23
24
# File 'lib/server_scripts/batch_job.rb', line 22

def system
  @system
end

#wall_timeObject

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

Raises:

  • (ArgumentError)


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