-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Allow sensors to return XCom values with PokeReturnValue #20547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Duplicate of #20546 ? |
|
Closing as duplicate |
|
Ah sorry. let me take a look. |
|
It's still not really backwards compatible (in the sense a having a New Sensor returnig PokeReturnValue run on airlfow pre 2.3). If you return PokeReturnValue() in Airlfow 2.2. it will not work. The BaseSensorOperator from Airflow 2.2 will run this: And it will always finish after first check no matter what "is_done" is. In this case self.poke() returns PokeReturnValue() class which is Truthy no matter what is set in But It could be made backwards compatible - and I like this much more than my "return Truthy" approach. Should be enough to do this:
UPDATE: Nope. It won't work, because in Airflow 2.2 there wil be no PokeReturnValue class. |
A not-so-ideal way is to declare a dynamic return type: |
That's not enough. The problem is that any sensor that uses PokeReturnValue would have to be Airlfow 2.3+ only (PokeReturnValue will fail to be imported for such sensor) |
You are right - what I can think of is to introduce a new type of sensor, e.x RichSensor and make the poke() method return a PokeReturnValue type. |
7768eb3 to
c352995
Compare
Historically sensors do not support returning XCom unless you override the `execute` method. With this change we can optionally return an XCom value by returning one along with `True` in new class PokeReturnValue
c352995 to
19a9d2a
Compare
|
this pr taken over by @mingshi-wang in #20656 |
Historically sensors do not support returning XCom unless you override the
executemethod.With this change we can optionally return an XCom value by returning one along with
Truein new class PokeReturnValue
A key motivator for this PR is this other PR to add
@task.sensordecorator. With the present PR merged, we can make it so the sensor decorator can return a tupleTrue, {"some": "info"}to push xcom.