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.
Questo esercizio fa parte del corso
Introduction to Apache Airflow in Python
Istruzioni dell'esercizio
- 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.
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# 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