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

Method write

python/lbann/launcher/batch_script.py:108–138  ·  view source on GitHub ↗

Write script to file. The working directory is created if needed. Args: overwrite (bool): Whether to overwrite script file if it already exists (default: false).

(self, overwrite=False)

Source from the content-addressed store, hash-verified

106 )
107
108 def write(self, overwrite=False):
109 """Write script to file.
110
111 The working directory is created if needed.
112
113 Args:
114 overwrite (bool): Whether to overwrite script file if it
115 already exists (default: false).
116
117 """
118
119 # Create directories if needed
120 os.makedirs(self.work_dir, exist_ok=True)
121 os.makedirs(os.path.dirname(self.script_file), exist_ok=True)
122
123 # Check if script file already exists
124 if not overwrite and os.path.isfile(self.script_file):
125 raise RuntimeError('Attempted to write batch script to {}, '
126 'but it already exists'
127 .format(self.script_file))
128
129 # Write script to file
130 with open(self.script_file, 'w') as f:
131 for line in self.header:
132 f.write('{}\n'.format(line))
133 f.write('\n')
134 for line in self.body:
135 f.write('{}\n'.format(line))
136
137 # Make script file executable
138 os.chmod(self.script_file, 0o755)
139
140 def run(self, overwrite=False):
141 """Execute the script.

Callers 11

runMethod · 0.95
grid_searchFunction · 0.45
runFunction · 0.45
save_prototextFunction · 0.45
text2binFunction · 0.45
bin2textFunction · 0.45
submitMethod · 0.45
submitMethod · 0.45
submitMethod · 0.45
runFunction · 0.45
submitMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected