-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
40 lines (31 loc) · 1.42 KB
/
main.py
File metadata and controls
40 lines (31 loc) · 1.42 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
import os
import argparse
import sys
sys.path.insert(0, '/')
import constants
MODELS = ['LGBM', 'LSTM', 'CoxPHM']
STEPS = ['tune', 'train', 'eval']
model_parser = argparse.ArgumentParser(description='Execute model training and testing pipeline. When called '
'without any arguments, execute all pipeline steps for all models.')
model_parser.add_argument('--model', metavar='MODEL_NAME', choices=MODELS,
help='specify a model (must be one of {LGBM, LSTM, CoxPHM})')
model_parser.add_argument('--step', metavar='STEP_NAME', choices=STEPS,
help='the step in the pipeline to execute (must be one of {tune, train, eval})')
model_parser.add_argument('--n_cpus', metavar='N_CPUS', type=int, default=1,
help='number of CPUs to use (default 1)')
model_parser.add_argument('--n_gpus', metavar='N_GPUS', type=int, default=1,
help='number of GPUs to use (default 1)')
args = model_parser.parse_args()
if args.model is None:
models_to_include = MODELS
else:
models_to_include = [args.model]
if args.step is None:
steps_to_include = STEPS
else:
steps_to_include = [args.step]
os.environ['N_CPUS'] = str(args.n_cpus)
os.environ['N_GPUS'] = str(args.n_gpus)
for model in models_to_include:
for step in steps_to_include:
os.system('python3 src/models/{}/{}_{}.py'.format(model, step, model))