iykrichie / mlflow-project-best-practices

An example MLFlow project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mlflow-project-best-practices

An example MLFlow project

Python application test with Github Actions

High Level Architecture

end-to-end-mlops

You can Notebook see the Databricks code here: https://github.com/noahgift/mlflow-project-best-practices/blob/main/XGBoost-fake-news-automl.ipynb

Example in Azure CloudShell

predict

Example in Github Codespaces

Screen Shot 2022-03-12 at 7 11 31 PM

Curl Example

curl \
  -u token:$DATABRICKS_TOKEN \
  -X POST \
  -H "Content-Type: application/json; format=pandas-records" \
  -d@data.json \
  https://adb-2951765055089996.16.azuredatabricks.net/model/Fake-News/1/invocations

Deploy Architecture

IMG_0217

Query registered model

Query with Databricks CLI

  1. Create a databricks config: touch ~/.databrickscfg
  2. Put in host and token
  3. Query jobs

databricks jobs list --output JSON | jq 4. List clusters

databricks clusters list --output JSON | jq

  1. List contents of DBFS

databricks fs ls dbfs:/

Query for Models with API

You need to set the tracking URI.

export MLFLOW_TRACKING_URI=databricks
from pprint import pprint
from mlflow.tracking import MlflowClient
client = MlflowClient()
for rm in client.list_registered_models():
  pprint(dict(rm), indent=4)

Download Model

CLI version

mlflow artifacts download --artifact-uri models:/<name>/<version|stage>

To use Python do the following:

from mlflow.store.artifact.models_artifact_repo import ModelsArtifactRepository

model_uri = MlflowClient.get_model_version_download_uri(model_name, model_version)
ModelsArtifactRepository(model_uri).download_artifacts(artifact_path="")

Register model for AWS Sagemaker

Screen Shot 2022-03-16 at 1 53 31 PM

Goal for today

  • Databricks Tensorflow run
  • Feature Store
  • Model Serving

Model Serving

https://docs.databricks.com/applications/mlflow/model-serving.html

Run it with mlserve

 mlflow models serve --model-uri  /workspaces/mlflow-project-best-practices/tf-model

References

About

An example MLFlow project

License:Creative Commons Zero v1.0 Universal


Languages

Language:Jupyter Notebook 90.6%Language:PureBasic 5.1%Language:Python 3.7%Language:Shell 0.3%Language:Dockerfile 0.2%Language:Makefile 0.1%