Skip to main content

Table logger using Rich, aimed at Pytorch Lightning logging

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 and name
  • 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

import time
import random
from rich_logger import RichTablePrinter
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)
    t = time.time()
    for i in range(10):
        time.sleep(random.random())
        printer.log({"step": i, "task_precision": i/10. if i < 5 else 0.5-(i-5)/10.})
        time.sleep(random.random())
        printer.log({"step": i, "task_recall": 0. if i < 3 else (i-3)/10., "duration": time.time() - t})
        t = time.time()
    printer.finalize()
        
optimization()

Demo

Use it with PytorchLightning

from rich_logger import RichTableLogger
trainer = pl.Trainer(..., logger=[RichTableLogger(key="epoch", fields=logger_fields)])

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

rich_logger-0.1.3.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file rich_logger-0.1.3.tar.gz.

File metadata

  • Download URL: rich_logger-0.1.3.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.4

File hashes

Hashes for rich_logger-0.1.3.tar.gz
Algorithm Hash digest
SHA256 a054c7c7f9e987fc8e1541e1660d30a7ffadab53e43f44033ad4f03177fad69e
MD5 5ce97c15f301633245c89be01d31d5bb
BLAKE2b-256 2b4863e31454d82b095a9e873d7505a42a89d4262a118a3c00322dac58a1abd3

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page