-
Notifications
You must be signed in to change notification settings - Fork 93
/
Copy pathjetstream.py
146 lines (130 loc) · 4.75 KB
/
jetstream.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
"""
Powers the [jetstream](https://experimenter.info/jetstream/jetstream/)
analysis framework for experiments.
See the [jetstream repository](https://github.com/mozilla/jetstream).
*Triage notes*
In case jetstream configuration is modified it is perfectly normal for the task
`jetstream_run_config_changed` to take significantly longer to complete (hours instead of minutes).
In these cases we expect anything below 12 hours, only after that amount of time should
this task be considered potentially faulty and subject to the triage process.
""" # noqa: D205
from datetime import datetime, timedelta
from airflow import DAG
from airflow.sensors.external_task import ExternalTaskSensor
from operators.gcp_container_operator import GKEPodOperator
from utils.constants import ALLOWED_STATES, FAILED_STATES
from utils.tags import Tag
default_args = {
"owner": "ascholtz@mozilla.com",
"email": [
"ascholtz@mozilla.com",
"mwilliams@mozilla.com",
],
"depends_on_past": False,
"start_date": datetime(2020, 3, 12),
"email_on_failure": True,
"email_on_retry": True,
"retries": 2,
"retry_delay": timedelta(minutes=30),
}
tags = [Tag.ImpactTier.tier_1]
with DAG(
"jetstream",
default_args=default_args,
schedule_interval="0 4 * * *",
doc_md=__doc__,
tags=tags,
) as dag:
# Built from repo https://github.com/mozilla/jetstream
jetstream_image = "gcr.io/moz-fx-data-experiments/jetstream:latest"
jetstream_run = GKEPodOperator(
task_id="jetstream_run",
name="jetstream_run",
image=jetstream_image,
email=default_args["email"],
arguments=[
"--log_to_bigquery",
"run-argo",
"--date={{ ds }}",
# the Airflow cluster doesn't have Compute Engine API access so pass in IP
# and certificate in order for the pod to connect to the Kubernetes cluster
# running Jetstream
"--cluster-ip={{ var.value.jetstream_cluster_ip }}",
"--cluster-cert={{ var.value.jetstream_cluster_cert }}",
],
dag=dag,
)
jetstream_config_changed = GKEPodOperator(
task_id="jetstream_run_config_changed",
name="jetstream_run_config_changed",
image=jetstream_image,
email=default_args["email"],
arguments=[
"--log_to_bigquery",
"rerun-config-changed",
"--argo",
# the Airflow cluster doesn't have Compute Engine API access so pass in IP
# and certificate in order for the pod to connect to the Kubernetes cluster
# running Jetstream
"--cluster-ip={{ var.value.jetstream_cluster_ip }}",
"--cluster-cert={{ var.value.jetstream_cluster_cert }}",
],
dag=dag,
)
wait_for_clients_daily_export = ExternalTaskSensor(
task_id="wait_for_clients_daily",
external_dag_id="bqetl_main_summary",
external_task_id="telemetry_derived__clients_daily__v6",
execution_delta=timedelta(hours=2),
mode="reschedule",
allowed_states=ALLOWED_STATES,
failed_states=FAILED_STATES,
pool="DATA_ENG_EXTERNALTASKSENSOR",
email_on_retry=False,
dag=dag,
)
wait_for_search_clients_daily = ExternalTaskSensor(
task_id="wait_for_search_clients_daily",
external_dag_id="bqetl_search",
external_task_id="search_derived__search_clients_daily__v8",
execution_delta=timedelta(hours=1),
mode="reschedule",
allowed_states=ALLOWED_STATES,
failed_states=FAILED_STATES,
pool="DATA_ENG_EXTERNALTASKSENSOR",
email_on_retry=False,
dag=dag,
)
wait_for_bq_events = ExternalTaskSensor(
task_id="wait_for_bq_main_events",
external_dag_id="copy_deduplicate",
external_task_id="bq_main_events",
execution_delta=timedelta(hours=3),
mode="reschedule",
allowed_states=ALLOWED_STATES,
failed_states=FAILED_STATES,
pool="DATA_ENG_EXTERNALTASKSENSOR",
email_on_retry=False,
dag=dag,
)
wait_for_copy_deduplicate_events = ExternalTaskSensor(
task_id="wait_for_event_events",
external_dag_id="copy_deduplicate",
external_task_id="event_events",
execution_delta=timedelta(hours=3),
mode="reschedule",
allowed_states=ALLOWED_STATES,
failed_states=FAILED_STATES,
pool="DATA_ENG_EXTERNALTASKSENSOR",
email_on_retry=False,
dag=dag,
)
jetstream_run.set_upstream(
[
wait_for_clients_daily_export,
wait_for_search_clients_daily,
wait_for_bq_events,
wait_for_copy_deduplicate_events,
]
)
jetstream_config_changed.set_upstream(jetstream_run)