/
run_onto.py
40 lines (30 loc) · 950 Bytes
/
run_onto.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
29
30
31
32
33
34
35
36
37
38
39
40
# coding=utf-8
import os
import copy
opt = dict()
opt['dataset'] = 'dataset/OntoNotes'
devices = [1, 2, 4, 6]
def load_seeds(seed_file):
seeds = []
with open(seed_file, 'r') as f:
for line in f:
seeds.append(int(line.strip()))
return seeds
def generate_command(opt, log_path):
cmd = 'python -u bootstrap.py --local'
for opt, val in opt.items():
if val is not None and val != '':
cmd += ' --' + opt + ' ' + str(val)
cmd = 'nohup ' + cmd + ' > ' + log_path + ' 2>&1 &'
return cmd
def run(opt, log_path):
opt_ = copy.deepcopy(opt)
cmd = generate_command(opt_, log_path)
print('\n------Run following command------\n%s' % cmd)
os.system(cmd)
for i in range(6, 10):
device = devices[i % 4]
opt['device'] = device
opt['output_model_file'] = 'saved/onto_model_' + str(i+1)
log_path = 'logs/onto_abl_org_' + str(i+1) + '.txt'
run(opt, log_path)