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
updater = ProgressUpdater(task_name="My Task")
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
If you want to save the output in a Database you will need to define a backend. There are three backends available to save our logs.
- Mongo.
- Redis.
- SQL.
from progress_updater.backends import MongoLog
from uuid import UUID
log = MongoLog.get(uuid=UUID("<your task uuid>"))
assert log.status == "SUCCESS"
Settings
There are some possible ways to pass settings to the updater. This is the priority.
- Passing settings as parameters when creating a
ProgressUpdater
object.
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",
)
with ProgressUpdater(task_name="My Task", settings=settings) as updater:
pass
- Environment variables.
The PU__
prefix indicates that it belongs to ProgressUpdater
.
export PU__SQL_DSN=postgresql+psycopg2://user:pass@postgres:5432/db
export PU__SQL_TABLE=logs
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
progress_updater-0.1.3.tar.gz
(8.1 kB
view hashes)
Built Distribution
Close
Hashes for progress_updater-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ae4b13c906a0d09a6c1eaf534f7b70b7d7a00761d396931e1600b4de0b13045 |
|
MD5 | b4953fd0f8e1412761d2f47ed64e7910 |
|
BLAKE2b-256 | 2413fdfb2e6e70235932a940b5367a66a9a021b46130b4f19a19aa683e07b1e5 |