Metadata-Version: 2.4
Name: auto-data-alerts
Version: 0.0.2
Summary: Automated Data Alerts for Slack
Author-email: Cooper Richason <144618753+cooper-richason@users.noreply.github.com>
License: Apache-2.0
Project-URL: Repository, https://github.com/cooper-richason/auto-data-alerts
Project-URL: Documentation, https://cooper-richason.github.io/auto-data-alerts
Keywords: nbdev,jupyter,notebook,python
Classifier: Natural Language :: English
Classifier: Intended Audience :: Developers
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: fastcore
Requires-Dist: pandas
Requires-Dist: snowflake-connector-python
Requires-Dist: nbdev

# auto-data-alerts


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

`auto-data-alerts` is a Python package that monitors Snowflake views and
sends formatted alert messages to Slack channels. Point it at a view in
your `DATA_ALERTS` schema, configure a template and channel, and it
handles the rest — querying the data, formatting the message, sending to
Slack, and logging the result.

## Features

- **Snowflake integration** — queries any view in your `DATA_ALERTS`
  schema, no boilerplate required
- **5 message templates** — from simple row-by-row lists to grouped
  data, metrics dashboards, and summary cards
- **Smart skipping** — if a view returns no rows, the alert is skipped
  and the outcome is still logged
- **Alert history logging** — every run (success or failure) is written
  back to Snowflake for auditing
- **Debug mode** — set `DEBUG=TRUE` to redirect all messages to a test
  channel without changing any code

## Installation

Install the latest version directly from GitHub:

``` sh
pip install git+https://github.com/cooper-richason/auto-data-alerts.git
```

Or from [PyPI](https://pypi.org/project/auto-data-alerts/):

``` sh
pip install auto-data-alerts
```

## Setup

The package reads credentials from environment variables. Set the
following before running:

| Variable | Description |
|----|----|
| `SNOWFLAKE_USER` | Snowflake username |
| `SNOWFLAKE_PASSWORD` | Snowflake password |
| `SNOWFLAKE_ACCOUNT` | Snowflake account identifier |
| `SNOWFLAKE_WAREHOUSE` | Warehouse to use for queries |
| `SNOWFLAKE_DATABASE` | Database containing the `DATA_ALERTS` schema |
| `SLACK_BOT_TOKEN` | Slack Bot OAuth token (`xoxb-...`) |
| `DEBUG` | Set to `TRUE` to route all messages to your test channel (optional) |

## How to use

The core function is `send_alert`. Call it with the Snowflake view name,
a group label, a configuration dict, and the Slack channel ID:

``` python
from auto_data_alerts.core import send_alert

view_config = {
    'format_template': 'F1',          # which template to use
    'message_text': '@here, new alert:' # optional intro text
}

send_alert(
    view='my_alert_view',       # name of the Snowflake view in DATA_ALERTS schema
    view_group='my_team',       # prefix / team label used for titles and logging
    view_config=view_config,
    slack_channel='C01234ABCDE' # Slack channel ID
)
```

If the view returns no rows, the call returns early and logs a skipped
result. If `DEBUG=TRUE` is set in the environment, the message is sent
to your configured test channel instead.

See the [full usage
guide](https://cooper-richason.github.io/auto-data-alerts/API/core.html)
for complete setup instructions, Snowflake schema requirements, and
configuration options.

## Message Templates

Choose a template with the `format_template` key in `view_config`. All
templates include a header derived from the view name and log the result
to Snowflake.

| Template | Key | Best for |
|----|----|----|
| **F1** (default) | `'F1'` | Row-by-row list with a label on the left and detail fields on the right |
| **F2** | `'F2'` | Summary count and column stats with a “View Details” button |
| **F3** | `'F3'` | Rows grouped by a category column, with optional per-group stats |
| **F4** | `'F4'` | Metrics dashboard — configurable KPIs at the top, filtered critical alerts below |
| **F5** | `'F5'` | Single-row view where each column becomes its own section block |
