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)"},
".*": True, # Any other field must be logged at the end
}
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.3.1.tar.gz
(13.7 kB
view details)
Built Distribution
File details
Details for the file rich-logger-0.3.1.tar.gz
.
File metadata
- Download URL: rich-logger-0.3.1.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b49e354297086f4378cb0c9bdbbe34d4241972b6f3723d42a0e280cdb64462b |
|
MD5 | 1f5810e2760b86596724ee2b1fae6aca |
|
BLAKE2b-256 | aea22f18436919a31e5fea5123098ded2d76faa8fc4201345d4d2c369bca020c |
File details
Details for the file rich_logger-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: rich_logger-0.3.1-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04ef8f0e22d096be992218eb594cbb2110ec3068aec77d6da2215090754197bd |
|
MD5 | 53361a4ebd72f04bb80056c627ea6f13 |
|
BLAKE2b-256 | 22963a42c0c49fb1a72a52379681c200458caf5da18be8d21d3157dfb630cea1 |