Programmer-RD-AI opened a new pull request, #54450:
URL: https://github.com/apache/airflow/pull/54450

   
   ## Summary
   
   This PR fixes a documentation bug in the "Params" example under 
core-concepts: the use of `dag.log` inside the `@task.python` function. In the 
current code, `dag.log` doesn’t exist in TaskFlow DAGs, causing runtime errors 
when the code is executed.
   
   ## Changes
   
   - Replaced `dag.log.info(...)` with proper usage of task context and Python 
logging:
     - Used `get_current_context()` to access runtime values.
     - Used a standard logger (`logging.getLogger("airflow.task")`) to output 
parameter values.
   
   ```diff
   - dag.log.info(dag.params['my_int_param'])
   + logger.info(ctx["dag"].params["my_int_param"])
   ````
   
   And similarly for user-provided values via `params`.
   
   ## Rationale
   
   * Airflow 3's Task SDK no longer attaches a `.log` property to `DAG`, so 
relying on `dag.log` is no longer valid.
   * `get_current_context()` provides a reliable way to access `dag.params` and 
`params` inside tasks.
   * Logging via Python’s `logging` module (or `self.log` on operators) aligns 
with Airflow’s logging model and avoids missing attribute errors.
   
   ## Fixes
   
   Closes: #54380.
   


-- 
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