-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakejob.py
61 lines (46 loc) · 1.55 KB
/
makejob.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import os, sys
import argparse
import json
parser = parser = argparse.ArgumentParser(description='Launch distributed mxnet models on vagrant')
parser.add_argument('-c', '--copy', type=str)
parser.add_argument('-p', '--pretty', action='store_true')
parser.add_argument('-n', '--name', required=True, type=str)
parser.add_argument('-S', '--script', required=True, type=str)
parser.add_argument('-d', '--dataset', required=True, type=str)
parser.add_argument('-e', '--epochs', type=int)
parser.add_argument('-b', '--batch-size', type=int)
parser.add_argument('-s', '--sequence-length', type=int)
parser.add_argument('-t', '--test-split', type=float)
args, unknown = parser.parse_known_args()
layout = {
'script': args.script,
'dataset': args.dataset,
'epochs': 10,
'batch-size': 32,
'sequence-length': 10,
'test-split': 0.3
}
if args.copy:
if args.copy == args.name:
parser.error('--name must not match --copy.')
copy = args.copy
if not str.endswith(copy, '.json'):
copy = '%s.json' % (copy)
with open(copy) as f:
layout = json.load(f)
if args.epochs:
layout['epochs'] = args.epochs
if args.batch_size:
layout['batch-size'] = args.batch_size
if args.sequence_length:
layout['sequence-length'] = args.sequence_length
if args.test_split:
layout['test-split'] = args.sequence_length
job = args.name
if not str.endswith(job, '.json'):
job = '%s.json' % (job)
with open(job, 'w') as f:
if args.pretty:
f.write(json.dumps(layout, indent=4, sort_keys=True))
else:
f.write(json.dumps(layout))