Skip to main content

lit-mlflow

Build Documentation PyPI - Package Version PyPI - Python Version Docs with MkDocs uv linting: ruff ty prek security: bandit Semantic Versions Copier SPEC 0 — Minimum Supported Dependencies License

An improved Lightning mlflow logger. Works seamlessly with PyTorch Lightning on Databricks and offers more control compared to the mlflow.pytorch.autolog function.

Features

  • Makes MLflow logging work with lightning and Databricks

Installation

With pip:

python -m pip install lit-mlflow

With uv:

uv add lit-mlflow

How to use it

Replace mlflow.autolog() with the MlFlowAutoCallback:

from lit_mlflow import MlFlowAutoCallback
import lightning.pytorch as pl

trainer = pl.Trainer(callbacks=[MlFlowAutoCallback()])

Models are saved with pickle by default. To export a model in MLflow's pickle-free pt2 format:

callback = MlFlowAutoCallback(serialization_format="pt2")

The callback captures the first training batch's first element as the model input (or the batch itself if it is a tensor). For other batch layouts or multiple positional inputs, select the inputs explicitly:

callback = MlFlowAutoCallback(
    serialization_format="pt2",
    input_example_fn=lambda batch: (batch["features"], batch["mask"]),
)

Inputs must be tensors, and the model's forward method must support torch.export. MLflow's pt2 format is distinct from TorchScript; export failures are not silently converted to pickle. PT2 export requires PyTorch 2.4 or newer and uses the captured shapes, with a dynamic batch dimension where supported.

For a single CPU input, MLflow includes the captured input example in the model artifacts. Multiple inputs and non-CPU inputs are used for export but do not produce an input example artifact or an MLflow PyFunc flavor.

To support Databricks mlflow, use the DbxMLFlowLogger instead of the MlFlowLogger:

from lit_mlflow import DbxMLFlowLogger
import lightning.pytorch as pl

trainer = pl.Trainer(logger=[DbxMLFlowLogger()])

Docs

uv run mkdocs build -f ./mkdocs.yml -d ./_build/

Run the example on Databricks

The Databricks Asset Bundle provides a serverless job (example) and a job-cluster job (example_cluster) for notebooks/example.ipynb. After configuring Databricks CLI authentication, validate and deploy the bundle, then run either job:

databricks bundle validate
databricks bundle deploy
databricks bundle run example
databricks bundle run example_cluster

The cluster job defaults to Azure Standard_D4ds_v5. For AWS, set cluster_node_type_id in databricks.yml to i3.xlarge. Ensure the VM type is available in your cloud and region.

Update template

copier update --trust -A --vcs-ref=HEAD

Credits

This project was generated with 🚀 python project template.

Metadata

Release files for lit-mlflow 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lit-mlflow 0.2.1
File Size Uploaded Provenance Actions
lit_mlflow-0.2.1.tar.gz 17.3 kB Without provenance Details for lit_mlflow-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lit-mlflow 0.2.1
File Interpreter ABI Platform Actions
lit_mlflow-0.2.1-py3-none-any.whl Python 3 none any Details for lit_mlflow-0.2.1-py3-none-any.whl

Total release size: 33.7 kB

Release files / lit_mlflow-0.2.1.tar.gz

Download URL lit_mlflow-0.2.1.tar.gz
Size 17.3 kB
Tags Source
SHA-256 checksum
How to use checksums
786ed55340569afca33ea0a444b2187f98b354eda45dd2eb6dd93df6c92db45e
BLAKE2b-256 checksum
How to use checksums
c8a116013d6a78750703401c16f105d1f87adafd311c661a98643e021f3db8e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / lit_mlflow-0.2.1-py3-none-any.whl

Download URL lit_mlflow-0.2.1-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b918a1aa6c8d83f72c708caf7e9051ccde1c4db7affc5f6e0fbf32a819cd295f
BLAKE2b-256 checksum
How to use checksums
45222ea156dd0da0924fd4162f054ee69963123841c0d1bb5109be08e5533bd0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for lit-mlflow 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page