AIrflow - task_instance.try_number is not working

廉价感情. 提交于 2019-12-11 17:24:21

问题


I am trying to send parameter to an airflow task in order to identify the last execution.

The following code always send {"try_number": "1"} as POST data.

Airflow version: 1.10.2

Thanks

    xxx = SimpleHttpOperator(
        task_id='XXX',
        endpoint='/backend/XXX',
        http_conn_id='backend_url',
        data=json.dumps({"try_number": "{{ti.try_number}}"}),
        headers={"Content-Type": "application/json"},
        response_check=lambda response: response.json().get('status') == 'ok',
        dag=dag,
    )


回答1:


The problem is with the rendered view, I looked at the rendered result's instead of viewing the actual value of the operator.

I pushed the output to new XCOM (xcom_push=True) and now I can see the right value:

{ "status": "ok", "try_number": "15" }



来源:https://stackoverflow.com/questions/57886226/airflow-task-instance-try-number-is-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!