-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_reference_json.py
41 lines (29 loc) · 1.11 KB
/
create_reference_json.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
41
from collections import OrderedDict
import os
import json
import argparse
parser = argparse.ArgumentParser(description='')
parser.add_argument('-modeldir', required=True)
args = parser.parse_args()
exclude_ids = set([])
src_file = "src/create_references.py"
_dataset = ['paws', 'sst2-eq', 'sst2-new', 'rte-eq', 'mrpc-new', 'qnli-eq', 'qqp-new']
_ckpt = [os.path.join(args.modeldir, name) for name in os.listdir(args.modeldir) if os.path.isdir(os.path.join(args.modeldir, name)) and 'Incorrect' not in os.path.join(args.modeldir, name)]
i, count = 0, 0
set_configs = set()
for ckpt in _ckpt:
for dataset in _dataset:
config = OrderedDict()
config['src_file'] = src_file
config['ckpt'] = ckpt
config['dataset'] = dataset
config['ebs'] = 512
if i not in exclude_ids:
set_configs.add(json.dumps(config))
i += 1
with open("precommands.json", 'w') as f:
for s in set_configs:
count += 1
f.write(s + "\n")
print("Inserting {}".format(count), end="\r")
print('\nInserted {} in precommands.json. Complete'.format(count))