print-on-steroids 🏋️♂️
A lean and hackable rich logger and drop-in enhanced replacement for the native print function.
Installation
You can install print-on-steroids with pip:
pip install print-on-steroids
or conda:
conda install -c conda-forge print-on-steroids
We use the better-exceptions package if available to pretty print tracebacks. To install better-exceptions, use pip install print-on-steroids[exceptions] instead or run pip install better-exceptions manually.
Features
- Support for logging only on rank zero in distributed setups (e.g. DistributedDataParallel or sharded training in Deep Learning)
- Gracefully handles
tqdmandtqdm.richprogress bars (logs during training do not interrupt the progress bar!) - A context manager and decorator for beautiful and enriched exception printing
- Rich meta-information for free like timestamps and originating line of code (turned into a clickable deeplink by VS Code)
- Easy switching between
devandpackagemodes when publishing packages to PyPI (cleaner logs without clutter)
Usage
print_on_steroids - like print but on steroids!
from print_on_steroids import print_on_steroids as print
# Enjoy enhanced print with optional log levels, timestamp, and originating line of code
print("Enhanced", "print!", level="success", print_time=True, print_origin=True)
# Logging with multiple processes - avoid terminal clutter
print("Gets printed", rank=0, rank0_only=True)
print("Doesn't get printed", rank=1, rank0_only=True)
Use logger for more advanced use cases:
from print_on_steroids import logger
# Full-fledged logger object out-of-the-box
logger.log("This", "is", "cool", level="info")
# or give the log level 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 agai
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="MyPackage")
All methods gracefully handle tqdm - no interrupted progress bars:
from print_on_steroids import logger, print_on_steroids as print
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)
Beautifully formatted Exception and traceback printing:
from print_on_steroids import graceful_exceptions
# As a context manager:
with graceful_exceptions():
# Do stuff...
# As a decorator:
@graceful_exceptions()
def do_stuff():
# Do stuff...
Metadata
Release files for print-on-steroids 1.2.3
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 |
|---|---|---|---|---|
| print-on-steroids-1.2.3.tar.gz | 12.9 kB | Without provenance | Details for print-on-steroids-1.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| print_on_steroids-1.2.3-py3-none-any.whl | Python 3 | none | any | Details for print_on_steroids-1.2.3-py3-none-any.whl |
Total release size: 21.6 kB
Release files / print-on-steroids-1.2.3.tar.gz
| Download URL | print-on-steroids-1.2.3.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3d2027511c6cd68e3ed808b34270bfc2141bdfbf697dccc14248a60e0037aef5
|
|
BLAKE2b-256 checksum How to use checksums |
f71372952e34831493d98104a2e726277502ab65503c307a1ef570a9f29b2965
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / print_on_steroids-1.2.3-py3-none-any.whl
| Download URL | print_on_steroids-1.2.3-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed8e28a3b798d86cc9c185486ba713948600db433c2e3f562606b6d1322dc951
|
|
BLAKE2b-256 checksum How to use checksums |
6189e81e3b458b777a4fefb265e3d7501775675a2465a57ae50b9f9a240ec092
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Security for print-on-steroids 1.2.3
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.