jrderuiter opened a new issue, #42254:
URL: https://github.com/apache/airflow/issues/42254
### Description
I'd like to add a new dataset listener that allows me to listen for new
dataset events. This would be similar to the existing `on_dataset_changed`
listener, but would pass the underlying `DatasetEvent` instead of the `Dataset`
reference:
```
@hookspec
def on_dataset_event_created(
event : DatasetEvent,
):
"""Execute when dataset a dataset event is created."""
```
Alternatively, we could expand the existing `on_dataset_changed` handler to
add the dataset event as an argument to the listener. This would however not be
backwards compatible with existing listener implementations.
### Use case/motivation
Currently Airflow provides the `on_dataset_changed`
[listeners](https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/listeners.html#dataset-events)
as a hook for listening to changes on datasets. However, this listener only
passes the dataset object to the listener and not the `DatasetEvent`
corresponding to the change:
```
@hookspec
def on_dataset_changed(
dataset: Dataset,
):
"""Execute when dataset change is registered."""
```
For a use case that I'm working on I'd also like to have access to the
dataset event to determine whether that dataset event came from the API or not
(which you can check on the event using `event.extra["from_rest_api"]`.
This is not possible with the current listeners.
### 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]