potiuk commented on code in PR #38155: URL: https://github.com/apache/airflow/pull/38155#discussion_r1555047282
########## docs/apache-airflow/administration-and-deployment/listeners.rst: ########## @@ -34,21 +34,63 @@ Lifecycle events allow you to react to start and stop events for an Airflow ``Jo DagRun State Change Events -------------------------- +DagRun state change events occur when a :class:`~airflow.models.dagrun.DagRun` changes state. + - ``on_dag_run_running`` + +.. exampleinclude:: /../../airflow/example_dags/plugins/event_listener.py + :language: python + :dedent: 4 + :start-after: [START howto_listen_dagrun_running_task] + :end-before: [END howto_listen_dagrun_running_task] + - ``on_dag_run_success`` + +.. exampleinclude:: /../../airflow/example_dags/plugins/event_listener.py + :language: python + :dedent: 4 + :start-after: [START howto_listen_dagrun_success_task] + :end-before: [END howto_listen_dagrun_success_task] + - ``on_dag_run_failed`` -DagRun state change events occur when a ``DagRun`` changes state. +.. exampleinclude:: /../../airflow/example_dags/plugins/event_listener.py + :language: python + :dedent: 4 + :start-after: [START howto_listen_dagrun_failure_task] + :end-before: [END howto_listen_dagrun_failure_task] + TaskInstance State Change Events -------------------------------- +TaskInstance state change events occur when a :class:`~airflow.models.taskinstance.TaskInstance` changes state. +You can use these events to react to ``LocalTaskJob`` state changes. + - ``on_task_instance_running`` + +.. exampleinclude:: /../../airflow/example_dags/plugins/event_listener.py + :language: python + :dedent: 4 + :start-after: [START howto_listen_ti_running_task] + :end-before: [END howto_listen_ti_running_task] + - ``on_task_instance_success`` + +.. exampleinclude:: /../../airflow/example_dags/plugins/event_listener.py + :language: python + :dedent: 4 + :start-after: [START howto_listen_ti_success_task] + :end-before: [END howto_listen_ti_success_task] + - ``on_task_instance_failed`` -TaskInstance state change events occur when a ``TaskInstance`` changes state. -You can use these events to react to ``LocalTaskJob`` state changes. +.. exampleinclude:: /../../airflow/example_dags/plugins/event_listener.py Review Comment: NIT: would be nice to mention that you can retrieve the error in the text. Yes it will be visible in the example but mentioning it explicitly would be great. I'd also love others to review it as well. -- 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]
