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 Apprise Provider #31533

Merged
merged 33 commits into from
Jun 21, 2023
Merged

Add Apprise Provider #31533

merged 33 commits into from
Jun 21, 2023

Conversation

utkarsharma2
Copy link
Contributor

@utkarsharma2 utkarsharma2 commented May 25, 2023

Adding Apprise Provider, which is a module to send notifications to a bunch of services like -

  1. Microsoft Teams
  2. Twitter
  3. Reddit

The entire list of supported services can be found here

This provider is especially helpful in scenarios where Airflow doesn't have a provider for service and you want to send notifications to that service. Like MS Teams at the moment, to send notifications to MS teams we would just need to create the apprise connection with the right value for the config field example, which you can get by following the instructions here

{"path": "https://team-name.office.com/webhook/abcdefgf8-2f4b-4eca-8f61-225c83db1967@abcdefg2-5a99-4849-8efc-c9e78d28e57d/IncomingWebhook/291289f63a8abd3593e834af4d79f9fe/a2329f43-0ffb-46ab-948b-c9abdad9d643"}

Then in your DAG you can do something like this -

from datetime import datetime
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.apprise.notifications.apprise import send_apprise_notification
from apprise import NotifyType

with DAG(
    dag_id="apprise_notifier_testing",
    schedule_interval=None,
    start_date=datetime(2023, 1, 1),
    catchup=False,
    on_success_callback=[
        send_apprise_notification(apprise_conn_id="apprise_conn", body="The dag {{ dag.dag_id }} failed", notify_type=NotifyType.FAILURE)
    ],
):
    BashOperator(
        task_id="mytask",
        on_failure_callback=[
            send_apprise_notification(apprise_conn_id="apprise_conn", body="The task {{ ti.task_id }} failed", notify_type=NotifyType.FAILURE)
        ],
        bash_command="fail",
    )

@utkarsharma2 utkarsharma2 marked this pull request as ready for review May 25, 2023 05:44
@utkarsharma2 utkarsharma2 marked this pull request as draft May 25, 2023 08:51
Copy link
Contributor

@eladkal eladkal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see how this provider be useful however you need to follow the policy of adding new provider https://github.com/apache/airflow/blob/main/PROVIDERS.rst#accepting-new-community-providers

it needs to be discussed and accepted in the mailing list first

@utkarsharma2 utkarsharma2 marked this pull request as ready for review May 30, 2023 03:47
@jedcunningham
Copy link
Member

Lazy consensus was reached in https://lists.apache.org/thread/2gh845jb8k0nlvzpqdm4pk1t44djhs92

airflow/providers/apprise/hooks/apprise.py Outdated Show resolved Hide resolved
airflow/providers/apprise/hooks/apprise.py Show resolved Hide resolved
airflow/providers/apprise/hooks/apprise.py Outdated Show resolved Hide resolved
airflow/providers/apprise/hooks/apprise.py Outdated Show resolved Hide resolved
airflow/providers/apprise/hooks/apprise.py Outdated Show resolved Hide resolved
docs/apache-airflow-providers-apprise/connections.rst Outdated Show resolved Hide resolved
docs/apache-airflow-providers-apprise/index.rst Outdated Show resolved Hide resolved
docs/apache-airflow-providers-apprise/index.rst Outdated Show resolved Hide resolved
generated/provider_dependencies.json Outdated Show resolved Hide resolved
utkarsharma2 and others added 9 commits June 1, 2023 09:21
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
utkarsharma2 and others added 5 commits June 2, 2023 09:43
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
airflow/providers/apprise/provider.yaml Outdated Show resolved Hide resolved
Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@potiuk potiuk merged commit f4c4b77 into apache:main Jun 21, 2023
61 checks passed
ferruzzi pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Jun 27, 2023
@ephraimbuddy ephraimbuddy added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Jul 6, 2023
@ephraimbuddy ephraimbuddy added this to the Airflow 2.7.0 milestone Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:dev-tools area:providers changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) kind:documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants