Code Monkey home page Code Monkey logo

proofofconcept_mlops's Introduction

Proof Of Concept MLOps

Example setting up MLOps using databricks-managed mlFlow and Seldon-Core on Azure.

How to setup

Setting up Infrastructure

To provision the infrastructure on Azure use terraform:

cd terraform
az login
terraform init
terraform apply

Installing seldon-core on kubernetes cluster

Use the following to install seldon-core

# Get kubernetes credentials
az aks get-credentials --resource-group MLOpsDemo --name kubernetes-demo

# Install Ambassador
sudo curl -fL https://metriton.datawire.io/downloads/linux/edgectl -o /usr/local/bin/edgectl && sudo chmod a+x /usr/local/bin/edgectl
edgectl install

# Create namespaces
kubectl create namespace seldon-system
kubectl create namespace mlflowmodels-namespace

# Install seldon-core on kubernetes cluster
helm install seldon-core seldon-core-operator \
    --repo https://storage.googleapis.com/seldon-charts \
    --set usageMetrics.enabled=true \
    --set ambassador.enabled=true \
    --namespace seldon-system

Testing out with Iris model

kubectl apply -f iris-seldon.yaml

curl -X POST https://naughty-albattani-574.edgestack.me/seldon/seldon/iris-model/api/v1.0/predictions \
    -H 'Content-Type: application/json' \
    -d '{"data": {"ndarray":[[1.0, 2.0, 5.0, 6.0]]}}'

Testing with wines mlflow model from seldon

kubectl apply -f mlflow-seldon.yaml

curl -X POST https://naughty-albattani-574.edgestack.me/seldon/seldon/mlflow-wine/api/v1.0/predictions \
    -H 'Content-Type: application/json' \
    -d '{"data": {"ndarray":[[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1]]}}'

Transfer model from mlflow to seldon-core

# Login to azure & get kubernetes setup
az login
az aks get-credentials --resource-group MLOpsDemo --name kubernetes-demo
az extension add --name storage-preview

# Connect to the databricks workspace
export DATABRICKS_AAD_TOKEN=$(jq .accessToken -r <<< "$(az account get-access-token --resource 2ff814a6-3304-4ab8-85cb-cd0e6f879c1d)")
databricks configure --aad-token

# Fetch mnist keras mlflow model from databricks (trained as described in medium post)
cd deploy_script
python download_mlflow_model.py --model_name "Digit Classifier" --model_stage Production

# S2I image expects conda yaml to be in 'environment.yml' file
# We append 'seldon-core' package in the yaml as a dependency (github issue 1125)
sed -e "/  - mlflow/a\\  - seldon-core" < model/conda.yaml | tee environment.yml

# Put model into docker image
s2i build \
  -e MODEL_NAME=MyMlflowModel \
  -e API_TYPE=REST \
  -e SERVICE_TYPE=MODEL \
  -e PERSISTENCE=0 \
  -e CONDA_ENV_NAME=microservice \
  . seldonio/seldon-core-s2i-python3:1.8.0-dev nanomathias/mlflow_model:0.1

# Push docker image to repository
docker push nanomathias/mlflow_model:0.1

# Test locally by running the docker image & sending a request
docker run --rm --name mlflowmodel -p 5000:5000 nanomathias/mlflow_model:0.1
seldon-core-microservice-tester contract.json 0.0.0.0 5000 -p --grpc

# Deploy to cluster
kubectl apply -f mlflow-custom.yaml

For testing deployment we can go to the following: https://naughty-albattani-574.edgestack.me/seldon/seldon/mlflow-wine/api/v1.0/doc/

Prometheus & Grafana for Monitoring

helm install seldon-core-analytics seldon-core-analytics \
  --set grafana_prom_admin_password=password \
   --repo https://storage.googleapis.com/seldon-charts \
   --namespace seldon-system

kubectl port-forward svc/seldon-core-analytics-grafana 3000:80 -n seldon-system

proofofconcept_mlops's People

Contributors

mathiasgruber avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.