Class: ServerScripts::BatchJob

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_fname) {|_self| ... } ⇒ BatchJob

Returns a new instance of BatchJob.

Yields:

  • (_self)

Yield Parameters:



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/server_scripts.rb', line 50

def initialize job_fname
  @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

  yield self
end

Instance Attribute Details

#additional_commandsObject

Returns the value of attribute additional_commands.



40
41
42
# File 'lib/server_scripts.rb', line 40

def additional_commands
  @additional_commands
end

#enable_intel_itacObject

Returns the value of attribute enable_intel_itac.



41
42
43
# File 'lib/server_scripts.rb', line 41

def enable_intel_itac
  @enable_intel_itac
end

#envObject (readonly)

Returns the value of attribute env.



46
47
48
# File 'lib/server_scripts.rb', line 46

def env
  @env
end

#err_fileObject

Returns the value of attribute err_file.



32
33
34
# File 'lib/server_scripts.rb', line 32

def err_file
  @err_file
end

#executableObject

Returns the value of attribute executable.



39
40
41
# File 'lib/server_scripts.rb', line 39

def executable
  @executable
end

#executorObject

Returns the value of attribute executor.



39
40
41
# File 'lib/server_scripts.rb', line 39

def executor
  @executor
end

#intel_vtune_fnameObject

Returns the value of attribute intel_vtune_fname.



42
43
44
# File 'lib/server_scripts.rb', line 42

def intel_vtune_fname
  @intel_vtune_fname
end

#job_fnameObject (readonly)

Returns the value of attribute job_fname.



47
48
49
# File 'lib/server_scripts.rb', line 47

def job_fname
  @job_fname
end

#job_nameObject

Returns the value of attribute job_name.



30
31
32
# File 'lib/server_scripts.rb', line 30

def job_name
  @job_name
end

#modulesObject

Returns the value of attribute modules.



44
45
46
# File 'lib/server_scripts.rb', line 44

def modules
  @modules
end

#node_typeObject

Returns the value of attribute node_type.



34
35
36
# File 'lib/server_scripts.rb', line 34

def node_type
  @node_type
end

#nodesObject

Returns the value of attribute nodes.



36
37
38
# File 'lib/server_scripts.rb', line 36

def nodes
  @nodes
end

#npernodeObject

Returns the value of attribute npernode.



37
38
39
# File 'lib/server_scripts.rb', line 37

def npernode
  @npernode
end

#nprocsObject

Returns the value of attribute nprocs.



38
39
40
# File 'lib/server_scripts.rb', line 38

def nprocs
  @nprocs
end

#optionsObject

Returns the value of attribute options.



35
36
37
# File 'lib/server_scripts.rb', line 35

def options
  @options
end

#out_fileObject

Returns the value of attribute out_file.



31
32
33
# File 'lib/server_scripts.rb', line 31

def out_file
  @out_file
end

#run_cmdObject

Returns the value of attribute run_cmd.



39
40
41
# File 'lib/server_scripts.rb', line 39

def run_cmd
  @run_cmd
end

#source_bashrcObject

Returns the value of attribute source_bashrc.



43
44
45
# File 'lib/server_scripts.rb', line 43

def source_bashrc
  @source_bashrc
end

#systemObject (readonly)

Returns the value of attribute system.



48
49
50
# File 'lib/server_scripts.rb', line 48

def system
  @system
end

#wall_timeObject

Returns the value of attribute wall_time.



33
34
35
# File 'lib/server_scripts.rb', line 33

def wall_time
  @wall_time
end

Instance Method Details

#set_env(var, value) ⇒ Object

Raises:

  • (ArgumentError)


73
74
75
76
# File 'lib/server_scripts.rb', line 73

def set_env var, value
  raise ArgumentError, "Env #{var} is already set to #{value}." if @env[var]
  @env[var] = value
end

#submit!Object



83
84
85
86
# File 'lib/server_scripts.rb', line 83

def submit!
  write_job_script!
  Kernel.system(@system.job_submit_cmd(batch_script: @job_fname))
end

#write_job_script!Object



78
79
80
81
# File 'lib/server_scripts.rb', line 78

def write_job_script!
  generate_job_script! unless @job_script
  File.write(@job_fname, @job_script)      
end