A package to provide useful functionality for sending alerts about running simulations.
Project description
simulert
A package for generating alerts about simulations.
Installation
This project has not made it to Pypi so installation will require cloning the repository
and adding it as a development package with either pip install -e /path/to/simulert
or
conda develop /path/to/simulert
.
Usage
This package is architected similarly to Python's built-in logging package.
An Alerter
class is instantiated with getAlerter
and this class is triggered to send
alerts which are distributed to all the handlers registered with that class.
Current handlers include a logger (default), an emailer and a slack client.
The Alerter
currently provides two ways to trigger alerts: most simply,calling the
alert
method with a message; and possibly more conveniently, with the
simulation_alert
context wrapping the simulation code.
Example
from simulert import getAlerter
from simulert.handlers import Emailer, Slacker
emailer = Emailer(
"username",
"password",
("Simulations", "noreply_simulations@company.com"),
("Data scientist", "scientist@company.com"),
"smtp.mailserver.company.com",
)
slacker = Slacker("slack_app_token", "username")
alerter = getAlerter().add_handler(emailer).add_handler(slacker)
with alerter.simulation_alert("super dooper sim"):
run_simulation()
TODO
- Complete docstrings
- Test email.py, logs.py and slack.py
- Add default handler args that read environment variables
- Write a better README.md
- Tidy up pyproject.toml to include only necessary files
- Setup Github
- Automated testing
- Branch protection
- Deploy to Pypi via github with version management
- Add a changelog
- Add a logging handler as an event source.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.