ashb commented on a change in pull request #18868:
URL: https://github.com/apache/airflow/pull/18868#discussion_r726093537



##########
File path: docs/apache-airflow/tutorial_taskflow_api.rst
##########
@@ -286,6 +286,26 @@ In the above code block, a 
:class:`~airflow.providers.http.operators.http.Simple
 was captured via :doc:`XCOMs </concepts/xcoms>`. This XCOM result, which is 
the task output, was then passed
 to a TaskFlow decorated task which parses the response as JSON - and the rest 
continues as expected.
 
+Accessing context from decorated tasks
+--------------------------------------
+
+While the TaskFlow API transparently handles most of the Airflow boilerplate 
(such as passing inputs/outputs
+between tasks), sometimes you might want to access the operator context 
directly. You can do it via
+``get_current_context`` method of the Python operator.
+
+.. code-block:: python
+
+    from airflow.operators.python import task, get_current_context
+
+
+    @task
+    def my_task():
+        context = get_current_context()
+        ti = context["ti"]

Review comment:
       This is part of the "PythonOperator" interface which is what TaskFlow 
uses/wraps. I don't know off the top of my head if this is documented there or 
not -- but this behaviour is now "default" since v2 (prior to that, you had to 
pass `provider_context=True` to get it.




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to