-
Notifications
You must be signed in to change notification settings - Fork 4
/
project7_dag.py
169 lines (156 loc) · 7.44 KB
/
project7_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
from datetime import datetime
from airflow import DAG
from airflow.providers.apache.spark.operators.spark_submit import SparkSubmitOperator
import os
os.environ['HADOOP_CONF_DIR'] = '/etc/hadoop/conf'
os.environ['YARN_CONF_DIR'] = '/etc/hadoop/conf'
os.environ['JAVA_HOME']='/usr'
os.environ['SPARK_HOME'] ='/usr/lib/spark'
os.environ['PYTHONPATH'] ='/usr/local/lib/python3.8'
default_args = {
'owner': 'ssenigov',
'start_date':datetime(2023, 4, 1),
'catchup': False
}
dag_spark = DAG(
dag_id = "project7_tasks",
default_args=default_args,
schedule_interval='0 0 * * *',
catchup=False
)
cities = SparkSubmitOperator(
task_id='cities_task',
dag=dag_spark,
application ='/lessons/run_geo.py' ,
application_args = ["Cities"],
conf={
"spark.executor.instances": "2",
"spark.executor.cores": "2",
"spark.driver.memory": "1g",
"spark.driver.cores": "1",
"spark.sql.shuffle.partitions": "170",
"spark.eventLog.logBlockUpdates.enabled": "True"
},
name = "GeoProject7_AirFlow"
)
eventsWithUserAndCoords = SparkSubmitOperator(
task_id='eventsWithUserAndCoords_task',
dag=dag_spark,
application ='/lessons/run_geo.py' ,
application_args = ["EventsWithUserAndCoords"],
conf={
"spark.executor.instances": "2",
"spark.executor.cores": "2",
"spark.driver.memory": "1g",
"spark.driver.cores": "1",
"spark.sql.shuffle.partitions": "170",
"spark.eventLog.logBlockUpdates.enabled": "True"
},
name = "GeoProject7_AirFlow"
)
eventsWithCitiesAll = SparkSubmitOperator(
task_id='eventsWithCitiesAll_task',
dag=dag_spark,
application ='/lessons/run_geo.py' ,
application_args = ["EventsWithCitiesAll"],
conf={
"spark.executor.instances": "2",
"spark.executor.cores": "2",
"spark.driver.memory": "1g",
"spark.driver.cores": "1",
"spark.sql.shuffle.partitions": "170",
"spark.eventLog.logBlockUpdates.enabled": "True"
},
name = "GeoProject7_AirFlow"
)
eventsWithRegsWithCities = SparkSubmitOperator(
task_id='eventsWithRegsWithCities_task',
dag=dag_spark,
application ='/lessons/run_geo.py' ,
application_args = ["EventsWithRegsWithCities"],
conf={
"spark.executor.instances": "2",
"spark.executor.cores": "2",
"spark.driver.memory": "1g",
"spark.driver.cores": "1",
"spark.sql.shuffle.partitions": "170",
"spark.eventLog.logBlockUpdates.enabled": "True"
},
name = "GeoProject7_AirFlow"
)
users = SparkSubmitOperator(
task_id='users_task',
dag=dag_spark,
application ='/lessons/run_geo.py' ,
application_args = ["Users"],
conf={
"spark.executor.instances": "2",
"spark.executor.cores": "2",
"spark.driver.memory": "1g",
"spark.driver.cores": "1",
"spark.sql.shuffle.partitions": "200",
"spark.eventLog.logBlockUpdates.enabled": "True"
},
name = "GeoProject7_AirFlow"
)
userTravels = SparkSubmitOperator(
task_id='userTravels_task',
dag=dag_spark,
application ='/lessons/run_geo.py' ,
application_args = ["UserTravels"],
conf={
"spark.executor.instances": "2",
"spark.executor.cores": "2",
"spark.driver.memory": "1g",
"spark.driver.cores": "1",
"spark.sql.shuffle.partitions": "200",
"spark.eventLog.logBlockUpdates.enabled": "True"
},
name = "GeoProject7_AirFlow"
)
report2 = SparkSubmitOperator(
task_id='report2_task',
dag=dag_spark,
application ='/lessons/run_geo.py' ,
application_args = ["Report2"],
conf={
"spark.executor.instances": "2",
"spark.executor.cores": "2",
"spark.driver.memory": "1g",
"spark.driver.cores": "1",
"spark.sql.shuffle.partitions": "200",
"spark.eventLog.logBlockUpdates.enabled": "True"
},
name = "GeoProject7_AirFlow"
)
report3 = SparkSubmitOperator(
task_id='report3_task',
dag=dag_spark,
application ='/lessons/run_geo.py' ,
application_args = ["Report3"],
conf={
"spark.executor.instances": "2",
"spark.executor.cores": "2",
"spark.driver.memory": "1g",
"spark.driver.cores": "1",
"spark.sql.shuffle.partitions": "200",
"spark.eventLog.logBlockUpdates.enabled": "True"
},
name = "GeoProject7_AirFlow"
)
report4 = SparkSubmitOperator(
task_id='report4_task',
dag=dag_spark,
application ='/lessons/run_geo.py' ,
application_args = ["Report4"],
conf={
"spark.executor.instances": "2",
"spark.executor.cores": "2",
"spark.driver.memory": "1g",
"spark.driver.cores": "1",
"spark.sql.shuffle.partitions": "200",
"spark.eventLog.logBlockUpdates.enabled": "True"
},
name = "GeoProject7_AirFlow"
)
cities >> eventsWithUserAndCoords >> eventsWithCitiesAll >> eventsWithRegsWithCities >> users >> userTravels >> [report2, report3, report4]