Params
Params in Airflow are a way to pass dynamic runtime configuration to tasks within a DAG. They allow tasks to be more flexible by enabling templated values to be injected during execution.
Key Features
- Available in DAG and task definitions.
- Can be templated using Jinja.
- Useful for customizing task behavior without modifying code.
Example DAG
default:
catchup: false
default_args:
start_date: 2025-01-01
example_params:
params:
model_version: 1.0.0
input_uri: localhost
description: "This is an DAG-Factory example dag with param"
schedule_interval: "@daily"
tasks:
task_1:
operator: airflow.operators.bash.BashOperator
bash_command: "echo 'Running task 1 with model version {{ params.model_version }} and url: {{ params.input_uri }}'"
task_2:
operator: airflow.operators.python.PythonOperator
params:
my_param: 10
python_callable: sample.read_params
When to Use
- You want to reuse the same DAG for different input values.
- You want to change a task’s behavior at runtime.