Construct LSF batch script manager. Args: script_file (str): Script file. work_dir (str, optional): Working directory (default: current working directory). nodes (int, optional): Number of compute nodes (default: 1).
(self,
script_file=None,
work_dir=os.getcwd(),
nodes=1,
procs_per_node=1,
time_limit=None,
job_name=None,
partition=None,
account=None,
reservation=None,
launcher='jsrun',
launcher_args=[],
interpreter='/bin/bash')
| 9 | """Utility class to write LSF batch scripts.""" |
| 10 | |
| 11 | def __init__(self, |
| 12 | script_file=None, |
| 13 | work_dir=os.getcwd(), |
| 14 | nodes=1, |
| 15 | procs_per_node=1, |
| 16 | time_limit=None, |
| 17 | job_name=None, |
| 18 | partition=None, |
| 19 | account=None, |
| 20 | reservation=None, |
| 21 | launcher='jsrun', |
| 22 | launcher_args=[], |
| 23 | interpreter='/bin/bash'): |
| 24 | """Construct LSF 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 | nodes (int, optional): Number of compute nodes |
| 31 | (default: 1). |
| 32 | procs_per_node (int, optional): Parallel processes per |
| 33 | compute node (default: 1). |
| 34 | time_limit (int, optional): Job time limit, in minutes |
| 35 | (default: none). |
| 36 | job_name (str, optional): Job name (default: none). |
| 37 | partition (str, optional): Scheduler partition |
| 38 | (default: none). |
| 39 | account (str, optional): Scheduler account |
| 40 | (default: none). |
| 41 | reservation (str, optional): Scheduler advance reservation |
| 42 | (default: none). |
| 43 | launcher (str, optional): Parallel command launcher |
| 44 | (default: jsrun). |
| 45 | launcher_args (`Iterable` of `str`, optional): |
| 46 | Command-line arguments to jsrun. |
| 47 | interpreter (str, optional): Script interpreter |
| 48 | (default: /bin/bash). |
| 49 | |
| 50 | """ |
| 51 | super().__init__(script_file=script_file, |
| 52 | work_dir=work_dir, |
| 53 | interpreter=interpreter) |
| 54 | self.nodes = nodes |
| 55 | self.procs_per_node = procs_per_node |
| 56 | self.reservation = reservation |
| 57 | self.launcher = launcher |
| 58 | self.launcher_args = launcher_args |
| 59 | |
| 60 | # Configure header with LSF job options |
| 61 | self.add_header_line(f'#BSUB -cwd {self.work_dir}') |
| 62 | self.add_header_line(f'#BSUB -o {self.out_log_file}') |
| 63 | self.add_header_line(f'#BSUB -e {self.err_log_file}') |
| 64 | self.add_header_line(f'#BSUB -nnodes {nodes}') |
| 65 | if time_limit: |
| 66 | minutes = int(round(max(time_limit, 0))) |
| 67 | hours, minutes = divmod(minutes, 60) |
| 68 | self.add_header_line(f'#BSUB -W {hours}:{minutes:02}') |
nothing calls this directly
no test coverage detected