File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ def notification_email(context, state):
2525 email_port = int (Variable .get ("email_port" ))
2626
2727 print (context )
28- subject = f"Airflow Alert: Task ' { task } ' in DAG '{ dag } ' has { state .upper ()} "
28+ subject = f"Airflow Alert: Task in DAG '{ dag } ' has { state .upper ()} "
2929 body = f"""
3030 Hey { dag_owner }
3131
@@ -42,7 +42,9 @@ def notification_email(context, state):
4242
4343 ssl_context = ssl .create_default_context ()
4444
45- with smtplib .SMTP_SSL (mail_server , email_port , context = ssl_context ) as smtp :
45+ with smtplib .SMTP_SSL (
46+ mail_server , email_port , context = ssl_context
47+ ) as smtp :
4648 smtp .login (email_sender , email_password )
4749 smtp .sendmail (email_sender , email_receiver , em .as_string ())
4850 print ("Email Sent Successfully" )
@@ -53,5 +55,5 @@ def task_state_alert(context):
5355 This function send notification of a dags task
5456 """
5557 state = context .get ("task_instance" ).state
56- if state in ("success" ,"failed" ):
58+ if state in ("success" , "failed" ):
5759 notification_email (context , state )
Original file line number Diff line number Diff line change 1111 "email_on_failure" : True ,
1212 "email_on_retry" : False ,
1313 "email_on_success" : True ,
14- ' on_failure_callback' : task_state_alert ,
15- ' on_success_callback' : task_state_alert ,
14+ " on_failure_callback" : task_state_alert ,
15+ " on_success_callback" : task_state_alert ,
1616 "email" : ["chideraozigbo@gmail.com" ],
1717 "retries" : 1 ,
1818 "retry_delay" : timedelta (seconds = 3 ),
You can’t perform that action at this time.
0 commit comments