{"id":13473522,"url":"https://github.com/iterative/mlem","last_synced_at":"2025-03-26T19:34:14.678Z","repository":{"id":37407301,"uuid":"411977306","full_name":"iterative/mlem","owner":"iterative","description":"🐶 A tool to package, serve, and deploy any ML model on any platform. Archived to be resurrected one day🤞","archived":true,"fork":false,"pushed_at":"2023-09-13T18:27:00.000Z","size":1365,"stargazers_count":719,"open_issues_count":131,"forks_count":43,"subscribers_count":24,"default_branch":"main","last_synced_at":"2025-03-24T04:02:12.654Z","etag":null,"topics":["cli","data-science","deployment","developer-tools","git","machine-learning","mlem","model-registry","python"],"latest_commit_sha":null,"homepage":"https://mlem.ai","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iterative.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-09-30T08:07:34.000Z","updated_at":"2025-03-17T23:27:46.000Z","dependencies_parsed_at":"2024-01-03T02:30:27.069Z","dependency_job_id":"67aa80d2-03f6-4e8b-bce7-83b238e9e673","html_url":"https://github.com/iterative/mlem","commit_stats":null,"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iterative%2Fmlem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iterative%2Fmlem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iterative%2Fmlem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iterative%2Fmlem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iterative","download_url":"https://codeload.github.com/iterative/mlem/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245722838,"owners_count":20661833,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","data-science","deployment","developer-tools","git","machine-learning","mlem","model-registry","python"],"created_at":"2024-07-31T16:01:04.396Z","updated_at":"2025-03-26T19:34:14.079Z","avatar_url":"https://github.com/iterative.png","language":"Python","readme":"![image](https://user-images.githubusercontent.com/6797716/165590476-994d4d93-8e98-4afb-b5f8-6f42b9d56efc.png)\n\n\n[![Check, test and release](https://github.com/iterative/mlem/actions/workflows/check-test-release.yml/badge.svg)](https://github.com/iterative/mlem/actions/workflows/check-test-release.yml)\n[![codecov](https://codecov.io/gh/iterative/mlem/branch/main/graph/badge.svg?token=WHU4OAB6O2)](https://codecov.io/gh/iterative/mlem)\n[![PyPi](https://img.shields.io/pypi/v/mlem.svg?label=pip\u0026logo=PyPI\u0026logoColor=white)](https://pypi.org/project/mlem)\n[![License: Apache 2.0](https://img.shields.io/github/license/iterative/mlem)](https://github.com/iterative/mlem/blob/master/LICENSE)\n\u003c!-- [![Maintainability](https://codeclimate.com/github/iterative/mlem/badges/gpa.svg)](https://codeclimate.com/github/iterative/mlem) --\u003e\n\nMLEM helps you package and deploy machine learning models.\nIt 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.\n\n- **Run your ML models anywhere:**\n  Wrap models as a Python package or Docker Image, or deploy them to Heroku, SageMaker or Kubernetes (more platforms coming soon).\n  Switch between platforms transparently, with a single command.\n\n- **Model metadata into YAML automatically:**\n  Automatically include Python requirements and input data needs into a human-readable, deployment-ready format.\n  Use the same metafile on any ML framework.\n\n- **Stick to your training workflow:**\n  MLEM doesn't ask you to rewrite model training code.\n  Add just two lines around your Python code: one to import the library and one to save the model.\n\n- **Developer-first experience:**\n  Use the CLI when you feel like DevOps, or the API if you feel like a developer.\n\n## Why is MLEM special?\n\nThe main reason to use MLEM instead of other tools is to adopt a **GitOps approach** to manage model lifecycles.\n\n- **Git as a single source of truth:**\n  MLEM writes model metadata to a plain text file that can be versioned in Git along with code.\n  This enables GitFlow and other software engineering best practices.\n\n- **Unify model and software deployment:**\n  Release models using the same processes used for software updates (branching, pull requests, etc.).\n\n- **Reuse existing Git infrastructure:**\n  Use familiar hosting like Github or Gitlab for model management, instead of having separate services.\n\n- **UNIX philosophy:**\n  MLEM is a modular tool that solves one problem very well.\n  It integrates well into a larger toolset from Iterative.ai, such as [DVC](https://dvc.org/) and [CML](https://cml.dev/).\n\n## Usage\n\nThis a quick walkthrough showcasing deployment functionality of MLEM.\n\nPlease read [Get Started guide](https://mlem.ai/doc/get-started) for a full version.\n\n### Installation\n\nMLEM requires Python 3.\n\n```console\n$ python -m pip install mlem\n```\n\n\u003e To install the pre-release version:\n\u003e\n\u003e ```console\n\u003e $ python -m pip install git+https://github.com/iterative/mlem\n\u003e ```\n\n### Saving the model\n\n```python\n# train.py\nfrom mlem.api import save\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.datasets import load_iris\n\ndef main():\n    data, y = load_iris(return_X_y=True, as_frame=True)\n    rf = RandomForestClassifier(\n        n_jobs=2,\n        random_state=42,\n    )\n    rf.fit(data, y)\n\n    save(\n        rf,\n        \"models/rf\",\n        sample_data=data,\n    )\n\nif __name__ == \"__main__\":\n    main()\n```\n\n### Codification\n\nCheck out what we have:\n\n```shell\n$ ls models/\nrf\nrf.mlem\n$ cat rf.mlem\n```\n\u003cdetails\u003e\n  \u003csummary\u003e Click to show `cat` output\u003c/summary\u003e\n\n```yaml\nartifacts:\n  data:\n    hash: ea4f1bf769414fdacc2075ef9de73be5\n    size: 163651\n    uri: rf\nmodel_type:\n  methods:\n    predict:\n      args:\n      - name: data\n        type_:\n          columns:\n          - sepal length (cm)\n          - sepal width (cm)\n          - petal length (cm)\n          - petal width (cm)\n          dtypes:\n          - float64\n          - float64\n          - float64\n          - float64\n          index_cols: []\n          type: dataframe\n      name: predict\n      returns:\n        dtype: int64\n        shape:\n        - null\n        type: ndarray\n    predict_proba:\n      args:\n      - name: data\n        type_:\n          columns:\n          - sepal length (cm)\n          - sepal width (cm)\n          - petal length (cm)\n          - petal width (cm)\n          dtypes:\n          - float64\n          - float64\n          - float64\n          - float64\n          index_cols: []\n          type: dataframe\n      name: predict_proba\n      returns:\n        dtype: float64\n        shape:\n        - null\n        - 3\n        type: ndarray\n  type: sklearn\nobject_type: model\nrequirements:\n- module: sklearn\n  version: 1.0.2\n- module: pandas\n  version: 1.4.1\n- module: numpy\n  version: 1.22.3\n```\n\u003c/details\u003e\n\n### Deploying the model\n\nIf you want to follow this Quick Start, you'll need to sign up on https://heroku.com,\ncreate an API_KEY and populate `HEROKU_API_KEY` env var (or run `heroku login` in command line).\nBesides, you'll need to run `heroku container:login`. This will log you in to Heroku\ncontainer registry.\n\nNow we can [deploy the model with `mlem deploy`](https://mlem.ai/doc/get-started/deploying)\n(you need to use different `app_name`, since it's going to be published on https://herokuapp.com):\n\n```shell\n$ mlem deployment run heroku app.mlem \\\n  --model models/rf \\\n  --app_name example-mlem-get-started-app\n⏳️ Loading model from models/rf.mlem\n⏳️ Loading deployment from app.mlem\n🛠 Creating docker image for heroku\n  🛠 Building MLEM wheel file...\n  💼 Adding model files...\n  🛠 Generating dockerfile...\n  💼 Adding sources...\n  💼 Generating requirements file...\n  🛠 Building docker image registry.heroku.com/example-mlem-get-started-app/web...\n  ✅  Built docker image registry.heroku.com/example-mlem-get-started-app/web\n  🔼 Pushing image registry.heroku.com/example-mlem-get-started-app/web to registry.heroku.com\n  ✅  Pushed image registry.heroku.com/example-mlem-get-started-app/web to registry.heroku.com\n🛠 Releasing app example-mlem-get-started-app formation\n✅  Service example-mlem-get-started-app is up. You can check it out at https://example-mlem-get-started-app.herokuapp.com/\n```\n\n## Contributing\n\nContributions are welcome! Please see our [Contributing Guide](https://mlem.ai/doc/contributing/core)\nfor more details.\n\nThanks to all our contributors!\n\n## Copyright\n\nThis project is distributed under the Apache license version 2.0 (see the LICENSE file in the project root).\n\nBy submitting a pull request to this project, you agree to license your contribution under the Apache license version 2.0 to this project.\n","funding_links":[],"categories":["The Data Science Toolbox","Large Scale Deployment","Model Management","Python","Tools","Model Serving"],"sub_categories":["Miscellaneous Tools","Model Management","General-Purpose Machine Learning"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiterative%2Fmlem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiterative%2Fmlem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiterative%2Fmlem/lists"}