Skip to content Skip to sidebar Skip to footer

Airflow Python Script With Execution_date In Op_kwargs

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 execution date as an a

Solution 1:

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/docs/apache-airflow/stable/macros-ref.html

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

Post a Comment for "Airflow Python Script With Execution_date In Op_kwargs"