Skip to content

Commit 926d9bd

Browse files
authored
Mention context variables and logging (#24304)
* Mention context variables and logging * Fix static checks
1 parent 5d992a5 commit 926d9bd

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/apache-airflow/concepts/taskflow.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ You can also use a plain value or variable to call a TaskFlow function - for exa
6363

6464
If you want to learn more about using TaskFlow, you should consult :doc:`the TaskFlow tutorial </tutorial_taskflow_api>`.
6565

66+
Context
67+
-------
68+
69+
When running your callable, Airflow will pass a set of keyword arguments that can be used in your function. This set of kwargs correspond exactly to the :ref:`context variables<templates:variables>` you can use in your Jinja templates.
70+
71+
For this to work, you need to define ``**kwargs`` in your function header, or you can add directly the keyword arguments you would like to get such as ``ti=None`` to have the task instance passed.
72+
73+
Logging
74+
-------
75+
76+
To use logging from your task functions, simply import and use Python's logging system:
77+
78+
.. code-block:: python
79+
80+
logger = logging.getlogger("airflow.task")
81+
82+
Every logging line created this way will be recorded in the task log.
6683

6784
History
6885
-------

0 commit comments

Comments
 (0)