Skip to main content

Logging Utility for ML Experiments

Project description

CircleCI PyPI - License PyPI - Python Version Code style: black

ml-logger

Logging utility for ML experiments

Why

People use different tools for logging experimental results - Tensorboard, Wandb etc to name a few. Working with different collaborators, I will have to switch my logging tool with each new project. So I made this simple tool that provides a common interface to logging results to different loggers.

Installation

  • pip install "mllogger[all]"

If you want to use only the filesystem logger, use pip install "mllogger"

Install from source

  • git clone git@github.com:shagunsodhani/ml-logger.git
  • cd ml-logger
  • pip install ".[all]"

Alternatively, pip install "git+https://git@github.com/shagunsodhani/ml-logger.git@master#egg=ml_logger[all]"

If you want to use only the filesystem logger, use pip install . or pip install "git+https://git@github.com/shagunsodhani/ml-logger.git@master#egg=ml_logger".

Documentation

https://shagunsodhani.github.io/ml-logger

Use

  • Make a logbook_config:

    from ml_logger import logbook as ml_logbook
    logbook_config = ml_logbook.make_config(
        logger_dir = <path to write logs>,
        wandb_config = <wandb config or None>,
        tensorboard_config = <tensorboard config or None>,
        mlflow_config = <mlflow config or None>)
    

    The API for make_config can be accessed here.

  • Make a LogBook instance:

    logbook = ml_logbook.LogBook(config = logbook_config)
    
  • Use the logbook instance:

    log = {
        "epoch": 1,
        "loss": 0.1,
        "accuracy": 0.2
    }
    logbook.write_metric_log(log)
    

    The API for write_metric_log can be accessed here.

Note

  • If you are writing to wandb, the log must have a key called step. If your log already captures the step but as a different key (say epoch), you can pass the wandb_key_map argument (set as {epoch: step}). For more details, refer the documentation here.

  • If you are writing to mlflow, the log must have a key called step. If your log already captures the step but as a different key (say epoch), you can pass the mlflow_key_map argument (set as {epoch: step}). For more details, refer the documentation here.

  • If you are writing to tensorboard, the log must have a key called main_tag or tag which acts as the data Identifier and another key called global_step. These keys are described here. If your log already captures these values but as different key (say mode for main_tag and epoch for global_step), you can pass the tensorboard_key_map argument (set as {mode: main_tag, epoch: global_step}). For more details, refer the documentation here.

Dev Setup

  • pip install -e ".[dev]"
  • Install pre-commit hooks pre-commit install
  • The code is linted using:
    • black
    • flake8
    • mypy
  • Tests can be run locally using nox

Acknowledgements

  • Config for circleci, pre-commit, mypy etc are borrowed/modified from Hydra

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

mllogger-0.5rc1.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

mllogger-0.5rc1-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file mllogger-0.5rc1.tar.gz.

File metadata

  • Download URL: mllogger-0.5rc1.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0.post20200119 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.8

File hashes

Hashes for mllogger-0.5rc1.tar.gz
Algorithm Hash digest
SHA256 03f4f02f2a792b593ec49235af97b6c5d54c3fa2221ceef35ad2582bd151f5a0
MD5 e49cb10557647e12e4addc71ab872798
BLAKE2b-256 1cd5a90ee8dfc7c70850167b8f0084dff1397c4d413aaa9600895f28a9975d69

See more details on using hashes here.

File details

Details for the file mllogger-0.5rc1-py3-none-any.whl.

File metadata

  • Download URL: mllogger-0.5rc1-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0.post20200119 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.8

File hashes

Hashes for mllogger-0.5rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 e2d91ef5bdf4dbcd0ce4da5116cf0cff67a4cdd9f4780716d386896400bb8981
MD5 5b1a10b74aaf254ae3e206f1ce293a89
BLAKE2b-256 42424c21105f3923ad90422c6edae3c4e33295d1b68e9b0ad5dcbae9b2f3226d

See more details on using hashes here.

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