# Notification Tasks


Collection of tasks for sending notifications.

Useful for situations in which state handlers are inappropriate.

# EmailTask

class

prefect.tasks.notifications.email_task.EmailTask

(subject=None, msg=None, email_to=None, email_from="notifications@prefect.io", smtp_server="smtp.gmail.com", smtp_port=465, smtp_type="SSL", **kwargs)[source]

Task for sending email from an authenticated email service over SMTP. For this task to function properly, you must have the "EMAIL_USERNAME" and "EMAIL_PASSWORD" Prefect Secrets set. It is recommended you use a Google App Password if you use Gmail. The default SMTP server is set to the Gmail SMTP server on port 465 (SMTP-over-SSL)

Args:

  • subject (str, optional): the subject of the email; can also be provided at runtime
  • msg (str, optional): the contents of the email; can also be provided at runtime
  • email_to (str, optional): the destination email address to send the message to; can also be provided at runtime
  • email_from (str, optional): the email address to send from; defaults to notifications@prefect.io
  • smtp_server (str, optional): the hostname of the SMTP server; defaults to smtp.gmail.com
  • smtp_port (int, optional): the port number of the SMTP server; defaults to 465
  • smtp_type (str, optional): either SSL or STARTTLS; defaults to SSL
  • **kwargs (Any, optional): additional keyword arguments to pass to the base Task initialization

methods:                                                                                                                                                       

prefect.tasks.notifications.email_task.EmailTask.run

(subject=None, msg=None, email_to=None, email_from=None, smtp_server=None, smtp_port=None, smtp_type=None)[source]

Run method which sends an email.

Args:

  • subject (str, optional): the subject of the email; defaults to the one provided at initialization
  • msg (str, optional): the contents of the email; defaults to the one provided at initialization
  • email_to (str, optional): the destination email address to send the message to; defaults to the one provided at initialization
  • email_from (str, optional): the email address to send from; defaults to the one provided at initialization
  • smtp_server (str, optional): the hostname of the SMTP server; defaults to the one provided at initialization
  • smtp_port (int, optional): the port number of the SMTP server; defaults to the one provided at initialization
  • smtp_type (str, optional): either SSL or STARTTLS; defaults to the one provided at initialization
Returns:
  • None



# SlackTask

class

prefect.tasks.notifications.slack_task.SlackTask

(message=None, webhook_secret="SLACK_WEBHOOK_URL", **kwargs)[source]

Task for sending a message via Slack. For this task to function properly, you must have a Prefect Secret set which stores your Slack webhook URL. For installing the Prefect App, please see these installation instructions.

Args:

  • message (str, optional): the message to send; can also be provided at runtime
  • webhook_secret (str, optional): the name of the Prefect Secret which stores your slack webhook URL; defaults to "SLACK_WEBHOOK_URL"
  • **kwargs (Any, optional): additional keyword arguments to pass to the base Task initialization

methods:                                                                                                                                                       

prefect.tasks.notifications.slack_task.SlackTask.run

(message=None)[source]

Run method which sends a Slack message.

Args:

  • message (str, optional): the message to send; if not provided here, will use the value provided at initialization
Returns:
  • None



# PushbulletTask

class

prefect.tasks.notifications.pushbullet_task.PushbulletTask

(msg=None, **kwargs)[source]

Task for sending a notification to a mobile phone (or other device) using pushbullet. For this task to function properly, you must have the "PUSHBULLET_TOKEN" Prefect Secret set. You can set up a pushbullet account and/or get a token here: https://www.pushbullet.com/#settings/account

Args:

  • msg(str, optional): The message you want to send to your phone; can also be provided at runtime.
  • **kwargs (Any, optional): additional keyword arguments to pass to the standard Task init method

methods:                                                                                                                                                       

prefect.tasks.notifications.pushbullet_task.PushbulletTask.run

(msg=None, access_token=None)[source]

Run method for this Task. Invoked by calling this Task after initialization within a Flow context, or by using Task.bind.

Args:

  • msg (str): The message you want sent to your phone; defaults to the one provided at initialization
  • access_token (str): a Pushbullet access token, provided with a Prefect secret. Defaults to the "PUSHBULLET_TOKEN" secret
Raises:
  • None


Returns:
  • None



This documentation was auto-generated from commit n/a
on May 14, 2020 at 21:12 UTC