-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsubmit.py
More file actions
69 lines (40 loc) · 1.41 KB
/
submit.py
File metadata and controls
69 lines (40 loc) · 1.41 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
47
48
49
50
51
52
import sys
import os,pdb,time
#######################################################################################
## relative to config
config_file='standard.yaml'
#cluster=True
#cluster=False
#######################################################################################
ckpt_dir = '../ckpt'
main_dirs = [ckpt_dir]
### Get job name
with open('config/'+config_file,'r') as f:
lines = f.readlines()
job_name = lines[0][:-1].split(': ')[1][1:-1]
### process config
config=config_file.split('/')
if len(config)==1:
filename = config[0]
else:
dirs,filename = config[0:-1], config[-1]
filename = filename.split('.')[0]
dirs.append(filename)
dirs.append('log')
for each_main_dir in main_dirs:
for ind, each_dir in enumerate(dirs):
each_dir = '/'.join( dirs[0:ind+1])
new_dir = os.path.join(each_main_dir, each_dir)
if not os.path.exists( new_dir ):
os.mkdir( new_dir )
print('create ckpt dir: ', each_main_dir, '/', each_dir)
time.ctime()
cur_time = time.strftime('_%b%d_%H-%M-%S')
#######################################################################################
### run script
cmd = '''\
LOG="''' + ckpt_dir + '/' + '/'.join(dirs) + '/' + filename + '''-`date +'%Y-%m-%d_%H-%M-%S'`_train"
echo $LOG ;
python run.py --mode train --cfg ''' + config_file + ''' --time ''' + cur_time + '''$2>&1 | tee ${LOG}
'''
os.system(cmd)