Progress Updater
Project description
progress-updater
Writing the progress of a task to a backend!
Installation
Install it using pip
pip install progress-updater
Basic usage
from progress_updater import ProgressUpdater
from progress_updater.backends.mongo import MongoSettings
settings = MongoSettings(
mongo_connection="mongodb://user:pass@mongo:27017",
mongo_db="db",
mongo_collection="logs",
)
updater = ProgressUpdater(task_name="My Task", settings=settings)
with updater(block_name="First part"):
# doing things
updater.notify("doing first block...")
# doing more things
with updater(block_name="Second part"):
# doing things
updater.notify("doing second block...")
# doing more things
updater.raise_latest_exception() # if exists
The output is:
- Task: My task
- Entering First part
doing first block...
Time spent: 0h0m
Successfully completed
- Entering Second part
doing second block...
Time spent: 0h0m
Successfully completed
Backends
The available backends to store logs are Mongo, Redis and SQL. Please read the docs for further information.
Setting your backend with environment variables
You can set your backend by defining env vars.
The PU__
prefix indicates that it belongs to ProgressUpdater
.
# SQL
PU__SQL_DSN='postgresql+psycopg2://user:pass@postgres:5432/db'
PU__SQL_TABLE='logs'
...
# Redis
PU__REDIS_HOST='redis'
PU__REDIS_DB='1'
PU__REDIS_PASSWORD='pass'
...
# Mongo
PU__MONGO_CONNECTION='mongodb://user:pass@mongo:27017'
PU__MONGO_DB='db'
PU__MONGO_COLLECTION='logs'
...
And then when creating a ProgressUpdater
object, the backend will be
automatically configured.
from progress_updater import ProgressUpdater
with ProgressUpdater(task_name="My Task") as updater:
pass
Documentation
Please visit this link for documentation.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file progress_updater-0.1.9.tar.gz
.
File metadata
- Download URL: progress_updater-0.1.9.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.2 Linux/5.10.104-linuxkit
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bea3bb989e078defc07085b0d9920d1fbcbf8d53a6904071dbb0db335162fb84 |
|
MD5 | e4c6e03f0ba2c5f451e3f4961dd775e9 |
|
BLAKE2b-256 | 33059b46925c3e7f76885edcadfe285c8a007bcc1fcd17c3f686d4ee7dc4cb53 |
File details
Details for the file progress_updater-0.1.9-py3-none-any.whl
.
File metadata
- Download URL: progress_updater-0.1.9-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.2 Linux/5.10.104-linuxkit
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee5bdcd4703df0061371f944de80fdf38fc33484aa9087240b689ca7ef910895 |
|
MD5 | c888560cf135f983f018c81cfcdf7818 |
|
BLAKE2b-256 | b824a7385236bb47608cb21954a8515cbd83be8a4c421e15ead014f5951ef889 |