Airflow Python Script with execution_date in op_kwargs

前端 未结 1 391
一向
一向 2021-01-01 22:45

With assistance from this answer https://stackoverflow.com/a/41730510/4200352 I am executing a python file.

I use PythonOperator and am trying to include the executi

相关标签:
1条回答
  • 2021-01-01 23:08

    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.

    0 讨论(0)
提交回复
热议问题