Smart dependency analysis and minimal requirements generation for MLflow models
Project description
MLflow Dependency Analyzer
Smart dependency analysis and minimal requirements generation for MLflow models.
Automatically detect and generate minimal code_paths and requirements lists for your MLflow models using AST-based analysis, ensuring portable and reproducible model deployments without dependency bloat.
Installation
pip install mlflow-dep-analyzer
Quick Start
Log an MLflow model with minimal dependencies:
import mlflow
import mlflow.sklearn
from mlflow_dep_analyzer import analyze_code_dependencies, analyze_code_paths
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import make_classification
# Train your model
X, y = make_classification(n_samples=100, n_features=4, random_state=42)
model = RandomForestClassifier(random_state=42)
model.fit(X, y)
# Find minimal requirements
requirements = analyze_code_dependencies(
code_paths=["my_model.py"],
repo_root="."
)
# Find code dependencies
code_paths = analyze_code_paths(
entry_files=["my_model.py"],
repo_root="."
)
# Log model with minimal dependencies
with mlflow.start_run():
mlflow.sklearn.log_model(
model,
"random_forest",
code_paths=code_paths,
pip_requirements=requirements
)
Development
This repo uses uv for environment management. For the simplest setup, make sure it is installed.
Note: This repo was developed with python 3.11.11 to match Databricks Runtime 15.4 LTS, though it should be functioning on other versions. You may need to adjust the dev dependency versions to get it functioning.
git clone https://github.com/andrewgross/mlflow-dep-analyzer
cd mlflow-dep-analyzer
make setup
make test
Project details
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_dep_analyzer-0.2.0.tar.gz.
File metadata
- Download URL: mlflow_dep_analyzer-0.2.0.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83393e83b1c103c66f303a5c46f8901883766b4d80bc3262fb9b037d6b1b840b
|
|
| MD5 |
10919204910752fb5e403e17992eb779
|
|
| BLAKE2b-256 |
41cedfd6a4f256d29d7f7534be92370fb7c4e21fac3598d8c4542ecebf91618b
|
File details
Details for the file mlflow_dep_analyzer-0.2.0-py3-none-any.whl.
File metadata
- Download URL: mlflow_dep_analyzer-0.2.0-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7693e77fad6e13a2b1c70386945552095e63b5502f53b89c79b73ec584ad8dd5
|
|
| MD5 |
bad1766b5e1147429a240777e21191ef
|
|
| BLAKE2b-256 |
07e90bd3dc8f13e3b15ebbaa178b56038b7345d7bb2bfa2dd2c0590ee9a74040
|