• This repository has been archived on 13/Sep/2023
  • Stars
    star
    713
  • Rank 61,185 (Top 2 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 2 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿถ A tool to package, serve, and deploy any ML model on any platform. Archived to be resurrected one day๐Ÿคž

image

Check, test and release codecov PyPi License: Apache 2.0

MLEM helps you package and deploy machine learning models. It saves ML models in a standard format that can be used in a variety of production scenarios such as real-time REST serving or batch processing.

  • Run your ML models anywhere: Wrap models as a Python package or Docker Image, or deploy them to Heroku, SageMaker or Kubernetes (more platforms coming soon). Switch between platforms transparently, with a single command.

  • Model metadata into YAML automatically: Automatically include Python requirements and input data needs into a human-readable, deployment-ready format. Use the same metafile on any ML framework.

  • Stick to your training workflow: MLEM doesn't ask you to rewrite model training code. Add just two lines around your Python code: one to import the library and one to save the model.

  • Developer-first experience: Use the CLI when you feel like DevOps, or the API if you feel like a developer.

Why is MLEM special?

The main reason to use MLEM instead of other tools is to adopt a GitOps approach to manage model lifecycles.

  • Git as a single source of truth: MLEM writes model metadata to a plain text file that can be versioned in Git along with code. This enables GitFlow and other software engineering best practices.

  • Unify model and software deployment: Release models using the same processes used for software updates (branching, pull requests, etc.).

  • Reuse existing Git infrastructure: Use familiar hosting like Github or Gitlab for model management, instead of having separate services.

  • UNIX philosophy: MLEM is a modular tool that solves one problem very well. It integrates well into a larger toolset from Iterative.ai, such as DVC and CML.

Usage

This a quick walkthrough showcasing deployment functionality of MLEM.

Please read Get Started guide for a full version.

Installation

MLEM requires Python 3.

$ python -m pip install mlem

To install the pre-release version:

$ python -m pip install git+https://github.com/iterative/mlem

Saving the model

# train.py
from mlem.api import save
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import load_iris

def main():
    data, y = load_iris(return_X_y=True, as_frame=True)
    rf = RandomForestClassifier(
        n_jobs=2,
        random_state=42,
    )
    rf.fit(data, y)

    save(
        rf,
        "models/rf",
        sample_data=data,
    )

if __name__ == "__main__":
    main()

Codification

Check out what we have:

$ ls models/
rf
rf.mlem
$ cat rf.mlem
Click to show `cat` output
artifacts:
  data:
    hash: ea4f1bf769414fdacc2075ef9de73be5
    size: 163651
    uri: rf
model_type:
  methods:
    predict:
      args:
      - name: data
        type_:
          columns:
          - sepal length (cm)
          - sepal width (cm)
          - petal length (cm)
          - petal width (cm)
          dtypes:
          - float64
          - float64
          - float64
          - float64
          index_cols: []
          type: dataframe
      name: predict
      returns:
        dtype: int64
        shape:
        - null
        type: ndarray
    predict_proba:
      args:
      - name: data
        type_:
          columns:
          - sepal length (cm)
          - sepal width (cm)
          - petal length (cm)
          - petal width (cm)
          dtypes:
          - float64
          - float64
          - float64
          - float64
          index_cols: []
          type: dataframe
      name: predict_proba
      returns:
        dtype: float64
        shape:
        - null
        - 3
        type: ndarray
  type: sklearn
object_type: model
requirements:
- module: sklearn
  version: 1.0.2
- module: pandas
  version: 1.4.1
- module: numpy
  version: 1.22.3

Deploying the model

If you want to follow this Quick Start, you'll need to sign up on https://heroku.com, create an API_KEY and populate HEROKU_API_KEY env var (or run heroku login in command line). Besides, you'll need to run heroku container:login. This will log you in to Heroku container registry.

Now we can deploy the model with mlem deploy (you need to use different app_name, since it's going to be published on https://herokuapp.com):

$ mlem deployment run heroku app.mlem \
  --model models/rf \
  --app_name example-mlem-get-started-app
โณ๏ธ Loading model from models/rf.mlem
โณ๏ธ Loading deployment from app.mlem
๐Ÿ›  Creating docker image for heroku
  ๐Ÿ›  Building MLEM wheel file...
  ๐Ÿ’ผ Adding model files...
  ๐Ÿ›  Generating dockerfile...
  ๐Ÿ’ผ Adding sources...
  ๐Ÿ’ผ Generating requirements file...
  ๐Ÿ›  Building docker image registry.heroku.com/example-mlem-get-started-app/web...
  โœ…  Built docker image registry.heroku.com/example-mlem-get-started-app/web
  ๐Ÿ”ผ Pushing image registry.heroku.com/example-mlem-get-started-app/web to registry.heroku.com
  โœ…  Pushed image registry.heroku.com/example-mlem-get-started-app/web to registry.heroku.com
๐Ÿ›  Releasing app example-mlem-get-started-app formation
โœ…  Service example-mlem-get-started-app is up. You can check it out at https://example-mlem-get-started-app.herokuapp.com/

Contributing

Contributions are welcome! Please see our Contributing Guide for more details.

Thanks to all our contributors!

Copyright

This project is distributed under the Apache license version 2.0 (see the LICENSE file in the project root).

By submitting a pull request to this project, you agree to license your contribution under the Apache license version 2.0 to this project.

More Repositories

1

dvc

๐Ÿฆ‰ ML Experiments and Data Management with Git
Python
13,036
star
2

cml

โ™พ๏ธ CML - Continuous Machine Learning | CI/CD for ML
JavaScript
3,907
star
3

PyDrive2

Google Drive API Python wrapper library. Maintained fork of PyDrive.
Python
516
star
4

shtab

โ†”๏ธ Automagic shell tab completion for Python CLI applications
Python
328
star
5

dvc.org

๐Ÿ“– DVC website and documentation
TypeScript
320
star
6

terraform-provider-iterative

โ˜๏ธ Terraform plugin for machine learning workloads: spot instance recovery & auto-termination | AWS, GCP, Azure, Kubernetes
Go
287
star
7

vscode-dvc

Machine learning experiment tracking and data versioning with DVC extension for VS Code
TypeScript
176
star
8

example-get-started

Get started DVC project
Python
167
star
9

dvclive

๐Ÿ“ˆ Log and track ML metrics, parameters, models with Git and/or DVC
Python
150
star
10

gto

๐Ÿท๏ธ Git Tag Ops. Turn your Git repository into Artifact Registry or Model Registry.
Python
134
star
11

awesome-iterative-projects

A list of projects relying on Iterative.AI tools to achieve awesomeness
63
star
12

dataset-registry

Dataset registry DVC project
60
star
13

magnetic-tiles-defect

Demo Computer Vision Project
Jupyter Notebook
55
star
14

course-ds-base

Jupyter Notebook
39
star
15

example-get-started-experiments

Get started DVC project
Python
39
star
16

demo-bank-customer-churn

Demo DVC project training a classification model on tabular data
Jupyter Notebook
38
star
17

aita_dataset

AITA dataset based on r/AmItheAsshole/
Python
32
star
18

setup-dvc

DVC GitHub action
JavaScript
29
star
19

example_cml

Python
28
star
20

workshop-uncool-mlops

Accompanies the uncool MLOps workshop
Python
26
star
21

ldb-resources

Python
26
star
22

mlem.ai

โœจ Landing page for MLEM
TypeScript
26
star
23

setup-cml

GitHub Action for CML setup
TypeScript
21
star
24

cml_base_case

Python
21
star
25

example-repos-dev

Source code and generator scripts for example DVC projects
Python
21
star
26

cml_cloud_case

Python
20
star
27

dvc-bench

Benchmarks for DVC
Python
20
star
28

scmrepo

SCM wrapper and fsspec filesystem for Git for use in DVC.
Python
19
star
29

cml_dvc_case

Python
18
star
30

intellij-dvc

DVC integration plugin for Intellij IDEs including PyCharm, IntelliJ IDEA and CLion
Java
17
star
31

dvc-data

DVC's data management subsystem
Python
17
star
32

studio-support

โ“ DVC Studio Issues, Question, and Discussions
15
star
33

studio-selfhosted

This repository contains auxiliary installation code for self-hosting Studio
Shell
15
star
34

VSCode-DVC-Workshop

Workshop about DVC VSCode Extension
Jupyter Notebook
14
star
35

example-dvc-experiments

DVC Get Started Project with a focus on `dvc experiment` features.
HTML
13
star
36

pytest-servers

Create temporary directories on the various filesystems for testing
Python
12
star
37

py-template

Hypermodern Python Cookiecutter
Python
12
star
38

cml.dev

๐Ÿ”— CML website and documentation
TypeScript
12
star
39

dvc-objects

dvc objects - contains filesystem and object-db level abstractions to use in dvc and dvc-data
Python
10
star
40

dvcyaml-schema

Schema for dvc.yaml
Python
10
star
41

example-versioning

Data sets and ML models versioning example from DVC get started
Python
9
star
42

dvc-streamlit-components

Streamlit components for DVC
Python
9
star
43

blog

๐Ÿ“– DVC blog engine
TypeScript
8
star
44

cml_tensorboard_case

Python
8
star
45

priority-list

โ›๏ธ Make a dent in GitHub issue & PR backlogs across repositories
Python
7
star
46

dvc-task

Celery task queue used in DVC
Python
7
star
47

tpi

Python wrapper for terraform-provider-iterative
Python
7
star
48

example-gto

Get Started GTO Project
7
star
49

example-pokemon-classifier

Example project with a CNN to train a Pokรฉmon type classifier.
Python
7
star
50

dvc-render

Library for rendering DVC plots
Python
6
star
51

example-mlem-get-started

Get Started MLEM project
Python
6
star
52

dvc-studio-client

Client to interact with DVC Studio
Python
6
star
53

workshop-uncool-mlops-solution

Python
6
star
54

pytest-test-utils

Python
6
star
55

features

A collection of development container 'features' for machine learning and data science
Shell
6
star
56

dvc-s3

AWS S3 plugin for dvc
Python
6
star
57

gatsby-theme-iterative

A Gatsby theme for shared logic between all the websites from iterative.ai
JavaScript
6
star
58

stale-model-example

This is the repo for the Preventing Stale Models in Production blog post.
Jupyter Notebook
6
star
59

gto-action

โš™๏ธ GTO Github Action
Shell
6
star
60

morefs

A collection of self-contained fsspec-based filesystems
Python
6
star
61

llm-demo

Demo of using DVC with LangChain
Python
6
star
62

course-checkpoints-project

This is the project we use for the DVC educational course to demonstrate how checkpoints work.
HTML
6
star
63

dvc-checkpoints-mnist

Example of checkpoints in a DVC project training a simple convolutional neural net to classify MNIST data
Python
5
star
64

dvc-s3-repo

Maintain deb and rpm repositories on s3
Python
5
star
65

enhancement-proposals

5
star
66

evidently-dvc

Tutorial: Automate Data Validation and Model Monitoring Pipelines with DVC and Evidently
HTML
5
star
67

dvc-gs

Google Storage plugin for dvc
Python
4
star
68

link-check

A Node-based tool to verify if links are alive. Built to be used anywhere!
TypeScript
4
star
69

dvc-snap

dvc snap package
Shell
4
star
70

cml-runner-base-case

Python
4
star
71

pretrained-model-demo

Python
4
star
72

homebrew-dvc

Automatic updates for dvc homebrew package
Shell
4
star
73

sqltrie

SQL-based prefix tree implementation inspired by pygtrie and python-diskcache
Python
3
star
74

vscode-dvc-demo

Python
3
star
75

example_model_export_cml

Example on how to use CML to provision an AWS EC2 runner, train a model, and export the resulting model.
Python
3
star
76

cnn_tutorial

CNN tutorial for DVC
Python
3
star
77

cml-playground

Shell
3
star
78

dvc-learn-project

This is the project used in the DVC Learn Meetups and videos.
HTML
3
star
79

telemetry-python

Common library to send usage telemetry
Python
3
star
80

checkpoints-tutorial

This is the code used in the checkpoints tutorial.
Python
3
star
81

ldb

Python
3
star
82

chocolatey-dvc

Chocolatey package for dvc
PowerShell
3
star
83

blog-tpi-jupyter

Terraform Provider Iterative + Jupyter + TensorBoard + AWS/Azure/GCP/K8s
Jupyter Notebook
3
star
84

example-get-started-ssh-private-fixture

Frozen copy of the Get Started DVC project. Used in Studio tests to test SSH remote credentials.
Python
2
star
85

link-check.action

A GitHub Action driver for link-check, deployed via submodules.
JavaScript
2
star
86

dvc-gdrive

Google Drive plugin for DVC
Python
2
star
87

example-get-started-s3

Example get started (metrics and plots in S3)
Python
2
star
88

example-mlem

Example of using MLEM with DVC Pipeline
Python
2
star
89

katacoda-scenarios

Interactive Katacoda Scenarios
Shell
2
star
90

dvc-exe

Private repository for building and signing dvc for windows
Inno Setup
2
star
91

dvc-azure

Azure plugin for dvc
Python
2
star
92

dvc_action_example

Python
2
star
93

dvc-oss

Alibaba OSS plugin for dvc
Python
2
star
94

sagemaker-pipeline

An example project, showcasing a DVC pipeline using SageMaker SDK for data preparation and model training
Python
2
star
95

dvc-test

Integration tests for dvc
Python
2
star
96

vscode-dvc-pack

2
star
97

get-started-pipelines

DVC Get Started project with a focus on creating pipelines with `dvc stage`
Python
2
star
98

cookiecutter-dvc-plugin

A Cookiecutter template for dvc plugins
Python
2
star
99

testing-ldb

Aug 10th Hackathon
Python
2
star
100

gha-required-workflows

Repository containing Iterative Required workflows for GitHub Actions
1
star