Skip to content
Advertisement

Trigger airflow DAG manually with parameter and pass then into python function

I want to pass parameters into airflow DAG and use them in python function. I can use the parameter into bash operator, but I can’t find any reference to use them as python function.

JavaScript

I want to pass below as parameters while trigger DAG. “task1” works fine for me. I need to make “task2” workable. Please guide me to correct the above code so that I can pass parameters into it.

JavaScript

Advertisement

Answer

For passing arguments into the PythonOperator you should use either op_args (for positional arguments) or op_kwargs (for keyword arguments). Both parameters are also template fields so the values can be Jinja expressions as well.

Refactoring your code using op_kwargs:

JavaScript

Both tasks will log the INFO - test_owner.test_table now.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement