Thomas-McKanna opened a new issue, #29137:
URL: https://github.com/apache/airflow/issues/29137

   ### Description
   
   Hello, I am a new Airflow user. I am requesting a feature in which the 
airflow context (containing task instance, etc.) be available inside of 
functions decorated by `airflow.decorators.task.sensor`.
   
   ### Use case/motivation
   
   I have noticed that when using the `airflow.decorators.task` decorator, one 
can access items from the context (such as the task instance) by using 
`**kwargs` or keyword arguments in the decorated function. But I have 
discovered that the same is not true for the `airflow.decorators.task.sensor` 
decorator. I'm not sure if this is a bug or intentional, but it would be very 
useful to be able to access the context normally from functions decorated by 
`task.sensor`.
   
   I believe this may have been an oversight. The `DecoratedSensorOperator` 
class is a child class of `PythonSensor`:
   
   
https://github.com/apache/airflow/blob/1fbfd312d9d7e28e66f6ba5274421a96560fb7ba/airflow/decorators/sensor.py#L28
   
   This `DecoratedSensorOperator` class overrides `poke`, but does not 
incorporate the passed in `Context` object before calling the decorated 
function:
   
   
https://github.com/apache/airflow/blob/1fbfd312d9d7e28e66f6ba5274421a96560fb7ba/airflow/decorators/sensor.py#L60-L61
   
   This is in contrast to the `PythonSensor`, whose `poke` method merges the 
context with the existing `op_kwargs`:
   
   
https://github.com/apache/airflow/blob/1fbfd312d9d7e28e66f6ba5274421a96560fb7ba/airflow/sensors/python.py#L68-L77
   
   This seems like an easy fix, and I'd be happy to submit a pull request. But 
I figured I'd start with a feature request since I'm new to the open source 
community.
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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: commits-unsubscr...@airflow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to