-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsensor_s3.py
More file actions
37 lines (31 loc) · 952 Bytes
/
sensor_s3.py
File metadata and controls
37 lines (31 loc) · 952 Bytes
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
"""
S3 Sensor Connection Test
"""
from airflow import DAG
from airflow.operators import SimpleHttpOperator, HttpSensor, BashOperator, EmailOperator, S3KeySensor
from datetime import datetime, timedelta
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'start_date': datetime(2016, 11, 1),
'email': ['something@here.com'],
'email_on_failure': False,
'email_on_retry': False,
'retries': 5,
'retry_delay': timedelta(minutes=5)
}
dag = DAG('s3_dag_test', default_args=default_args, schedule_interval= '@once')
t1 = BashOperator(
task_id='bash_test',
bash_command='echo "hello, it should work" > s3_conn_test.txt',
dag=dag)
sensor = S3KeySensor(
task_id='check_s3_for_file_in_s3',
bucket_key='XXX/YYY/ZZZ.xml',
wildcard_match=True,
bucket_name='{BUCKET_NAME}',
timeout=18*60*60,
poke_interval=120,
aws_conn_id='s3_connection',
dag=dag)
t1.set_upstream(sensor)