Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
887 views
in Technique[技术] by (71.8m points)

how do I use the --conf option in airflow

I am trying to run a airflow DAG and need to pass some parameters for the tasks.

How do I read the JSON string passed as the --conf parameter in the command line trigger_dag command, in the python DAG file.

ex: airflow trigger_dag 'dag_name' -r 'run_id' --conf '{"key":"value"}'

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Two ways. From inside a template field or file:

{{ dag_run.conf['key'] }}

Or when context is available, e.g. within a python callable of the PythonOperator:

context['dag_run'].conf['key']

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...