mik-laj edited a comment on issue #6074: [AIRFLOW-5390] Remove provide context URL: https://github.com/apache/airflow/pull/6074#issuecomment-530125171 Here I put my proposition for documentation based on note in updating.md. This is not a finished change, but I wanted to show an example. ---- # UPDATING.md `provide_context` argument on the PythonOperator was removed. The signature of the callable passed to the PythonOperator is now inferred and argument values are always automatically provided. There is no need to explicitly provide or not provide the context anymore. For more information: [python.rst] The change is backwards compatible, setting provide_context will add the provide_context variable to the kwargs (but won't do anything). PR: #5990 ---- # python.rst The signature of the callable passed to the PythonOperator is inferred and argument values are always automatically provided. For example: ``` def myfunc(execution_date): print(execution_date) python_operator = PythonOperator(task_id='mytask', python_callable=myfunc, dag=dag) ``` Notice you don't have to set provide_context=True, variables from the task context are now automatically detected and provided. All context variables can still be provided with a double-asterisk argument: ``` def myfunc(**context): print(context) # all variables will be provided to context python_operator = PythonOperator(task_id='mytask', python_callable=myfunc) ``` The task context variable names are reserved names in the callable function, hence a clash with op_args and op_kwargs results in an exception: ``` def myfunc(dag): # raises a ValueError because "dag" is a reserved name # valid signature example: myfunc(mydag) python_operator = PythonOperator( task_id='mytask', op_args=[1], python_callable=myfunc, ) ```` --- # docstring ``` The signature of the callable passed to the PythonOperator is inferred and argument values are always automatically provided. .. warning:: The task context variable names are reserved names in the callable function, hence a clash with op_args and op_kwargs results in an exception ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services