-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhcd_batch
More file actions
executable file
·47 lines (36 loc) · 1.76 KB
/
hcd_batch
File metadata and controls
executable file
·47 lines (36 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
# -----------------------------------------------------
# AUTO-GENERATE BATCH SCRIPT TO RUN THE H&CD WORKFLOW,
# AND LAUNCH IT VIA QSUB
# -----------------------------------------------------
# EXAMPLE:
# hcd_batch -n 1 -t 1 -e mireille.schneider@iter.org -q all -c tests/data/batch_test
import argparse, subprocess
from datetime import datetime
# Management of input arguments
parser = argparse.ArgumentParser(description='---- Run the H&CD workflow without the interface')
parser.add_argument("-n","--nproc",help="Number of processors", required=True)
parser.add_argument("-t","--time",help="Required cpu time in hours", required=True)
parser.add_argument("-e","--email",help="E-mail where to send job resulting status", required=True)
parser.add_argument("-q","--queue",help="Name of the batch queue", required=True)
parser.add_argument("-c","--config_folder",help="input configuration folder", required=True)
args = vars(parser.parse_args())
nproc = args["nproc"]
time = args["time"]
email = args["email"]
queue = args["queue"]
config_folder = args["config_folder"]
auto_batch_name = str('auto_batch_'+datetime.now().strftime('%y%m%d_%H%M%S'))
with open(auto_batch_name, 'w') as file:
file.write('#!/bin/sh\n\n')
file.write('#SBATCH --ntasks-per-node='+nproc+'\n')
file.write('#SBATCH --cpus-per-task=1'+'\n')
file.write('#SBATCH --time='+time+':00:00'+'\n')
file.write('#SBATCH --mail-user='+email+'\n')
file.write('#SBATCH --mail-type=END'+'\n')
file.write('#SBATCH --job-name=HCD_wf'+'\n')
file.write('#SBATCH --partition='+queue+'\n\n')
file.write('hcd_nogui -c '+config_folder+'\n\n')
file.close()
subprocess.call(['qsub '+auto_batch_name],shell=True)
print(auto_batch_name+' submitted.')