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



##########
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:
       And just to provide a bit of `context` - the `ti` example of mine was 
really to show that you can retrieve `any` context variables here - people were 
asking for example how they can access `next_ds` from 
https://airflow.apache.org/docs/apache-airflow/stable/macros-ref.html - so my 
goal is to explain them how they can do 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