# 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", msg_plain=None, email_to_cc=None, email_to_bcc=None, attachments=None, **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). Sending messages containing HTML code is supported - the default MIME type is set to the text/html.

Args:

  • subject (str, optional): the subject of the email; can also be provided at runtime
  • msg (str, optional): the contents of the email, added as html; can be used in combination of msg_plain; 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
  • msg_plain (str, optional): the contents of the email, added as plain text can be used in combination of msg; can also be provided at runtime
  • email_to_cc (str, optional): additional email address to send the message to as cc; can also be provided at runtime
  • email_to_bcc (str, optional): additional email address to send the message to as bcc; can also be provided at runtime
  • attachments (List[str], optional): names of files that should be sent as attachment; can also be provided at runtime
  • **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, msg_plain=None, email_to_cc=None, email_to_bcc=None, attachments=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
  • msg_plain (str, optional): the contents of the email, added as plain text can be used in combination of msg; defaults to the one provided at initialization
  • email_to_cc (str, optional): additional email address to send the message to as cc; defaults to the one provided at initialization
  • email_to_bcc (str, optional): additional email address to send the message to as bcc; defaults to the one provided at initialization
  • attachments (List[str], optional): names of files that should be sent as attachment; 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 as either a dictionary or a plain string; 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, webhook_secret=None, webhook_url=None)[source]

Run method which sends a Slack message.

Args:

  • message (Union[str,dict], optional): the message to send as either a dictionary or a plain string; if not provided here, will use the value provided at initialization
  • webhook_secret (str, optional): the name of the Prefect Secret which stores your slack webhook URL; defaults to "SLACK_WEBHOOK_URL"; if not provided here, will use the value provided at initialization
  • webhook_url (str, optional): the value of a Slack webhook URL that is returned from an upstream PrefectSecret task. If specified then the webhook_secret will not be used.
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



This documentation was auto-generated from commit n/a
on July 1, 2021 at 18:35 UTC