は、私はこのような、simplehttpoperatorをトリガーにしたい: 気流trigger_dag test_trigger --conf '{ "名": "何か"}' は?
iがkwargsから[ 'dag_run' を使用してパラメータを受け入れるためにpythonoperatorのpython_callableを使用します] .confの、と私は[「dag_run」]を渡したい。simplehttpoperatorにconfに、どのように私はそれを行うことができますか?誰でも助けることができますか?タスク間通信のために
cc_ = {}
def run_this_func(ds, **kwargs):
cc_ = kwargs['dag_run'].conf
logging.info(cc_)
return cc_
run_this = PythonOperator(
task_id='run_this',
provide_context=True,
python_callable=run_this_func,
dag=dag)
http_task = SimpleHttpOperator(
task_id='http_task',
http_conn_id='test_http',
method='POST',
endpoint='/api/v1/function',
data=cc_,
headers={"Authorization": "Basic YWRtaW46MTIzNDU2", "Accept": "application/json, text/plain, */*"},
response_check=lambda response: True if "10000" in response.content else False,
dag=dag)
http_task.set_upstream(run_this)
ただし、simplehttpoperatorでXCOMを使用するにはどうすればよいですか?どのケースコードも教えていただけますか?これは – pyfroggogogo
@pyfroggogogo、私はいくつかのコード例を更新し、試してみてください。レンダリング後のバック辞書の種類にそれを得るために '|(「{tojson} {...}」)あなたは'データ=のjson.loadsを使用することができます。詳細については – Chengzhi
テンプレートが文字列として渡さする必要が動作するかどうか –