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



##########
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:
       I explained it better - and added back explanation with examples to 
PythonOperator docstring.




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