How to modify DAG parameter that has a default value when triggering a DAG manually

Viewed 1701
1 Answers

First, make sure that the argument days_of_data is a templated field in the operator you are calling. After that you just have to set a default value in the operator as follow:

"{{ dag_run.conf['days_of_data'] or 7 }}"

This will set days_of_data as 7 unless you pass the following JSON when executing manually a DAG (either from the CLI or the UI):

{"days_of_data": days}

Where x can be any value. Please note that this parameter would be a string, so you may need to convert it to int or another type before using it.

Related