Skip to main content

auto-alarm

A Python package that automatically sends email notifications when functions fail.

Features

  • Simple decorator-based API
  • Configurable via dictionary, JSON file, or environment variables
  • Support for multiple recipients
  • Optional success notifications
  • Full error traceback in email

Installation

pip install auto-alarm

Or install from source:

pip install -e .

Quick Start

from auto_alarm import init_notifier, notify_on_failure

# Initialize with SMTP settings
init_notifier(
    host='smtp.gmail.com',
    port=587,
    username='your_email@gmail.com',
    password='your_app_password',
    from_email='your_email@gmail.com'
)

# Use decorator to monitor function
@notify_on_failure('recipient@example.com')
def train_model(epochs):
    if epochs > 100:
        raise ValueError("Epochs cannot exceed 100")
    return f"Model trained for {epochs} epochs"

# Function fails - email will be sent automatically
result = train_model(150)

Configuration

Dictionary Configuration

from auto_alarm import init_notifier

init_notifier(
    host='smtp.gmail.com',
    port=587,
    username='your_email@gmail.com',
    password='your_app_password',
    from_email='your_email@gmail.com',
    use_tls=True  # default
)

JSON Configuration

// config.json
{
    "host": "smtp.gmail.com",
    "port": 587,
    "username": "your_email@gmail.com",
    "password": "your_app_password",
    "from_email": "your_email@gmail.com"
}
from auto_alarm import init_from_config

with open('config.json') as f:
    config = json.load(f)

init_from_config(config)

Environment Variables

Set these environment variables:

  • AUTO_ALARM_HOST
  • AUTO_ALARM_PORT
  • AUTO_ALARM_USERNAME
  • AUTO_ALARM_PASSWORD
  • AUTO_ALARM_FROM_EMAIL
from auto_alarm import init_from_config, Config

config = Config.from_env()
init_from_config(config)

API Reference

init_notifier(host, port, username, password, from_email, use_tls=True)

Initialize the global email notifier.

init_from_config(config)

Initialize from Config object or dictionary.

@notify_on_failure(to_emails, notify_on_success=False, success_message=None)

Decorator that sends email notification on function failure.

  • to_emails: Recipient email address(es) (str or list)
  • notify_on_success: Send notification on success (default: False)
  • success_message: Custom message for success notifications

SMTP Examples

Gmail

init_notifier(
    host='smtp.gmail.com',
    port=587,
    username='your_email@gmail.com',
    password='your_app_password',  # Use App Password, not your login password
    from_email='your_email@gmail.com'
)

Note: For Gmail, you need to enable 2-Step Verification and create an App Password.

Outlook

init_notifier(
    host='smtp.office365.com',
    port=587,
    username='your_email@outlook.com',
    password='your_password',
    from_email='your_email@outlook.com'
)

License

MIT

Metadata

Release files for auto-alarm 0.1.0

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

Source distribution (sdist)

Source distribution for auto-alarm 0.1.0
File Size Uploaded Provenance
auto_alarm-0.1.0.tar.gz 8.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for auto-alarm 0.1.0
File Interpreter ABI Platform
auto_alarm-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.5 kB

Release files / auto_alarm-0.1.0.tar.gz

Download URL auto_alarm-0.1.0.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a76953e7943784cb8837ffb304234742787baa5acf0d6d856e1e0cc4d0e5c9a3
BLAKE2b-256 checksum
How to use checksums
fa658422bd0a0d0a13d7a11d3452246d6abadb341b204cca9e42899f487a5511
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / auto_alarm-0.1.0-py3-none-any.whl

Download URL auto_alarm-0.1.0-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ca0c7cd8f191da799d9ba5050fd03557236c2e4b24b5f14efdb4c058107db41
BLAKE2b-256 checksum
How to use checksums
c518695783f35a6b18da9836460b8efb00732fd6329755d015356d86b130d0ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Security for auto-alarm 0.1.0

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.0 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