Created
January 8, 2019 19:43
-
-
Save flolas/430c548ec662c8d6002e66a14b82d8be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_slack_on_retry_callback(owners_list): | |
def retry_callback(context): | |
from airflow.operators import SlackAPIPostOperator | |
slack_conf = getVarIfExists("slack_conf", json=True) | |
message = '[{DS}]\n[{DAG}]\n[{TASK}]\n :warning: La tarea se está reintentando :warning: \n Alerta para {OWNERS} \n -----------'\ | |
.format( | |
DAG = context['dag'].dag_id, | |
TASK = context['task'].task_id, | |
DS = context['ds'], | |
OWNERS = ' '.join(owners_list) | |
) | |
slack_retry_notification = SlackAPIPostOperator(task_id="Notificar_Retry", | |
channel=slack_conf.get('channel'), | |
username=slack_conf.get('username'), | |
text=message, | |
token=slack_conf.get('token')) | |
return slack_retry_notification.execute() | |
return retry_callback |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment