创建dag运行时将参数传递给Airflow Experiment REST API [英] Pass parameters to Airflow Experimental REST api when creating dag run
问题描述
看起来Airflow有一个实验性的REST API,允许用户使用https POST请求创建dag运行。这太棒了。
Looks like Airflow has an experimental REST api that allow users to create dag runs with https POST request. This is awesome.
是否可以通过HTTP将参数传递给create dag运行?从官方文档来看,发现此处,答案似乎是否,但我我希望我错了。
Is there a way to pass parameters via HTTP to the create dag run? Judging from the official docs, found here, it would seem the answer is "no" but I'm hoping I'm wrong.
推荐答案
从源代码,它似乎将参数 传递给了dag跑。
Judging from the source code, it would appear as though parameters can be passed into the dag run.
如果http请求的正文包含json,并且该json包含顶级键 conf
,则 conf
密钥将作为配置传递给 trigger_dag
。有关其工作原理的更多信息,请参见此处。
If the body of the http request contains json, and that json contains a top level key conf
the value of the conf
key will be passed as configuration to trigger_dag
. More on how this works can be found here.
请注意 conf
键的值必须是字符串,例如
Note the value of the conf
key must be a string, e.g.
curl -X POST \
http://localhost:8080/api/experimental/dags/<DAG_ID>/dag_runs \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{"conf":"{\"key\":\"value\"}"}'
这篇关于创建dag运行时将参数传递给Airflow Experiment REST API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!