A lean & hackable rich logger and print function.
Project description
print-on-steroids :weight_lifting_man:
A lean and hackable rich logger and print function.
Installation
pip install print-on-steroids
conda install -c conda-forge print-on-steroids
Features
- Support for logging only on rank zero in distributed setups (e.g. Deep Learning)
- Gracefully handles
tqdm
andtqdm.rich
progress bars (no annoying leftover progress bars anymore!) - Rich meta-information for free like timestamps and originating line of code with clickable link
- Easy switching between
dev
andpackage
modes when publishing packages to PyPI (cleaner logs without clutter)
Usage
from print_on_steroids import print_on_steroids as print, logger
# Enjoy enhanced print with optional log levels, timestamp, and originating line of code
print("It's like", "your regular", "Python print function", "but better", level="success")
# Logging with multiple processes - avoid terminal clutter
print("Gets printed", rank=0, rank0=True)
print("Doesn't get printed", rank=1, rank0=True)
# Full-fledged logger object out-of-the-box
logger.log("This", "is", "cool", level="info")
# or directly:
logger.info("This", "is", "cool")
logger.warning("This", "is", "dangerous")
logger.error("This", "is", "fatal")
...
# Easy setup for distributed setting:
logger.config(rank=RANK, print_rank0_only=True)
# Afterwards, the rank is remembered and does not need to be passed again
logger.success("Dataset processing finished!") # <-- this now prints only on rank zero
# For cleaner logs when publishing a package, use this:
logger.config(mode="package", package_name="torch")
# Gracefully handles tqdm
from tqdm import tqdm
for i in tqdm(range(42), desc="This works!"):
sleep(1)
logger.success("Work done:", i)
print_on_steroids("Work done:", i)
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
print-on-steroids-1.1.0.tar.gz
(10.7 kB
view hashes)
Built Distribution
Close
Hashes for print_on_steroids-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8708d6d7b2ce37a9d9eb4ccba2a10a4f6bd9e03c5fd6ab78113a5cac9d0c00d5 |
|
MD5 | f2f19ea213648f406d72bc63f21110ea |
|
BLAKE2b-256 | 6c4cf11be2180a2575a3d8a28d5fa4792df931a473153432a2479a163f0f4e06 |