This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch v3-0-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-0-test by this push:
     new 9d41e5d9e48 [v3-0-test] Refactor example task to use context and 
logging for parameter access (#54450) (#54463)
9d41e5d9e48 is described below

commit 9d41e5d9e483cb702afb2c3248ae749d19c355df
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Aug 13 14:27:42 2025 +0100

    [v3-0-test] Refactor example task to use context and logging for parameter 
access (#54450) (#54463)
    
    (cherry picked from commit 12c3209c84d84f990f94eddd84aa677c8eba6737)
    
    Co-authored-by: Ranuga Disansa 
<[email protected]>
---
 airflow-core/docs/core-concepts/params.rst | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/airflow-core/docs/core-concepts/params.rst 
b/airflow-core/docs/core-concepts/params.rst
index 2ce7403df67..f313f0bd159 100644
--- a/airflow-core/docs/core-concepts/params.rst
+++ b/airflow-core/docs/core-concepts/params.rst
@@ -38,9 +38,8 @@ Use a dictionary that maps Param names to either a 
:class:`~airflow.sdk.definiti
 .. code-block::
    :emphasize-lines: 7-10
 
-    from airflow.sdk import DAG
-    from airflow.sdk import task
-    from airflow.sdk import Param
+    from airflow.sdk import DAG, task, Param, get_current_context
+    import logging
 
     with DAG(
         "the_dag",
@@ -51,15 +50,18 @@ Use a dictionary that maps Param names to either a 
:class:`~airflow.sdk.definiti
     ) as dag:
 
         @task.python
-        def example_task(params: dict):
+        def example_task():
+            ctx = get_current_context()
+            logger = logging.getLogger("airflow.task")
+
             # This will print the default value, 6:
-            dag.log.info(dag.params['my_int_param'])
+            logger.info(ctx["dag"].params["my_int_param"])
 
             # This will print the manually-provided value, 42:
-            dag.log.info(params['my_int_param'])
+            logger.info(ctx["params"]["my_int_param"])
 
             # This will print the default value, 5, since it wasn't provided 
manually:
-            dag.log.info(params['x'])
+            logger.info(ctx["params"]["x"])
 
         example_task()
 

Reply via email to