# uMLaut
The uMLaut library simplifies data science model deployment and querying. It provides a single access point for all your models and an interface to interact with them. uMLaut models can be as extensive as deep learning models or as simple as a reusable code block.
### uMLaut offers
- simple commands to track and query models
- history of all model query inputs and results
- model lifecycle management
- access to multiple versions of the same model
- a user interface with `MLflow`
- model audit tracking history (roadmap)
- auto-deployed models that can be queried through an API (roadmap)
### Installing uMLaut
`pip install umlaut`
___
## MLflow Setup
[MLflow](https://bit.ly/3eHJsx3) is a powerful machine learning library created by Databricks for data science teams. It offers an extensive API for tracking and querying models, but the learning curve can be a deterrent for small teams without dedicated data scientists. uMLaut strips away much of the complexity of MLflow while maintaining the immense value of tracking and querying your models in a single location.
MLflow has two requirements:
1) A model artifact storage location
- This can be a local directory or a cloud storage URI. More info in the MLflow [docs](https://mlflow.org/docs/latest/tracking.html#artifact-stores).
2) A model registry
- The model registry is where model changes and query data are stored. More info in the MLflow [docs](https://mlflow.org/docs/latest/tracking.html#backend-stores).
An `mlflow server` must be running in order to work with uMLaut. The command to start an MLflow server with local artifact storage and a Postgres model registry is as follows:
`mlflow server --backend-store-uri postgresql+psycopg2://admin:password@localhost:5432/database --default-artifact-root "mlruns/"`
Once the server is running you can navigate to the MLflow UI and begin interacting with models.
____
## Core Functionality
uMLaut offers a simple Python class to assist with saving and querying business logic in MLflow.
- `track_model`: Converts a data science model or block of business logic into an MLflow compatible `model`
- `query_model`: Queries a previously trained `model` and saves audit metadata
- `audit_model (roadmap)`: Retrieve the results of a model run for a historic date
### Deploying models with Umlaut
Custom data science models or business logic can be deployed simply by running `umlaut.track_model()`. Ensure the model code block is in a Python `Class` and follow the example below.
```
class ExampleModel():
"""
Example business logic that can be wrapped into a model.
The class _must_ contain a 'predict' method.
"""
def business_logic(self, revenue: int) -> bool:
return revenue > 5
def predict(self, model_input: dict) -> bool:
return self.business_logic(revenue=model_input.get("revenue"))
if __name__ == "__main__":
"""Saves the model to MLflow in an experiment run"""
from umlaut import Umlaut
Umlaut.track_model(
model=ExampleModel(),
model_name="Quarterly Revenue",
run_name="Update",
)
```
This will push the latest changes of `ExampleModel()` to MLflow as a new model version. Navigate to the MLflow server where you can find details for the example "Quarterly Revenue" model.
### Querying models with Umlaut
Once a model is deployed in MLflow with `umlaut.track_model()`, it can be queried by calling `umlaut.query_model()`.
```
from umlaut import Umlaut
result = Umlaut.query_model(
model_name="Quarterly Revenue",
input_config={"revenue": 3},
stage="Staging",
)
print(f"Revenue will{'' if result else ' not'} exceed target")
```
If we query the simple `Quarterly Revenue` example model with `revenue = 3`, the model will return `False` as the revenue does not exceed the target of 5. The call to the model will be tracked in MLflow with model inputs and results.
Raw data
{
"_id": null,
"home_page": "https://github.com/andrewdunkel/uMLaut",
"name": "umlaut",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9.12,<4.0",
"maintainer_email": "",
"keywords": "mlops,mlflow,devops",
"author": "Andrew Dunkel",
"author_email": "andrew.dunkel1@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/e6/b8/591383e02d18b240e2d08da07932bfb9dc620b229dc93adf41c2ffe2e653/umlaut-0.2.2.tar.gz",
"platform": null,
"description": "# uMLaut\n\nThe uMLaut library simplifies data science model deployment and querying. It provides a single access point for all your models and an interface to interact with them. uMLaut models can be as extensive as deep learning models or as simple as a reusable code block.\n\n### uMLaut offers\n- simple commands to track and query models\n- history of all model query inputs and results\n- model lifecycle management\n- access to multiple versions of the same model\n- a user interface with `MLflow`\n- model audit tracking history (roadmap)\n- auto-deployed models that can be queried through an API (roadmap)\n\n### Installing uMLaut\n`pip install umlaut`\n___\n## MLflow Setup\n[MLflow](https://bit.ly/3eHJsx3) is a powerful machine learning library created by Databricks for data science teams. It offers an extensive API for tracking and querying models, but the learning curve can be a deterrent for small teams without dedicated data scientists. uMLaut strips away much of the complexity of MLflow while maintaining the immense value of tracking and querying your models in a single location. \n\nMLflow has two requirements:\n1) A model artifact storage location\n- This can be a local directory or a cloud storage URI. More info in the MLflow [docs](https://mlflow.org/docs/latest/tracking.html#artifact-stores).\n2) A model registry\n- The model registry is where model changes and query data are stored. More info in the MLflow [docs](https://mlflow.org/docs/latest/tracking.html#backend-stores).\n\nAn `mlflow server` must be running in order to work with uMLaut. The command to start an MLflow server with local artifact storage and a Postgres model registry is as follows:\n\n`mlflow server --backend-store-uri postgresql+psycopg2://admin:password@localhost:5432/database --default-artifact-root \"mlruns/\"`\n\nOnce the server is running you can navigate to the MLflow UI and begin interacting with models.\n\n____\n## Core Functionality\nuMLaut offers a simple Python class to assist with saving and querying business logic in MLflow.\n\n- `track_model`: Converts a data science model or block of business logic into an MLflow compatible `model`\n- `query_model`: Queries a previously trained `model` and saves audit metadata\n- `audit_model (roadmap)`: Retrieve the results of a model run for a historic date\n\n### Deploying models with Umlaut\nCustom data science models or business logic can be deployed simply by running `umlaut.track_model()`. Ensure the model code block is in a Python `Class` and follow the example below.\n\n```\nclass ExampleModel():\n \"\"\"\n Example business logic that can be wrapped into a model.\n The class _must_ contain a 'predict' method.\n \"\"\"\n def business_logic(self, revenue: int) -> bool:\n return revenue > 5\n\n def predict(self, model_input: dict) -> bool:\n return self.business_logic(revenue=model_input.get(\"revenue\"))\n\n\nif __name__ == \"__main__\":\n \"\"\"Saves the model to MLflow in an experiment run\"\"\"\n from umlaut import Umlaut\n\n Umlaut.track_model(\n model=ExampleModel(),\n model_name=\"Quarterly Revenue\",\n run_name=\"Update\",\n )\n```\n\nThis will push the latest changes of `ExampleModel()` to MLflow as a new model version. Navigate to the MLflow server where you can find details for the example \"Quarterly Revenue\" model.\n\n\n### Querying models with Umlaut\nOnce a model is deployed in MLflow with `umlaut.track_model()`, it can be queried by calling `umlaut.query_model()`.\n\n```\nfrom umlaut import Umlaut\n\nresult = Umlaut.query_model(\n model_name=\"Quarterly Revenue\",\n input_config={\"revenue\": 3},\n stage=\"Staging\",\n)\nprint(f\"Revenue will{'' if result else ' not'} exceed target\")\n```\n\nIf we query the simple `Quarterly Revenue` example model with `revenue = 3`, the model will return `False` as the revenue does not exceed the target of 5. The call to the model will be tracked in MLflow with model inputs and results.\n",
"bugtrack_url": null,
"license": "",
"summary": "uMLaut simplifies deploying data science models",
"version": "0.2.2",
"split_keywords": [
"mlops",
"mlflow",
"devops"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "19a16d4d57f458d75ce736331f99257a4cbdaa1b0b2e71a3ae9e40e3107373a4",
"md5": "fdb3ed30e1ba5aae9813f7a4a217e718",
"sha256": "e9fe09ce0e535682f9e6f15b48ac18c93df98b68ff98c174238832dfb153309a"
},
"downloads": -1,
"filename": "umlaut-0.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fdb3ed30e1ba5aae9813f7a4a217e718",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9.12,<4.0",
"size": 18357,
"upload_time": "2023-02-09T02:48:33",
"upload_time_iso_8601": "2023-02-09T02:48:33.801927Z",
"url": "https://files.pythonhosted.org/packages/19/a1/6d4d57f458d75ce736331f99257a4cbdaa1b0b2e71a3ae9e40e3107373a4/umlaut-0.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e6b8591383e02d18b240e2d08da07932bfb9dc620b229dc93adf41c2ffe2e653",
"md5": "5e9c1fb7806fa3cad38c6c27e9c14ef4",
"sha256": "a9973f3c6b3d4815a00cdb6b1a09abcce62b266f30b67e7dccdf5bc4f981a3b8"
},
"downloads": -1,
"filename": "umlaut-0.2.2.tar.gz",
"has_sig": false,
"md5_digest": "5e9c1fb7806fa3cad38c6c27e9c14ef4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9.12,<4.0",
"size": 17489,
"upload_time": "2023-02-09T02:48:35",
"upload_time_iso_8601": "2023-02-09T02:48:35.440896Z",
"url": "https://files.pythonhosted.org/packages/e6/b8/591383e02d18b240e2d08da07932bfb9dc620b229dc93adf41c2ffe2e653/umlaut-0.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-02-09 02:48:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "andrewdunkel",
"github_project": "uMLaut",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "umlaut"
}