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 (Linux), system_profiler (macOS), or PowerShell (Windows) |
sysmetrics.error |
Captures any exception during tagging |
๐ก GPU detection is OS-aware:
- macOS: via
system_profiler - Linux: via
nvidia-smi - Windows: via PowerShell (
Get-CimInstance Win32_VideoController)
๐ 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:
๐ Project Structure
mlflow-sysmetrics/
โโโ src/mlflow_sysmetrics/
โ โโโ __init__.py
โ โโโ system_context.py # Plugin implementation
โ โโโ utils/
โ โโโ __init__.py
โ โโโ constants.py # Constants
โ โโโ mac.py # macOS-specific logic
โ โโโ windows.py # Windows-specific GPU logic
โโโ tests/
โ โโโ unit/
โ โ โโโ test_sysmetrics_context.py # Core plugin logic
โ โ โโโ test_mac_utils.py # macOS GPU tests
โ โ โโโ test_windows_utils.py # Windows GPU 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
โโโ LICENSE # Apache 2.0 License
โโโ CHANGELOG.md # Semantic changelog (Keep a Changelog format)
๐ฉ 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!
- Fork the repo
- Create a virtual environment:
poetry install - Write or update tests
- Run tests with
poetry run pytest - 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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mlflow_sysmetrics-0.1.3.tar.gz.
File metadata
- Download URL: mlflow_sysmetrics-0.1.3.tar.gz
- Upload date:
- Size: 9.7 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea12a7410f38319b6ab0c9c83a0f6bf155d61074209e639aa20ef5ce8822fb06
|
|
| MD5 |
d7b6bc454c6ff05ef2d17b106238822b
|
|
| BLAKE2b-256 |
2a4d4c0673234a5c45674de8a88c991c5c7b99c5610fc79d42b8b9ddbd8d4303
|
File details
Details for the file mlflow_sysmetrics-0.1.3-py3-none-any.whl.
File metadata
- Download URL: mlflow_sysmetrics-0.1.3-py3-none-any.whl
- Upload date:
- Size: 11.8 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20bbf86939a04bbc17e704f68cba6bedcaf19858a00597f3cd29306c5b9e1d15
|
|
| MD5 |
59405bc1f0f4f6617a427c22be875d0e
|
|
| BLAKE2b-256 |
3ed36b9723914145011d3932cf6755e725113adc0851649ec15894e6d3798c3e
|