Skip to main content

Linter for Machine Learning projects

Project description

mllint — Linter for Machine Learning projects

GitHub Workflow Status GitHub go.mod Go version Code coverage Platform

PyPI PyPI - Status PyPI - Downloads - Daily PyPI - Downloads - Monthly PyPI - Python Version

mllint is a command-line utility to evaluate the technical quality of Machine Learning (ML) and Artificial Intelligence (AI) projects written in Python by analysing the project's source code, data and configuration of supporting tools. mllint aims to ...

  • ... help data scientists and ML engineers in creating and maintaining production-grade ML and AI projects, both on their own personal computers as well as on CI.
  • ... help ML practitioners inexperienced with Software Engineering (SE) techniques explore and make effective use of battle-hardended SE for ML tools in the Python ecosystem.
  • ... help ML project managers assess the quality of their ML and AI projects and receive recommendations on what aspects of their projects they should focus on improving.

mllint does this by measuring the project's adherence to ML best practices, as collected and deduced from SE4ML and Google's Rules for ML. Note that these best practices are rather high-level, while mllint aims to give practical, down-to-earth advice to its users. mllint may therefore be somewhat opinionated, as it tries to advocate specific tools to best fit these best practices. However, mllint aims to only recommend open-source tooling and publically verifiable practices. Feedback is of course always welcome!

mllint is created during my MSc thesis in Computer Science at the Software Engineering Research Group (SERG) at TU Delft and ING's AI for FinTech Research Lab on the topic of Code Quality and Software Engineering for Machine Learning projects

See docs/example-report.md to view the report generated for this example project.


Installation

mllint is compiled for Linux, MacOS and Windows, both 64 and 32 bit x86 (MacOS 64-bit only), as well as 64-bit ARM on Linux and MacOS (Apple M1).

mllint is published to PyPI, so it can be installed globally or in your current environment using pip:

pip install mllint

Alternatively, to add mllint to an existing project, if your project uses Poetry for its dependencies:

poetry add --dev mllint

Or if your project uses Pipenv:

pipenv install --dev mllint

Usage

mllint is designed to be used both on your personal computer as well as on CI systems. So, open a terminal in your project folder and run one of the following commands, or add it to your project's CI script.

To run mllint on the project in the current folder, simply run:

mllint

To run mllint on a project in another folder, simply run:

mllint path/to/my-ml-project

mllint will analyse your project and create a Markdown-formatted report of its analysis. By default, this will be pretty printed to your terminal.

If you instead prefer to export the raw Markdown text to a file, which may be particularly useful when running on CI, the --output or -o flag and provide a filename. mllint does not overwrite the destination file if it already exists, unless --force or -f is used. For example:

mllint --output report.md

Using - (a dash) as the filename prints the raw Markdown directly to your terminal:

mllint -o -

In CI scripts, such raw markdown output (whether as a file or printed to the standard output) can be used to e.g. make comments on pull/merge requests or create Wiki pages on your repository.

See docs/example-report.md for an example of a report that mllint generates.

Of course, feel free to explore mllint help for more information about its commands and to discover additional flags that can be used.

Linters, Categories and Rules

mllint analyses your project by evaluating several categories of linting rules. Each category, as well as each rule, has a 'slug', i.e., a lowercased piece of text with dashes or slashes for spaces, e.g., code-quality/pylint/no-issues. This slug identifies a rule and is often (if not always) displayed next to the category or rule that it references.

To list all available (implemented) categories and linting rules, run:

mllint list all

To list all enabled linting rules, run (optionally providing the path to the project's folder):

mllint list enabled

By default, all of mllint's rules are enabled. See Configuration to learn how to selectively disable certain rules.

To learn more about a certain rule or category, use mllint describe along with the slug of the category or rule:

# Describe the Version Control category. This will also list the rules that it checks.
mllint describe version-control

# Describe the rule on DVC usage in the Version Control category
mllint describe version-control/data/dvc

Configuration

mllint can be configured either using a .mllint.yml file or through the project's pyproject.toml. This allows you to selectively disable specific linting rules or categories by means of their slug, as well as configure specific settings for various linting rules. See below for examples of such configuration files.

To print mllint's current configuration in YAML format, run (optionally providing the path to the project's folder):

mllint config

To print mllint's default configuration in YAML format, run (unless there is a folder called default in the current directory):

mllint config default

To create a .mllint.yml file from mllint's default configuration, run:

mllint config default -q > .mllint.yml

YAML

An example .mllint.yml that disables some rules looks as follows:

rules:
  disabled:
    - version-control/code/git
    - dependency-management/single

TOML

If no .mllint.yml is found, mllint searches the project's pyproject.toml for a [tool.mllint] section. TOML has a slightly different syntax, but the structure is otherwise the same as the config in the YAML file.

An example pyproject.toml configuration of mllint is as follows. Note that it is identical to the YAML example above.

