1. Learn
  2. /
  3. คอร์ส
  4. /
  5. Introduction to Apache Airflow in Python

Connected

แบบฝึกหัด

Writing with Jinja

As you've started working with Airflow more, you've added various notification callbacks but realize you're receiving the same messages in your inbox each time. It's hard to find a message when the subject is always the same. After reading about Airflow's Jinja support, you realize you can now add some identifying information to make sure your Dags send a report for each day's run. You've decided to start with updating the sales_update Dag to send you an email with a templated subject when it finishes successfully.

All necessary Airflow imports are already available, and the tasks pull_sales_data and generate_sales_report are already defined.

คำแนะนำ

100 XP
  • Set up the Dag to send you an email when it completes without error.

  • Set the subject attribute for the notification email.

  • Use a Jinja template to include the run date in the subject line:

    Sales update successfully processed for YYYY-MM-DD