Introduction
notipi is a python library to send custom notifications on Telegram and MacOS
Use cases include:
- Getting notified whenever a long running scripts finishes execution
- Knowing whenever a milestone is reached during ML / DL trainings
Installation
$ pip install notipi
Setup
If you wish to use just the MacOS notifications and not Telegram - you don't need anymore steps and start using the library right away. Refer the Usage examples below.
To use Telegram - you would be needing two environment variables: BOT_API_TOKEN and CHAT_ID
To get BOT_API_TOKEN:
- In the telegram app, initiate conversation with
@BotFather(you can also click here). - Send
/newbotas the message to@BotFatherand provide a new name and username for your bot account as per the instructions. @BotFatherwill reply with a unique api token - this is yourBOT_API_TOKEN
(Note: Detailed instructions to create a new bot can be found at Telegram website)
To get CHAT_ID:
- Once a new bot is created, send a dummy message to the bot via Telegram app so that your chat gets assigned an ID.
- Run the following script with your
BOT_API_TOKENto get yourCHAT_ID
from notipi.notipi import get_chat_id
get_chat_id(BOT_API_TOKEN)
This will give the following output:
Your CHAT ID: 1234567890
Once the BOT_API_TOKEN and CHAT_ID are obtained, set the environment variables
export BOT_API_TOKEN=<bot_api_token>
export CHAT_ID=<chat_id>
Usage
Once the required environment variables are in place, you can use notipi in the following ways to send messages via Telegram.
(NOTE: If the environment variables are not set - the messages will be sent only via MacOS notifications by default)
(1) As a regular function
from notipi.notipi import notify
def func():
for i in range(1000):
if i%100==0:
notify(f"Currently at {i}")
(2) As a decorator
from notipi.notipi import notify
@notify
def func():
for i in range(1000):
pass
When func() is invoked - you will be notified once it finishes execution
NOTE: Both Approaches (1) and (2) are compatible inside Jupyter Notebook as well
Once func3() is invoked - you will receive two notifications - first one after func1() is processed and second one after func2() is executed.
(3) As a command line tool
$ noticli -c python example.py
A notification will be sent once example.py finishes execution
Metadata
Release files for notipi 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| notipi-1.1.1.tar.gz | 44.8 kB | Without provenance | Details for notipi-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| notipi-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for notipi-1.1.1-py3-none-any.whl |
Total release size: 87.6 kB
Release files / notipi-1.1.1.tar.gz
| Download URL | notipi-1.1.1.tar.gz |
|---|---|
| Size | 44.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aa90d915bd36484f2eff53833cd049a1997f3686c1c7cdb0b72285fe5433ce6e
|
|
BLAKE2b-256 checksum How to use checksums |
3c3a2da41075b476fdf79291539f656583f894de2002c17dae89b320240afd99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / notipi-1.1.1-py3-none-any.whl
| Download URL | notipi-1.1.1-py3-none-any.whl |
|---|---|
| Size | 42.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
60c69c1fb143a7775cc63e47095a7ff39735e9a8288a121a6f64c2487cd57067
|
|
BLAKE2b-256 checksum How to use checksums |
6cc83154d95d36f90f09ab9152889c31d5e724919fa0158f26d256448422dbd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Security for notipi 1.1.1
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.