-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
56 lines (43 loc) · 1.35 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
import subprocess
import time
sys.path.insert(0, 'src/data')
sys.path.insert(0, 'src/analysis')
sys.path.insert(0, 'src/model')
from etl import get_data
from eda import analyze_data
from model import train
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.
'''
data = None
if 'data' in targets:
with open('config/data-params.json', 'r', encoding = "utf-8") as fh:
data_cfg = json.load(fh)
# make the data target
data = get_data(**data_cfg)
if 'analysis' in targets:
with open('config/analysis-params.json') as fh:
analysis_cfg = json.load(fh)
# make the data target
analyze_data(data, **analysis_cfg)
if 'model' in targets:
with open('config/model-params.json') as fh:
model_cfg = json.load(fh)
# make the data target
train(**model_cfg)
return
if __name__ == '__main__':
# run via:
# python main.py data model
targets = sys.argv[1:]
print("The arguments are:", str(sys.argv))
print("The name of the script:", sys.argv[0])
print("Number of arguments:", len(sys.argv))
print("targets:", targets)
main(targets)