Submit batch job. The script file is written before being submitted. Args: overwrite (bool): Whether to overwrite script file if it already exists (default: False). Returns: int: Exit status from script.
(self, overwrite=False)
| 130 | self.add_command(args) |
| 131 | |
| 132 | def submit(self, overwrite=False): |
| 133 | """Submit batch job. |
| 134 | |
| 135 | The script file is written before being submitted. |
| 136 | |
| 137 | Args: |
| 138 | overwrite (bool): Whether to overwrite script file if it |
| 139 | already exists (default: False). |
| 140 | |
| 141 | Returns: |
| 142 | int: Exit status from script. |
| 143 | |
| 144 | """ |
| 145 | |
| 146 | # Construct script file |
| 147 | self.write(overwrite=overwrite) |
| 148 | |
| 149 | # Submit batch script and pipe output to log files |
| 150 | run_proc = subprocess.Popen(['pjsub', self.script_file], |
| 151 | stdout=subprocess.PIPE, |
| 152 | stderr=subprocess.PIPE, |
| 153 | cwd=self.work_dir) |
| 154 | out_proc = subprocess.Popen(['tee', self.out_log_file], |
| 155 | stdin=run_proc.stdout, |
| 156 | cwd=self.work_dir) |
| 157 | err_proc = subprocess.Popen(['tee', self.err_log_file], |
| 158 | stdin=run_proc.stderr, |
| 159 | cwd=self.work_dir) |
| 160 | run_proc.stdout.close() |
| 161 | run_proc.stderr.close() |
| 162 | run_proc.wait() |
| 163 | out_proc.wait() |
| 164 | err_proc.wait() |
| 165 | return run_proc.returncode |