The spiritual successor to knockknock for PyTorch Lightning, to get a notification when your training is complete or when it crashes during the process with a single callback.
- Supports E-Mail, Discord, Slack, Teams, Telegram
With pip
:
python -m pip install whos-there
With poetry
:
poetry add whos-there
With conda
:
conda install conda-forge::whos-there
Check here for more information.
import lightning.pytorch as pl
from whos_there.callback import NotificationCallback
from whos_there.senders.debug import DebugSender
trainer = pl.Trainer(
callbacks=[
NotificationCallback(senders=[
# Add your senders here
DebugSender(),
])
]
)
Requires your e-mail provider specific SMTP settings.
from whos_there.senders.email import EmailSender
# ...
EmailSender(
host="smtp.example.de",
port=587,
sender_email="from@example.com",
password="*********",
recipient_emails=[
"to1@example.com",
"to2@example.com",
]
)
Requires your Discord channel's webhook URL.
from whos_there.senders.discord import DiscordSender
# ...
DiscordSender(
webhook_url="https://discord.com/api/webhooks/XXXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
)
Requires your Slack room webhook URL and optionally your user id (if you want to tag yourself or someone else).
from whos_there.senders.slack import SlackSender
# ...
SlackSender(
webhook_url="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX", # gitleaks:allow
channel="channel_name",
user_mentions=[
"XXXXXXXX"
]
)
Requires your Team Channel webhook URL.
from whos_there.senders.teams import TeamsSender
# ...
TeamsSender(
webhook_url="https://XXXXX.webhook.office.com/",
user_mentions=[
"twsl"
]
)
You can also use Telegram Messenger to get notifications. You'll first have to create your own notification bot by following the three steps provided by Telegram here and save your API access TOKEN
.
Telegram bots are shy and can't send the first message so you'll have to do the first step. By sending the first message, you'll be able to get the chat_id
required (identification of your messaging room) by visiting https://api.telegram.org/bot<YourBOTToken>/getUpdates
and get the int
under the key message['chat']['id']
.
from whos_there.senders.telegram import TelegramSender
# ...
TelegramSender(
chat_id=1234567890,
token="XXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXX"
)
poetry run mkdocs build -f ./docs/mkdocs.yaml -d ./_build/
The conda repository is maintained here.
copier update --trust
This project was generated with
Big thanks to knockknock for the idea and code snippets.