Generate and email a report
Airflow provides the ability to automate almost any style of workflow. You would like to receive a report from Airflow when tasks complete without requiring constant monitoring of the UI or log files. You decide to use the email functionality within Airflow to provide this message.
All the typical Airflow components have been imported for you, and a DAG is already defined as report_dag.
Latihan ini adalah bagian dari kursus
Introduction to Apache Airflow in Python
Petunjuk latihan
- Define the proper operator for the
email_reporttask. - Fill the missing details for the Operator. Use the file named
monthly_report.pdf. - Set the
email_reporttask to occur after thegenerate_reporttask.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
# Define the email task
email_report = ____(
task_id='email_report',
to='[email protected]',
subject='Airflow Monthly Report',
html_content="""Attached is your monthly workflow report - please refer to it for more detail""",
files=[____],
____=report_dag
)
# Set the email task to run after the report is generated
email_report ____ generate_report