bolkedebruin commented on issue #17984:
URL: https://github.com/apache/airflow/issues/17984#issuecomment-966276136
I see `on_state_change` as part of the operator so
`BashOperator.on_state_change` that inherits everthing the tasks knows about
itself including the standard context (ontext contains references to related
objects to the task instance and is documented under the macros section of the
API). What do you want in context? Maybe we should pass more in context for
security reasons to limit the 'surface of exposure of the task'.
Designing this a bit more I think this would be nice to have in Airflow:
```
# returns new state
def state_handler(old: State, new: State, ctx -> Context) -> State
def on_state_change(old: State, new: State, ctx -> Context) -> None
# python 3.10
# call legacy functions
match State:
case State.FAILED:
self.on_failure_callback(ctx)
case State.ON_RETRY:
self.on_retry_callback(ctx)
```
--
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]