Donentolon
Donentolon

Reputation: 1581

Different behavior depending on whether the DAG is manually triggered or not

I know Airflow distinguishes between manual and scheduled triggers of a DAG - the pattern of their ID is different, and also the UI in Tree View shows an outlined circle for one but not the other.

I have a DAG that uses a Python callable as on_failure_callback to emit failure alert. I now want to modify this DAG so that it will emit one type of alert when a manually triggered run fails, while emitting a different alert when the run was triggered by the scheduler.

I can do this by simply parsing the string in {{ execution_date }}. However, that seems hacky. Is there a flag that I can check instead?

Upvotes: 0

Views: 1313

Answers (1)

lilsebastian
lilsebastian

Reputation: 74

Seems very related to this question: Can I programmatically determine if an Airflow DAG was scheduled or manually triggered?

Looks like you can look up the run_id and parse that instead which might be slightly better.

Upvotes: 1

Related Questions