Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Mlflow Mlflow Build Packages

From Leeroopedia
Knowledge Sources
Domains Build System, Package Distribution
Last Updated 2026-02-13 20:00 GMT

Overview

Build script that produces MLflow Python distribution packages (wheel and sdist) for the four package variants: dev, release, skinny, and tracing.

Description

This script is the central build orchestrator for all MLflow distribution packages used in CI/CD and PyPI publishing. It defines four Package dataclass configurations:

  • DEV - The full development mlflow package built from the repository root
  • RELEASE - The release variant of mlflow, built with pyproject.release.toml swapped in for pyproject.toml
  • SKINNY - The lightweight mlflow-skinny package built from libs/skinny
  • TRACING - The mlflow-tracing package built from libs/tracing

The build process follows these steps:

  1. Git submodule initialization - Ensures submodules like mlflow/assistant/skills are up to date
  2. Artifact cleanup - Removes build/, dist/, and .egg_info directories from previous builds
  3. pyproject.toml swap - For release builds, temporarily replaces the development pyproject.toml with pyproject.release.toml
  4. Package build - Invokes python -m build on the selected package path
  5. Distribution consolidation - For skinny and tracing packages, moves artifacts from their subdirectory dist/ to the top-level dist/
  6. SHA tagging (optional) - Appends a git SHA as a build tag to the wheel filename (format: 0.sha.<commit-sha>)

The restore_changes context manager ensures that README.md and pyproject.toml are always restored to their original state via git restore after the build, even if an error occurs.

Usage

Run this script from the repository root during CI/CD or local development to build MLflow packages. Use the --package-type argument to select which variant to build, and optionally --sha to include a git commit hash in the wheel filename for traceability.

Code Reference

Source Location

Signature

@dataclass(frozen=True)
class Package:
    pypi_name: str
    type: str
    build_path: str

def parse_args() -> argparse.Namespace: ...

@contextlib.contextmanager
def restore_changes() -> Generator[None, None, None]: ...

def main() -> None: ...

Import

# Run directly as a script
python dev/build.py --package-type dev
python dev/build.py --package-type release --sha abc123

I/O Contract

Inputs

Name Type Required Description
--package-type str No Package variant to build: "dev" (default), "release", "skinny", or "tracing"
--sha str No Git commit SHA to include as a build tag in the wheel filename

Outputs

Name Type Description
dist/*.whl File Built wheel distribution for the selected package
dist/*.tar.gz File Built source distribution (sdist) for the selected package

Usage Examples

Building the Development Package

# Build the default dev package
# python dev/build.py

# Build the release package with SHA tag
# python dev/build.py --package-type release --sha $(git rev-parse --short HEAD)

# Build the skinny package
# python dev/build.py --package-type skinny

Package Definitions

DEV = Package("mlflow", "dev", ".")
RELEASE = Package("mlflow", "release", ".")
SKINNY = Package("mlflow-skinny", "skinny", "libs/skinny")
TRACING = Package("mlflow-tracing", "tracing", "libs/tracing")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment