Skip to main content

Extend MLflow's functionality

Project description

MLflow Extend

CI Documentation Status version pyversions Code style: black GitHub

Extend MLflow's functionality.


From PyPI

pip install mlflow-extend

From GitHub (development version)

pip install git+


import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from plotly import graph_objects as go

from mlflow_extend import mlflow

with mlflow.start_run():
    # mlflow native APIs
    mlflow.log_param('param', 0)
    mlflow.log_metric('metric', 1.0)

    ##### new APIs mlflow_extend provides #####

    # flatten dict
    mlflow.log_params_flatten({"a": {"b": 0}})
    mlflow.log_metrics_flatten({"a": {"b": 0.0}})

    # dict
    mlflow.log_dict({'a': 0}, 'dict.json')

    # numpy array
    mlflow.log_numpy(np.array([0]), 'array.npy')

    # pandas dataframe
    mlflow.log_df(pd.DataFrame({'a': [0]}), 'df.csv')

    # matplotlib figure
    fig, ax = plt.subplots()
    ax.plot([0, 1], [0, 1])
    mlflow.log_figure(fig, 'figure.png')

    # plotly figure
    fig = go.Figure(data=[go.Bar(x=[1, 2, 3], y=[1, 3, 2])])
    mlflow.log_figure(fig, 'figure.html')

    # confusion matrix
    mlflow.log_confusion_matrix([[1, 2], [3, 4]])

    # run "mlflow ui" and see the result.

Creating a Development Environment

conda create -n mlflow-extend python=3.6
conda activate mlflow-extend
pip install -r requirements.txt -r requirements-dev.txt

Formatting Code

Command Description Ref.
black . Format code Black
isort . Sort imports isort
flake8 . Check PEP8 flake8

After formatting, verify all the checks pass by running:


Running Type Check

mypy .

Running Unit Tests

# Run all the unit tests.

# Save figures generated during the unit tests in '.pytest_basetemp'.
./dev/ --savefig

Building Documentation

cd docs
make html

# Remove everything under 'docs/build' and run 'make html'.
make clean html

The generated files will be stored in docs/build/html. Open docs/build/html/index.html on the browser to check if the documentation is built properly.

Releasing New Version

  1. Make a pull request to update __version__ in mlflow-extend/ to the next version.
- __version__ = "1.2.2"  # current version
+ __version__ = "1.2.3"  # next version
  1. After the pull request is merged, create a new tag and push it to the remote.
git tag v1.2.3
git push origin v1.2.3
  1. Open the release page and publish a new release.

  2. Upload distribution archives to PyPI using twine.

# Remove old distribution archives.
rm -r dist/*

# Generate new distribution archives.
python sdist bdist_wheel

# Upload to Test PyPI and verify everything looks right.
twine upload --repository-url dist/*

twine upload dist/*

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for mlflow-extend, version 0.1.5
Filename, size File type Python version Upload date Hashes
Filename, size mlflow_extend-0.1.5-py3-none-any.whl (10.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size mlflow-extend-0.1.5.tar.gz (8.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page