-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEU_DAG.py
258 lines (183 loc) · 4.54 KB
/
EU_DAG.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
from __future__ import print_function
import time
from builtins import range
from pprint import pprint
import sys
import airflow
from airflow.models import DAG
from airflow.operators.python_operator import PythonOperator
import pandas as pd
import seaborn as sns
from EU_methods import(heatMap, load, count_records, count_columns, list_countries, Belgium, Denmark, France,
Germany, Greece, Ireland, Italy, Luxembourg, Netherlands, Portugal, Spain, United_Kingdom)
args = {
'owner': 'airflow',
'start_date': airflow.utils.dates.days_ago(2),
}
dag = DAG(
dag_id='EU_Heat_Map',
default_args=args,
schedule_interval=None,
)
#---------------------------#
# TASKS #
#---------------------------#
def load_eu(ds, **kwargs):
load()
return 'File Loaded'
def count_record(ds, **kwargs):
count_records()
return 'Counted records'
def count_cols(ds, **kwargs):
count_columns()
return 'Extracted/Stored Columns'
def list_country(ds, **kwargs):
list_countries()
return 'Extracted/Stored Countries'
def Belg(ds, **kwargs):
Belgium()
return 'Extracted/Stored Belgium'
def Den(ds, **kwargs):
Denmark()
return 'Extracted/Stored Denmark'
def Fra(ds, **kwargs):
France()
return 'Extracted/Stored France'
def Ger(ds, **kwargs):
Germany()
return 'Extracted/Stored Germany'
def Gre(ds, **kwargs):
Greece()
return 'Extracted/Stored Greece'
def Ire(ds, **kwargs):
Ireland()
return 'Extracted/Stored Ireland'
def Ita(ds, **kwargs):
Italy()
return 'Extracted/Stored Italy'
def Lux(ds, **kwargs):
Luxembourg()
return 'Extracted/Stored Luxembourg'
def Neth(ds, **kwargs):
Netherlands()
return 'Extracted/Stored Netherlands'
def Port(ds, **kwargs):
Portugal()
return 'Extracted/Stored Portugal'
def Spa(ds, **kwargs):
Spain()
return 'Extracted/Stored Spain'
def UK(ds, **kwargs):
United_Kingdom()
return 'Extracted/Stored UK'
def map(ds, **kwargs):
heatMap()
return 'Heat Map Generated'
#---------------------------#
# Operators #
#---------------------------#
a = PythonOperator(
task_id='Load_Europe_Data_File',
provide_context=True,
python_callable=load_eu,
dag=dag,
)
b = PythonOperator(
task_id='Count_Records_Raw_File',
provide_context=True,
python_callable=count_record,
dag=dag,
)
c = PythonOperator(
task_id='List_Countries_Raw',
provide_context=True,
python_callable=list_country,
dag=dag,
)
d = PythonOperator(
task_id='Belgium',
provide_context=True,
python_callable=Belg,
dag=dag,
)
e = PythonOperator(
task_id='Denmark',
provide_context=True,
python_callable=Den,
dag=dag,
)
f = PythonOperator(
task_id='France',
provide_context=True,
python_callable=Fra,
dag=dag,
)
g = PythonOperator(
task_id='Germany',
provide_context=True,
python_callable=Ger,
dag=dag,
)
h = PythonOperator(
task_id='Greece',
provide_context=True,
python_callable=Gre,
dag=dag,
)
i = PythonOperator(
task_id='Ireland',
provide_context=True,
python_callable=Ire,
dag=dag,
)
j = PythonOperator(
task_id='Italy',
provide_context=True,
python_callable=Ita,
dag=dag,
)
k = PythonOperator(
task_id='Luxembourg',
provide_context=True,
python_callable=Lux,
dag=dag,
)
l = PythonOperator(
task_id='Netherlands',
provide_context=True,
python_callable=Neth,
dag=dag,
)
m = PythonOperator(
task_id='Portugal',
provide_context=True,
python_callable=Port,
dag=dag,
)
n = PythonOperator(
task_id='Spain',
provide_context=True,
python_callable=Spa,
dag=dag,
)
o = PythonOperator(
task_id='United_Kingdom',
provide_context=True,
python_callable=UK,
dag=dag,
)
p = PythonOperator(
task_id='Generate_Heat_Map',
provide_context=True,
python_callable=map,
dag=dag,
)
#---------------------------#
# Dependencies #
#---------------------------#
# a = root
a.set_downstream(b)
# b = bottleneck to three threads
b.set_downstream(c)
c.set_downstream([d, e, f, g, h, i, j, k, l, m, n, o])
p.set_upstream([d, e, f, g, h, i, j, k, l, m, n, o])