[tool.mllint]
[tool.mllint.rules]
disabled = ["version-control/code/git", "dependency-management/single"]

Getting Started (development)

While mllint is a tool for the Python ML ecosystem and distributed through PyPI, it is actually written in Go, compiled to a static binary and published as platform-specific Python wheels.

To run mllint from source, install the latest version of Go for your operating system, then clone this repository and run go run . in the root of this repository. Use go test ./... or execute test.sh to run all of mllint's tests.

To test compiling and packaging mllint into a Python wheel for your current platform, run test.package.sh.

Download files

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

Source Distribution

mllint-0.8.3.tar.gz (6.6 MB view hashes)

Uploaded Source

Built Distributions

mllint-0.8.3-pp37-pypy37_pp73-win32.whl (6.8 MB view hashes)

Uploaded PyPy Windows x86

mllint-0.8.3-pp37-pypy37_pp73-manylinux2010_x86_64.whl (6.7 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ x86-64

mllint-0.8.3-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (6.8 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

mllint-0.8.3-pp36-pypy36_pp73-win32.whl (6.8 MB view hashes)

Uploaded PyPy Windows x86

mllint-0.8.3-pp36-pypy36_pp73-manylinux2010_x86_64.whl (6.7 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ x86-64

mllint-0.8.3-pp36-pypy36_pp73-macosx_10_9_x86_64.whl (6.8 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

mllint-0.8.3-cp39-cp39-win_amd64.whl (6.8 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

mllint-0.8.3-cp39-cp39-win32.whl (6.8 MB view hashes)

Uploaded CPython 3.9 Windows x86

mllint-0.8.3-cp39-cp39-manylinux2010_x86_64.whl (6.7 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

mllint-0.8.3-cp39-cp39-manylinux2010_i686.whl (6.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ i686

mllint-0.8.3-cp39-cp39-manylinux1_x86_64.whl (6.7 MB view hashes)

Uploaded CPython 3.9

mllint-0.8.3-cp39-cp39-manylinux1_i686.whl (6.2 MB view hashes)

Uploaded CPython 3.9

mllint-0.8.3-cp39-cp39-macosx_11_0_arm64.whl (6.8 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

mllint-0.8.3-cp39-cp39-macosx_10_9_x86_64.whl (6.8 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

mllint-0.8.3-cp38-cp38-win_amd64.whl (6.8 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

mllint-0.8.3-cp38-cp38-win32.whl (6.8 MB view hashes)

Uploaded CPython 3.8 Windows x86

mllint-0.8.3-cp38-cp38-manylinux2010_x86_64.whl (6.7 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

mllint-0.8.3-cp38-cp38-manylinux2010_i686.whl (6.2 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

mllint-0.8.3-cp38-cp38-manylinux1_x86_64.whl (6.7 MB view hashes)

Uploaded CPython 3.8

mllint-0.8.3-cp38-cp38-manylinux1_i686.whl (6.2 MB view hashes)

Uploaded CPython 3.8

mllint-0.8.3-cp38-cp38-macosx_10_9_x86_64.whl (6.8 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

mllint-0.8.3-cp37-cp37m-win_amd64.whl (6.8 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

mllint-0.8.3-cp37-cp37m-win32.whl (6.8 MB view hashes)

Uploaded CPython 3.7m Windows x86

mllint-0.8.3-cp37-cp37m-manylinux2010_x86_64.whl (6.7 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

mllint-0.8.3-cp37-cp37m-manylinux2010_i686.whl (6.2 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

mllint-0.8.3-cp37-cp37m-manylinux1_x86_64.whl (6.7 MB view hashes)

Uploaded CPython 3.7m

mllint-0.8.3-cp37-cp37m-manylinux1_i686.whl (6.2 MB view hashes)

Uploaded CPython 3.7m

mllint-0.8.3-cp37-cp37m-macosx_10_9_x86_64.whl (6.8 MB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

mllint-0.8.3-cp36-cp36m-win_amd64.whl (6.8 MB view hashes)

Uploaded CPython 3.6m Windows x86-64

mllint-0.8.3-cp36-cp36m-win32.whl (6.8 MB view hashes)

Uploaded CPython 3.6m Windows x86

mllint-0.8.3-cp36-cp36m-manylinux2010_x86_64.whl (6.7 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

mllint-0.8.3-cp36-cp36m-manylinux2010_i686.whl (6.2 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ i686

mllint-0.8.3-cp36-cp36m-manylinux1_x86_64.whl (6.7 MB view hashes)

Uploaded CPython 3.6m

mllint-0.8.3-cp36-cp36m-manylinux1_i686.whl (6.2 MB view hashes)

Uploaded CPython 3.6m

mllint-0.8.3-cp36-cp36m-macosx_10_9_x86_64.whl (6.8 MB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

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