Matías Senger
Matías Senger July 5th 2021

Motivation

Some processes in the lab are repetitive (just a for loop) and take a lot of time.

Example: A 2D laser scan on an R&D silicon detector:

This process can go from a few minutes up to a couple of weeks 😱.

It would be nice to:

Furthermore, it would be nice to have all this information available worldwide in your mobile/computer by adding just 3 lines of code to your script.

A simple Telegram bot can do the job!

A simple solution

Simple yet effective pure Python package (link) that sends notifications to a Telegram conversation:

Usage

from progressreporting.TelegramProgressReporter import TelegramProgressReporter

MAX_K = 99999

with TelegramProgressReporter(
	total = MAX_K, 
	telegram_token = 'token of your bot', 
	telegram_chat_id = 'ID of the chat to send the messages', 
	loop_name = 'Optional loop name'): 
as reporter:
	for k in range(MAX_K):
		# Do some stuff...
		reporter.update(1) # 1 means 1/MAX_K completed.

The reporter will:

The reporter will not: You will:

Run first example and come back!

Run the rest of the examples.

Conclusions

Presented a simple pure Python package that reports the progress of a loop to a Telegram chat using a bot.

Tested on Windows, Linux and Raspberry Pi.