-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcreate_job.py
28 lines (25 loc) · 1.11 KB
/
create_job.py
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
import os
if __name__ == '__main__':
main_code = 'run_FFN.py'
config_path = 'configs/IPCA_FFN'
logdir_path = 'model/IPCA_FFN'
version = 'v1'
notification = True
sep = '='
options = ['--config', '--logdir', '--nFactor']
nFactor_list = [i+1 for i in range(20)]
config_list = sorted([item for item in os.listdir(config_path) if item.endswith('.json')])
config_count = len(config_list)
for job_id in range(config_count):
config_file = config_list[job_id]
logdir_path_config = os.path.join(logdir_path, version, config_file.rstrip('.json'))
with open('job_%d.sh' %job_id, 'w') as file:
cmd = 'mkdir -p ' + logdir_path_config
file.write(cmd+'\n')
for nFactor in nFactor_list:
values = [os.path.join(config_path, config_file), logdir_path_config, str(nFactor)]
cmd = ' '.join(['python3', main_code] + [sep.join([option, value]) for option, value in zip(options, values)])
file.write(cmd+'\n')
if notification:
cmd = 'python3 ~/tool/sendEmail.py --FROM lychSendOnly@hotmail.com --TO lych@stanford.edu --p send1Email --s Job\ %d\ Finished! --MSG job_%d.sh' %(job_id, job_id)
file.write(cmd+'\n')