Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for templating in on_failure_callback #209

Closed
jroach-astronomer opened this issue Jul 29, 2024 · 4 comments · Fixed by #252
Closed

Add support for templating in on_failure_callback #209

jroach-astronomer opened this issue Jul 29, 2024 · 4 comments · Fixed by #252
Assignees
Labels
enhancement New feature or request priority/high

Comments

@jroach-astronomer
Copy link
Member

In reference to #206, add support for templating in on_failure_callback. Requester is specifically looking to support templated parameters that do not need to be stored in a .py file.

Here's an example (from the issue submitted by @matveykortsev) for reference:

from airflow.providers.slack.notifications.slack import send_slack_notification
'on_failure_callback': [
        send_slack_notification(
            slack_conn_id='slack',
            text="""
                :red_circle: Task Failed. 
                *Task*: {{ ti.task_id }}  
                *Dag*: {{ ti.dag_id }} 
                *Execution Time*: {{ ti.execution_date }}  
                *Log Url*: {{ ti.log_url }} 
                """,
            channel="analytics-alerts",
            username="Airflow",
        )
    ],

@pankajastro has created an issue (#200) to ensure consistency between native Airflow and dag-factory.

@jroach-astronomer
Copy link
Member Author

jroach-astronomer commented Aug 5, 2024

This would be a new feature, I'm going to see if it's something that's feasible. Basically, we'd need to support functionality that looks like this:

<dag-id>:
  default_args:
    on_failure_callback: <path-to-function>
      <arg-name>: value
      <arg-name>: value

@cmarteepants cmarteepants added enhancement New feature or request priority/high labels Aug 6, 2024
@cmarteepants cmarteepants added this to the DAG Factory 0.20.0 milestone Aug 6, 2024
@matveykortsev
Copy link
Contributor

Hi guys, is there any eta for this release?

@jroach-astronomer
Copy link
Member Author

@matveykortsev, there is currently a Pull Request in review with a solution to this issue.

@matveykortsev
Copy link
Contributor

@jroach-astronomer I see, there is not mention in PR so haven't seen this.
Thanks, cant wait for release!

pankajastro added a commit that referenced this issue Oct 30, 2024
Add support for templating in `on_failure_callback`. Requester is
specifically looking to support templated parameters that do not need to
be stored in a `.py` file.

Here's an example (from the issue submitted by @matveykortsev) for
reference:

```
from airflow.providers.slack.notifications.slack import send_slack_notification
'on_failure_callback': [
        send_slack_notification(
            slack_conn_id='slack',
            text="""
                🔴 Task Failed. 
                *Task*: {{ ti.task_id }}  
                *Dag*: {{ ti.dag_id }} 
                *Execution Time*: {{ ti.execution_date }}  
                *Log Url*: {{ ti.log_url }} 
                """,
            channel="analytics-alerts",
            username="Airflow",
        )
    ],
```

Closes: #209

---------

Co-authored-by: Pankaj Singh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority/high
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants