-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_etl.py
75 lines (60 loc) · 1.68 KB
/
main_etl.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import argparse
import os
import yaml
# load config variables to environment variables
with open('global_config.yaml', 'r') as f:
config = yaml.safe_load(f)
for key in config:
os.environ[key] = str(config[key])
from anime_recommender.etl import APIExtractor, APIProcessor, APITransformer
def get_args():
parser = argparse.ArgumentParser(
description='ETL Arguments',
formatter_class=argparse.RawTextHelpFormatter,
)
parser.add_argument(
'-e',
'--extract',
required=False,
action='store_true',
default=False,
help='''Optional. Extract data from API.''',
)
parser.add_argument(
'-p',
'--process',
required=False,
action='store_true',
default=False,
help='''Optional. Process data.''',
)
parser.add_argument(
'-t',
'--transform',
required=False,
action='store_true',
default=False,
help='''Optional. Transform data.''',
)
return parser.parse_args()
def main():
args = get_args()
if not any(vars(args).values()):
extractor = APIExtractor()
extractor.extract_pipe()
processor = APIProcessor()
processor.process_pipe()
transformer = APITransformer()
transformer.transform_pipe()
else:
if args.extract:
extractor = APIExtractor()
extractor.extract_pipe()
if args.process:
processor = APIProcessor()
processor.process_pipe()
if args.transform:
transformer = APITransformer()
transformer.transform_pipe()
if __name__ == '__main__':
main()