Get startedGet started for free

Adding Human approval

While working on a workflow, your boss mentions there have been issues with the data being posted to the sales team's analytics database. They want to be sure that the sales data looks good prior to posting it to a data warehouse. You realize that a HITL Approval step is a good option to add a last check prior to data insertion.

The dag, task, and timedelta objects have all been imported for you.

This exercise is part of the course

Introduction to Apache Airflow in Python

View Course

Exercise instructions

  • Import the appropriate library to create an Approve / Reject task.
  • Create the approve_gate approval task.
  • Set the title for the approval request that will appear to the reviewer in the Airflow UI.

Hands-on interactive exercise

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

# Import ApprovalOperator
from airflow.providers.standard.operators.____ import ____

@dag(start_date=datetime(2026,4,15))
def data_warehouse_dag():  
  # Create the approve_gate approval task
  approve_gate = ____(
        task_id="approve_sales_data",
        # Set the title for the approval request shown to the reviewer
        ____="Sales data processing - Approval Required",
        body=(
            "Please review the sales data produced by the *pull_raw_data* task."
            "Approve to push leads to the data warehouse, or Reject to halt the run."
        ),
    )
  
  pull_raw_data() >> approve_gate >> push_to_warehouse()
data_warehouse_dag()
Edit and Run Code