Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save samklr/95dce650e44af33ea9be96522ce1a1d5 to your computer and use it in GitHub Desktop.
Save samklr/95dce650e44af33ea9be96522ce1a1d5 to your computer and use it in GitHub Desktop.
Code Sample for Blog
# suppose my data file name has the following format "datatfile_YYYY_MM_DD.csv"; this file arrives in S3 every day.
file_suffix = "{{ execution_date.strftime('%Y-%m-%d') }}"
bucket_key_template = 's3://[bucket_name]/datatfile_{}.csv'.format(file_suffix)
file_sensor = S3KeySensor(
 task_id='s3_key_sensor_task',
 poke_interval=60 * 30, # (seconds); checking file every half an hour
 timeout=60 * 60 * 12, # timeout in 12 hours
 bucket_key=bucket_key_template,
 bucket_name=None,
 wildcard_match=False,
 dag=dag
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment