Skip to main content

mtnlog - A simple multinode performance logger for Python

Introduction

mtnlog is a simple multinode performance logger for Python. It is designed to be used in a similar way to Python's built-in logging module, but with a focus on performance logging. It provides a simple API for logging performance data, including start and end times, and allows for easy integration with other logging systems.

Installation

You can install mtnlog using pip:

pip install mtnlog

Usage

To use mtnlog, you have two features: JSONLogger and PerformanceLogger and PerformancePlotter.

JSONLogger

The JSONLogger class is a simple logger that writes performance data to a JSON file. You can create a new JSONLogger instance by passing a file path to the constructor:

from mtnlog import JSONLogger

logger = JSONLogger(log_dir='logs') # logs is the directory where the log file will be saved

You can then use the log method to log performance data:

logger.log('<your_dict>', filename='log') # your_dict is a dictionary with the data you want to log / filename is the name of the file

your_dict is a dictionary with the data you want to log. filename is the name of the file where the data will be saved

PerformanceLogger

The PerformanceLogger class is a logger for system performance data. It logs the the time taken to execute the block, as well as the CPU, memory, and GPU usage. You can create a new PerformanceLogger instance by passing a file path to the constructor:

from mtnlog import PerformanceLogger

collector = PerformanceLogger(log_dir="<your_log_dir>", log_node="<current_node>")

your_log_dir is the directory where the log file will be saved. current_node is the number of the node you are logging.

You can then use the change_tag method to change the tag of the log:

collector.change_tag("<new_tag>")

new_tag is the new tag you want to use.

To stop logging, you can use the stop method:

collector.stop()

PerformancePlotter

The PerformancePlotter class is a plotter for system performance data. It plots the time taken to execute the block, as well as the CPU, memory, GPU, and network usage. You can create a new PerformancePlotter instance by passing a file path to the constructor:

from mtnlog import PerformancePlotter

plotter = PerformancePlotter(base_dir="<your_base_dir>", log_node="<current_node>")

your_base_dir is the base directory where the log file will be saved. current_node is the number of the node you are logging.

You can then use the plot method to plot the data:

plotter.plot()

Example

Here is an example of how to use mtnlog:

from mtnlog import JSONLogger, PerformanceLogger, PerformancePlotter

# Create a JSONLogger instance

logger = JSONLogger(log_dir='logs')

# Log some data

logger.log({'message': 'Hello, world!'}, filename='log')

# Create a PerformanceLogger instance

collector = PerformanceLogger(log_dir='logs', log_node="0")

# Change the tag

collector.change_tag('new_tag')

# Stop logging

collector.stop()

# Create a PerformancePlotter instance

plotter = PerformancePlotter(base_dir='logs', log_node="0")

# Plot the data

plotter.plot()

Metadata

Release files for mtnlog 1.2.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mtnlog 1.2.17
File Size Uploaded
mtnlog-1.2.17.tar.gz 11.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mtnlog 1.2.17
File Interpreter ABI Platform
mtnlog-1.2.17-py3-none-any.whl Python 3 none any Details

Total release size: 24.2 kB

Release files / mtnlog-1.2.17.tar.gz

Download URL mtnlog-1.2.17.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
62ae30f041bc62b390fa1cc45533d05a007f62cd8aa1dacd6edf532e21aeffec
BLAKE2b-256 checksum
How to use checksums
a11aed8afec3126c3f5ba296b6660be4b82670b6f7a03a64ef611ca4b4252063
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Linux/5.14.21-150400.24.81_12.0.86-cray_shasta_c

Release files / mtnlog-1.2.17-py3-none-any.whl

Download URL mtnlog-1.2.17-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c57568fae8aa0ecd18d7b59b47ee8a04f13d22f847ec9a4ab1b258529285e6d
BLAKE2b-256 checksum
How to use checksums
0b4a24912149d12b9ebecb910087957847a81a2719c4c00563a595b7710a5326
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Linux/5.14.21-150400.24.81_12.0.86-cray_shasta_c

Release history Release notifications | RSS feed

This release

1.2.17 This release

2 release files

1.2.16

2 release files

1.2.15

2 release files

1.2.14

2 release files

1.2.13

2 release files

1.2.12

2 release files

1.2.11

2 release files

1.2.9

2 release files

1.2.8

2 release files

1.2.7

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page