From ae8ca7dab16c64002cf41e8db6ec4a0dcd9241a9 Mon Sep 17 00:00:00 2001 From: Malthe Borch Date: Tue, 7 Jun 2022 18:58:48 +0000 Subject: [PATCH 1/2] Mention context variables and logging --- docs/apache-airflow/concepts/taskflow.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/apache-airflow/concepts/taskflow.rst b/docs/apache-airflow/concepts/taskflow.rst index 4cfc91f821d98..dea009ad95b42 100644 --- a/docs/apache-airflow/concepts/taskflow.rst +++ b/docs/apache-airflow/concepts/taskflow.rst @@ -63,6 +63,24 @@ You can also use a plain value or variable to call a TaskFlow function - for exa If you want to learn more about using TaskFlow, you should consult :doc:`the TaskFlow tutorial `. +Context +------- + +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` you can use in your Jinja templates. + +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. + +Logging +------- + +To use logging from your task functions, simply import and use Python's logging system: + +.. code-block:: python + + import logging + logger = logging.getlogger("airflow.task") + +Every logging line created this way will be recorded in the task log. History ------- From 1f709418f4f912be52ab6fa251bdfabda9367a60 Mon Sep 17 00:00:00 2001 From: Malthe Borch Date: Tue, 7 Jun 2022 19:45:06 +0000 Subject: [PATCH 2/2] Fix static checks --- docs/apache-airflow/concepts/taskflow.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/apache-airflow/concepts/taskflow.rst b/docs/apache-airflow/concepts/taskflow.rst index dea009ad95b42..1c2d133fcff63 100644 --- a/docs/apache-airflow/concepts/taskflow.rst +++ b/docs/apache-airflow/concepts/taskflow.rst @@ -66,7 +66,7 @@ If you want to learn more about using TaskFlow, you should consult :doc:`the Tas Context ------- -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` you can use in your Jinja templates. +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` you can use in your Jinja templates. 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. @@ -77,7 +77,6 @@ To use logging from your task functions, simply import and use Python's logging .. code-block:: python - import logging logger = logging.getlogger("airflow.task") Every logging line created this way will be recorded in the task log.