Skip to main content

prefect-alert

PyPI

Welcome!

Prefect is an open-source library that allows you to orchestrate and observe your dataflow defined in Python.

prefect-alert is a decorator that allows you to send alert when a Prefect flow fails.

Read this article if you are not familiar with how to send notifications with Prefect.

Getting Started

Python setup

Requires an installation of Python 3.8+.

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

The decorator is designed to work with Prefect 2.0. For more information about how to use Prefect, please refer to the Prefect documentation.

Installation

Install prefect-alert with pip:

pip install prefect-alert

Create a notification block

Blocks enable you to store configuration and provide an interface for interacting with external systems.

First, start with creating a notification block through UI or a Python script:

from prefect.blocks.notifications import SlackWebhook

slack_block = SlackWebhook(url="https://hooks.slack.com/services/XXX/XXX/XXX")

Send an alert

Next, use the block created and the decorator prefect_alert.alert_on_failure to send alert when a flow fails.

Send an alert when a flow fails

from prefect import flow, task 
from prefect.blocks.notifications import SlackWebhook
from prefect_alert import alert_on_failure

@task
def may_fail():
    raise ValueError()

@alert_on_failure(block_type=SlackWebhook, block_name="test")
@flow
def failed_flow():
    res = may_fail()
    return res

if __name__=="__main__":
    failed_flow()

And you will see something like this on your Slack:

Send an alert when a asynchronous flow fails

from prefect import flow, task 
from prefect.blocks.notifications import SlackWebhook
from prefect_alert import alert_on_failure
import asyncio

@task
async def may_fail():
    raise ValueError()

@alert_on_failure(block_type=SlackWebhook, block_name="test")
@flow
async def failed_flow():
    res = await may_fail()
    return res

if __name__=="__main__":
    asyncio.run(failed_flow())

Resources

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

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

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

Development

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

git clone https://github.com/khuyentran1401/prefect-alert.git

cd prefect-alert/

pip install -e ".[dev]"

# Install linting pre-commit hooks
pre-commit install

Metadata

Release files for prefect-alert 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prefect-alert 0.1.3
File Size Uploaded Provenance
prefect-alert-0.1.3.tar.gz 26.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for prefect-alert 0.1.3
File Interpreter ABI Platform
prefect_alert-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 36.0 kB

Release files / prefect-alert-0.1.3.tar.gz

Download URL prefect-alert-0.1.3.tar.gz
Size 26.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c79dd5e353fd79253253b5aa78f05fb0b16baf56844fb534a452bd2c03ee98a9
BLAKE2b-256 checksum
How to use checksums
1bad1b1d045e6ad3d68e8ea4d0bf2a06d8c440d6d1d02175d2b6bee54420c3ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / prefect_alert-0.1.3-py3-none-any.whl

Download URL prefect_alert-0.1.3-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d248a97ffd52a66e21d4afc112687d492a01057a8efbf2a2b94dda00e30c297
BLAKE2b-256 checksum
How to use checksums
73c075f6785cb8e578517ff253a47d2942369bea69ba80695a693e850897c2d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Security for prefect-alert 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page