Vladislav Bogucharov
04/27/2021, 1:10 PMstate.TriggerFailed is a child of state.Failed. When one of my tasks fails, then I get the state.Failed from this task and then from the next task, which actually didn't break, I get state.TriggerFailed with message _TRIGGERFAIL('Trigger was "all_successful" but some of the upstream tasks failed.',)._
I would like to receive information only about the failed task. At the moment I have implemented the following logic, is this the best practice?
if isinstance (new_state, state.Failed) and not isinstance (new_state, state.TriggerFailed):Zach Angell
if isinstance (new_state, state.Failed) and not isinstance (new_state, state.TriggerFailed):Jenny
04/27/2021, 1:36 PMVladislav Bogucharov
04/27/2021, 1:55 PMdef telegram_alarm(task, old_state, new_state):
    if isinstance(new_state, state.Failed) and not isinstance(new_state, state.TriggerFailed):
        flow_name = prefect.context.to_dict()['flow_name']
        task_name = task.name
        error_text = repr(new_state.result)
        message_data = {'chat_id': CHAT_ID, 'text': f'[{flow_name}] - [{task_name}] - {error_text}'}
        <http://requests.post|requests.post>(TELEGRAM_URL + 'sendMessage', data=message_data)
If I do not additionally specify not isinstance (new_state, state.TriggerFailed), then I will receive two messages in telegrams, which does not correspond a little to what I want. One task has broken, I want to receive one message. Just asking if this is the best practice at the moment.Vladislav Bogucharov
04/27/2021, 2:00 PMZach Angell
Jenny
04/27/2021, 2:05 PMVladislav Bogucharov
04/27/2021, 2:10 PM