generated from ucsd-ets/datahub-example-notebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
56 lines (42 loc) · 1.36 KB
/
run.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
#!/usr/bin/env python
import sys
import json
sys.path.insert(0, 'src/data')
sys.path.insert(0, 'src/analysis')
sys.path.insert(0, 'src/model')
from etl import get_all_databases
from analysis import get_cond_probs
from model import build
def main(targets):
'''
Runs the main project pipeline logic, given the targets.
targets must contain: 'data', 'analysis', 'model'.
`main` runs the targets in order of data=>analysis=>model.
'''
if 'data' in targets:
with open('config/data-params.json') as fh:
data_cfg = json.load(fh)
# make the data target
data = get_all_databases(**data_cfg)
string_df = data[0]
ull_df = data[1]
if 'analysis' in targets:
with open('config/analysis-params.json') as fh:
analysis_cfg = json.load(fh)
# make the data target
get_cond_probs(string_df)
if 'model' in targets:
with open('config/model-params.json') as fh:
model_cfg = json.load(fh)
# make the data target
build(string_df, False, **model_cfg)
if 'test' in targets:
data = get_all_databases('test/testdata')
string_df = data[0]
build(string_df, True, .20, 'data/out/')
return
if __name__ == '__main__':
# run via:
# python main.py data model
targets = sys.argv[1:]
main(targets)