Table logger using Rich
Project description
rich-logger
Table logger using Rich, aimed at Pytorch Lightning logging
Features
- display your training logs with pretty rich tables
- describe your fields with
goal
("higher_is_better" or "lower_is_better"),format
andname
- a field descriptor can be matched with any regex
- a field name can be computed as a regex substitution
- works in Jupyter notebooks as well as in a command line
- integrates easily with Pytorch Lightning
Demo
from rich_logger import RichTablePrinter
import time
import random
from tqdm import trange
logger_fields = {
"step": {},
"(.*)_precision": {
"goal": "higher_is_better",
"format": "{:.4f}",
"name": r"\1_p",
},
"(.*)_recall": {
"goal": "higher_is_better",
"format": "{:.4f}",
"name": r"\1_r",
},
"duration": {"format": "{:.1f}", "name": "dur(s)"},
}
def optimization():
printer = RichTablePrinter(key="step", fields=logger_fields)
printer.hijack_tqdm()
t = time.time()
for i in trange(10):
time.sleep(random.random() / 3)
printer.log(
{
"step": i,
"task_precision": i / 10.0 if i < 5 else 0.5 - (i - 5) / 10.0,
}
)
time.sleep(random.random() / 3)
printer.log(
{
"step": i,
"task_recall": 0.0 if i < 3 else (i - 3) / 10.0,
"duration": time.time() - t,
}
)
printer.log({"test": i})
t = time.time()
for j in trange(5):
time.sleep(random.random() / 10)
printer.finalize()
optimization()
Use it with PytorchLightning
from rich_logger import RichTableLogger
trainer = pl.Trainer(..., logger=[RichTableLogger(key="epoch", fields=logger_fields)])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rich-logger-0.2.0.tar.gz
(9.1 kB
view details)
Built Distribution
File details
Details for the file rich-logger-0.2.0.tar.gz
.
File metadata
- Download URL: rich-logger-0.2.0.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.8.10 Linux/5.15.0-1020-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af77db803f043ce33db4798e5e068dbcf3e642bafa7b068dc7fd445c63d33c21 |
|
MD5 | 1187b7ba50a226988e74a0386052966f |
|
BLAKE2b-256 | bf3f925bf6766fab8120f8f294e4100a63fc7f834c012b4c7dd4d222228b1c77 |
Provenance
File details
Details for the file rich_logger-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: rich_logger-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.8.10 Linux/5.15.0-1020-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c7e78bfe49014315d48537055359d441d9bd8896d390b217418c73d19ca9394 |
|
MD5 | b6f9bc830a384e023e4bc5fc7e67da17 |
|
BLAKE2b-256 | 3c98dc9dfa5599bb79f23f056cd1cfcc6c54e747cbef7f86b7fa7a3161da6f51 |