Skip to main content

TA collection enabling integration between Prefect and Discord.

Project description

prefect-discord


Welcome!

A collection containing a notification block making it easy to send messages and notifications from Prefect >= 2.4.1 to a Discord channel. Read on for instructions on how to use the DiscordWebhook block.

Getting Started

Python setup

Requires an installation of Python 3.7+.

We recommend using a Python virtual environment manager such as pipenv, conda or virtualenv.

These tasks are designed to work with Prefect 2. For more information about how to use Prefect, please refer to the Prefect documentation.

Installation

Install prefect-discord with pip:

pip install git+https://github.com/rpeden/prefect-discord.git

Then, register to view the block on Prefect Cloud:

prefect block register -m prefect_discord

Note, to use the load method on Blocks, you must already have a block document saved through code or saved through the UI.

Creating a Discord Webhook Block

Before you start, you'll need to add a webhook to one of your Discord channels by following these instructions. When you're done, copy the webhook URL.

Via the UI

Click on the Blocks menu, then click the + button in the page header to open the block catalog: blocks menu

Find the listing for the Discord Webhook block and click Add: Discord Webhook catalog entry

Add a name for your block, paste the Discord webhook URL you copied, and click Create: Discord Webhook creation page

You'll see your new block's page: Created Discord block page

And your block is ready to use!

In Python

from prefect_discord import DiscordWebhook

my_webhook = DiscordWebhook(
    url="https://my-discord-webhook-url"
)

my_webhook.save("awesome-discord-webhook")

Use Discord Webhook Notifications

from prefect import flow
from prefect_discord import DiscordWebhook


@flow
def example_flow():
    discord_webhook_block = DiscordWebhook.load("awesome-discord-webhook")
    discord_webhook_block.notify("Hello from Prefect!")

example_flow()

When you run this code, you should see this in your Discord channel: Prefect notification in Discord

Resources

If you encounter any bugs while using prefect-discord, feel free to open an issue in the prefect-discord repository.

If you have any questions or issues while using prefect-discord, you can find help in either the Prefect Discourse forum or the Prefect Slack community.

Feel free to ⭐️ or watch prefect-discord for updates too!

Development

If you'd like to install a version of prefect-discord for development, clone the repository and perform an editable install with pip:

git clone https://github.com/rpeden/prefect-discord.git

cd prefect-discord/

pip install -e ".[dev]"

# Install linting pre-commit hooks
pre-commit install

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prefect-2-discord-0.1.0.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

prefect_2_discord-0.1.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file prefect-2-discord-0.1.0.tar.gz.

File metadata

  • Download URL: prefect-2-discord-0.1.0.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for prefect-2-discord-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8c1906027b4b690183e0cfc25d3732c2a1efe698a85028741d8c7f8219a64ac2
MD5 c7af53792e720fdaec52ae11626b4a12
BLAKE2b-256 46cf2623b710a7485c48c528440ba751d40a6dd954f9270760141ee387b52808

See more details on using hashes here.

File details

Details for the file prefect_2_discord-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for prefect_2_discord-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4fd515ce1f38fd3994f1d8f9d41f2c2cb682b5a4d69c4b49a95cedaa9ab6dd53
MD5 affb2b35fff64beb70cdbcda01254b40
BLAKE2b-256 ae7ed96a8890df4afbcde13c4afad78768df6310a95b44d0d10fc7d41a357ad7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page