-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmta_delays_consume_processed.py
49 lines (41 loc) · 1.21 KB
/
mta_delays_consume_processed.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import airflow
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from airflow.operators.bash_operator import BashOperator
from datetime import datetime, timedelta
from mta_delays.process.kafka_mta_producer import get_raw_delays_and_send_to_kafka
from mta_delays.ingest.index_es import index_es
defaults = {
'owner': 'Drew Gordon',
'depends_on_past': False,
'catchup': False,
'start_date': datetime(2018, 5, 15, 10, 42, 59),
'email':['asgor@uw.edu'],
'email_on_failure': True,
'email_on_retry': False,
'retries':1,
'retry_delay': timedelta(minutes=2),
}
dag = DAG('mta_delays_consume_processed',
default_args=defaults,
schedule_interval=timedelta(hours=5))
t1 = PythonOperator(
task_id="get_raw_delays_and_send_to_kafka",
python_callable=get_raw_delays_and_send_to_kafka,
dag=dag
)
t2 = BashOperator(
# give time for the consumer to finish before indexing
task_id='sleep',
bash_command='sleep 120',
retries=3,
dag=dag)
t3 = PythonOperator(
task_id="index_es",
python_callable=index_es,
dag=dag
)
t3.set_upstream(t2)
t2.set_upstream(t1)