MCPcopy Create free account
hub / github.com/LBANN/lbann / __init__

Method __init__

python/lbann/launcher/batch_script.py:20–50  ·  view source on GitHub ↗

Construct batch script manager. Args: script_file (str): Script file. work_dir (str, optional): Working directory (default: current working directory). interpreter (str, optional): Script interpreter (default: /bin/bash).

(self,
                 script_file=None,
                 work_dir=os.getcwd(),
                 interpreter='/bin/bash')

Source from the content-addressed store, hash-verified

18 """
19
20 def __init__(self,
21 script_file=None,
22 work_dir=os.getcwd(),
23 interpreter='/bin/bash'):
24 """Construct batch script manager.
25
26 Args:
27 script_file (str): Script file.
28 work_dir (str, optional): Working directory
29 (default: current working directory).
30 interpreter (str, optional): Script interpreter
31 (default: /bin/bash).
32
33 """
34
35 # Lines in script are stored as lists of strings
36 self.header = []
37 self.body = []
38
39 # Construct file paths
40 self.work_dir = os.path.realpath(work_dir)
41 self.script_file = script_file
42 if not self.script_file:
43 self.script_file = os.path.join(self.work_dir, 'batch.sh')
44 self.script_file = os.path.realpath(self.script_file)
45 self.out_log_file = os.path.join(self.work_dir, 'out.log')
46 self.err_log_file = os.path.join(self.work_dir, 'err.log')
47
48 # Shebang line
49 if interpreter:
50 self.add_header_line('#!{}'.format(interpreter))
51
52 def add_header_line(self, line):
53 """Add line to script header.

Callers

nothing calls this directly

Calls 1

add_header_lineMethod · 0.95

Tested by

no test coverage detected