Airflow Python Script with execution_date in op_kwargs

佐手、 提交于 2019-12-01 09:34:17
tobi6

This is really a bit confusing and not very well documented.

You are already using the PythonOperator.

Now just add the option

provide_context=True,

and extend your callable with a pointer, e.g.

update_bmk(bmk_code, is_hedged, **context)

Now, within your function you will have access to all information about the task, including the execution date like so:

task_instance = context['task_instance']
execution_date = context['execution_date']

To see a full reference of items in the context, see https://airflow.apache.org/macros.html

Those are the docs for macros, but you can use the items in the context dictionary.

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