Skip to main content

An MLflow plugin that automatically logs system-level metrics (CPU, memory, disk, GPU, OS) as run tags for improved experiment observability.

Project description

mlflow-sysmetrics

🧠 A lightweight MLflow Run Context Provider that automatically logs system-level metrics (CPU, memory, disk, GPU, OS) as run tags.

✅ Cross-platform · 🔌 Plugin-ready · 🧪 Tested · ⚙️ Minimal dependencies


📦 What it does

This plugin automatically adds system environment metadata to each MLflow run. It enables lightweight observability for experiment tracking — useful in both local development and remote execution contexts.

✅ Captured Tags

Tag Key Description
sys.cpu CPU model or architecture
sys.cpu_cores Logical CPU core count
sys.memory_gb Total system memory (GB)
sys.disk_free_gb Free disk space in current directory (GB)
sys.platform OS and kernel version
sys.gpu GPU name via nvidia-smi or "None"
sysmetrics.error Captures any exception during tagging

🚀 Installation

poetry add mlflow-sysmetrics

Requires: Python ≥ 3.9 · mlflow ≥ 2.0 · psutil (automatically included)


🛠️ Usage

Set the environment variable to activate the plugin:

export MLFLOW_RUN_CONTEXT_PROVIDER=sysmetrics

Then run any MLflow experiment:

import mlflow

with mlflow.start_run():
    mlflow.log_param("foo", "bar")
    # Plugin will automatically add sys.* tags

🧪 Testing

Run both unit and integration tests:

poetry run pytest -m unit
poetry run pytest -m integration

To manually verify plugin behavior:

export MLFLOW_RUN_CONTEXT_PROVIDER=sysmetrics
poetry run python scripts/debug_run.py

📷 Example: Debug Script Output

You can verify system metrics manually with the debug script. Below is a sample output:

Example terminal output of sysmetrics plugin


🔍 Project Structure

mlflow-sysmetrics/
├── src/mlflow_sysmetrics/
│   ├── __init__.py
│   ├── constants.py
│   └── system_context.py         # Plugin implementation
├── tests/
│   ├── unit/                     # Logic-only tests
│   └── integration/              # MLflow integration tests
├── scripts/
│   └── debug_run.py              # Manual testing script
├── assets/                       # Image and media assets
│   └── debug_run.png             # Screenshot of debug script
├── pyproject.toml
└── README.md

📩 Plugin Registration

This plugin is exposed to MLflow via entry points:

[tool.poetry.plugins."mlflow.run_context_provider"]
sysmetrics = "mlflow_sysmetrics:SysMetricsRunContextProvider"

🤝 Contributing

Pull requests, bug reports, and suggestions are welcome!

  1. Fork the repo
  2. Create a virtual environment: poetry install
  3. Write or update tests
  4. Run tests with poetry run pytest
  5. Submit your PR 🚀

📄 License

Apache License 2.0. See LICENSE for full terms.


💬 Questions?

Feel free to open an issue or reach out via GitHub Discussions.

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

mlflow_sysmetrics-0.1.2.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mlflow_sysmetrics-0.1.2-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file mlflow_sysmetrics-0.1.2.tar.gz.

File metadata

  • Download URL: mlflow_sysmetrics-0.1.2.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.10 Linux/6.11.0-1014-azure

File hashes

Hashes for mlflow_sysmetrics-0.1.2.tar.gz
Algorithm Hash digest
SHA256 aca6053236a6c16781fee437eb8ca2fc6134cf5883f9c3e607565de96ab11265
MD5 507e31f2d7747e394deca057c297c974
BLAKE2b-256 8792ca99ec642abbaf76ac503b2d2dca0f6f71f7057a8af86c72af21fefb776d

See more details on using hashes here.

File details

Details for the file mlflow_sysmetrics-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: mlflow_sysmetrics-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.10 Linux/6.11.0-1014-azure

File hashes

Hashes for mlflow_sysmetrics-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1c781e3e6fa96f0f42247ebfeda8499c391e9f62bba5bcc66a124407e05b106e
MD5 a919f9cb646302ea77c33c634d314bb9
BLAKE2b-256 84839464a9c9dca349af5c385a82e859451c5e7a859ac215bbac3781f1a76035

See more details on using hashes here.

Supported by

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