shivannakarthik commented on code in PR #55377:
URL: https://github.com/apache/airflow/pull/55377#discussion_r2332939416
##########
airflow-core/docs/core-concepts/operators.rst:
##########
@@ -84,11 +84,31 @@ Here, ``{{ ds }}`` is a templated variable, and because the
``env`` parameter of
You can also pass in a callable instead when Python is more readable than a
Jinja template. The callable must accept two named arguments ``context`` and
``jinja_env``:
+The ``context`` parameter is a dictionary-like object (``Dict[str, Any]``)
that provides access to runtime information about the current task execution.
You can access its contents using standard dictionary syntax
(``context["key"]``) and it contains all the same variables that are available
in Jinja templates. The context is read-only from the perspective of template
rendering - while you can access and use its values, modifications won't affect
the task execution environment.
+
+Key context variables include:
+
+- ``context["task"]``: The current task object (``BaseOperator``)
+- ``context["ti"]`` or ``context['task_instance']``: The task instance object
(``TaskInstance``)
+- ``context["dag"]``: The DAG object containing this task
+- ``context["dag_run"]``: The current DAG run object
+- ``context["ds"]``: Data interval start date in YYYY-MM-DD format (``str``)
+- ``context["logical_date"]``: The logical date for this DAG run (``DateTime``)
+- ``context["run_id"]``: The run ID of the current DAG run (``str``)
+
+For a complete list of available context variables, see :ref:`Templates
reference <templates:variables>`.
+
.. code-block:: python
+ from typing import Any, Dict
+ import jinja2
Review Comment:
Thanks @ashb for the review comment. Have incorporated the changes requested
and removed Any, Dict as its no longer required.
--
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]