Archive for 2024
Draft
from airflow.hooks.base import BaseOperatorHook
class MySuccessCallbackHook(BaseOperatorHook):
def __init__(self, task_instance):
super().__init__(task_instance)
def run_success_callback(self, context):
# Your custom logic here
print(f"Task {context.task_instance.task_id} finished successfully!")
from airflow.operators.python import PythonOperator
success_callback_hook = MySuccessCallbackHook(task_instance=task_instance)
task1 = PythonOperator(
task_id='my_task',
python_callable=my_task_function,
on_success_callback=lambda context: success_callback_hook.run_success_callback(context),
dag=your_dag,
)