0
0
Apache Airflowdevops~10 mins

Manual triggers and parameters in Apache Airflow - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Manual triggers and parameters
User opens Airflow UI
Select DAG to trigger
Click 'Trigger DAG'
Input parameters (optional)
DAG run starts with parameters
Tasks execute using parameters
DAG run completes
The user manually triggers a DAG from the Airflow UI, optionally inputs parameters, which the DAG run then uses during execution.
Execution Sample
Apache Airflow
from airflow import DAG
from airflow.operators.python import PythonOperator
from airflow.utils.dates import days_ago

def print_param(**kwargs):
    param = (kwargs['dag_run'].conf or {}).get('my_param', 'default')
    print(f"Parameter received: {param}")

dag = DAG('manual_trigger_example', start_date=days_ago(1))

run_task = PythonOperator(
    task_id='print_param_task',
    python_callable=print_param,
    dag=dag
)
This DAG prints a parameter passed during manual trigger or 'default' if none is given.
Process Table
StepActionParameter InputParameter Value UsedOutput
1User opens Airflow UI and selects DAGN/AN/AReady to trigger
2User clicks 'Trigger DAG' buttonN/AN/ATrigger dialog opens
3User inputs parameter 'my_param'='hello'my_param=hellohelloDAG run starts
4Task 'print_param_task' executesmy_param=hellohelloParameter received: hello
5DAG run completesN/AN/ASuccess
6User triggers DAG again without parameterNonedefaultDAG run starts
7Task 'print_param_task' executesNonedefaultParameter received: default
8DAG run completesN/AN/ASuccess
💡 Execution stops after DAG run completes successfully.
Status Tracker
VariableStartAfter Step 3After Step 6Final
my_paramN/Ahellodefaultdefault or hello depending on trigger
Key Moments - 2 Insights
Why does the task print 'default' sometimes instead of the parameter I entered?
If no parameter is provided during manual trigger (see step 6 in execution_table), the code uses the default value 'default' as shown in step 7.
How does Airflow pass parameters to tasks during manual trigger?
Parameters are passed via the DAG run's conf dictionary, accessed in the task with kwargs['dag_run'].conf, as shown in step 4.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 4. What parameter value does the task use?
Ahello
Bdefault
CNone
Dmy_param
💡 Hint
Check the 'Parameter Value Used' column at step 4 in execution_table.
At which step does the DAG run start without any parameter provided?
AStep 3
BStep 6
CStep 1
DStep 8
💡 Hint
Look for 'None' in the 'Parameter Input' column in execution_table.
If the user inputs parameter 'my_param=world' during trigger, what will the task print?
AParameter received: hello
BParameter received: default
CParameter received: world
DParameter received: None
💡 Hint
Refer to how parameter values are used in execution_table steps 3 and 4.
Concept Snapshot
Manual triggers in Airflow allow users to start DAG runs from the UI.
Users can input parameters as JSON in the trigger dialog.
Tasks access parameters via dag_run.conf dictionary.
If no parameter is given, tasks can use default values.
This enables flexible, on-demand DAG execution.
Full Transcript
In Airflow, you can manually start a DAG run from the web interface. When you do this, a dialog lets you enter parameters as JSON. These parameters are passed to the DAG run and can be accessed by tasks through the dag_run.conf dictionary. If you don't provide parameters, tasks can use default values coded in the DAG. This lets you run workflows on demand with custom inputs. The execution table shows the steps from opening the UI, triggering the DAG with or without parameters, task execution printing the parameter, and DAG completion.