Get startedGet started for free

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.

This exercise is part of the course

Introduction to Apache Airflow in Python

View Course

Exercise instructions

  • Define the proper operator for the email_report task.
  • Fill the missing details for the Operator. Use the file named monthly_report.pdf.
  • Set the email_report task to occur after the generate_report task.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# 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
Edit and Run Code