1

I created slack_alert_dag contains a class SlackAlert to send alerts to slack:

def __init__(self, context_args=None):
        self.domain_config = None
        self.context_args = context_args
        #etc...

def send_to_chat(self, msg):
    connection = BaseHook.get_connection(connection_id)
    print('The connection is: ' + connection)
    if self.domain_config['chat-send-log-level'].lower() == 'info':
        self.send_to_chat(msg)
        #etc...

In run_my_dag dag I do the following:

def run(ds,**kwargs):
    slack = SlackAlert(kwargs)
    dag1.send_to_chat('text_msg')
    #etc...

with dag() ... I use PythonOperator() to print the logs

  1. although the connection is fine, but I do not get alerts (it works if I put the connection definition within run_my_dag but it keeps sending alerts every time the dag is parsed) that's why I take the connection definition out.

  2. I get the error:

if self.domain_config['chat-send-log-level'].lower() == 'info':
    TypeError: 'NoneType' object is not subscriptable

I appreciate your assistance

Jamie
  • 1,530
  • 1
  • 19
  • 35
DDMYZ
  • 33
  • 4

0 Answers0