From 6d04973c547474b23058af555e7ac60e5020ea36 Mon Sep 17 00:00:00 2001 From: Sherif Akoush Date: Wed, 11 Aug 2021 16:38:26 +0100 Subject: [PATCH 01/10] Add a first pass mlflow v2 end to end example --- notebooks/mlflow_v2_protocol_end_to_end.ipynb | 1133 +++++++++++++++++ 1 file changed, 1133 insertions(+) create mode 100644 notebooks/mlflow_v2_protocol_end_to_end.ipynb diff --git a/notebooks/mlflow_v2_protocol_end_to_end.ipynb b/notebooks/mlflow_v2_protocol_end_to_end.ipynb new file mode 100644 index 0000000000..1390adf0e0 --- /dev/null +++ b/notebooks/mlflow_v2_protocol_end_to_end.ipynb @@ -0,0 +1,1133 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "6812a5fb", + "metadata": {}, + "source": [ + "# MLFlow v2 protocol elasticnet wine example\n", + "\n", + "In this example we are going to build a model using mlflow, pack and deploy it on seldon-core on a local kind cluster" + ] + }, + { + "cell_type": "markdown", + "id": "a842a699", + "metadata": {}, + "source": [ + "Prerequisites:\n", + "\n", + "- install and configure `mc`, follow the relevant section in this [link](https://docs.seldon.io/projects/seldon-core/en/latest/examples/minio_setup.html):\n", + "\n", + "- run this jupyter notebook in conda environment\n", + "```bash\n", + "$ conda create --name python3.8-mlflow-example python=3.8 -y\n", + "$ conda activate python3.8-mlflow-example\n", + "$ pip install jupyter\n", + "$ jupyter notebook\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "5d7c94b0", + "metadata": {}, + "source": [ + "## Setup local kind cluster using ansible" + ] + }, + { + "cell_type": "markdown", + "id": "246b23a4", + "metadata": {}, + "source": [ + "### Install ansible prerequisites" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "ef719025", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting ansible\n", + " Using cached ansible-4.3.0-py3-none-any.whl\n", + "Collecting openshift\n", + " Using cached openshift-0.12.1-py3-none-any.whl\n", + "Requirement already satisfied: docker in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (5.0.0)\n", + "Collecting passlib\n", + " Using cached passlib-1.7.4-py2.py3-none-any.whl (525 kB)\n", + "Collecting ansible-core<2.12,>=2.11.3\n", + " Using cached ansible_core-2.11.3-py3-none-any.whl\n", + "Requirement already satisfied: six in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from openshift) (1.16.0)\n", + "Requirement already satisfied: jinja2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from openshift) (3.0.1)\n", + "Collecting python-string-utils\n", + " Using cached python_string_utils-1.0.0-py3-none-any.whl (26 kB)\n", + "Collecting ruamel.yaml\n", + " Using cached ruamel.yaml-0.17.10-py3-none-any.whl (108 kB)\n", + "Collecting kubernetes~=12.0\n", + " Using cached kubernetes-12.0.1-py2.py3-none-any.whl (1.7 MB)\n", + "Requirement already satisfied: websocket-client>=0.32.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from docker) (1.1.1)\n", + "Requirement already satisfied: requests!=2.18.0,>=2.14.2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from docker) (2.26.0)\n", + "Requirement already satisfied: packaging in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from ansible-core<2.12,>=2.11.3->ansible) (21.0)\n", + "Collecting resolvelib<0.6.0,>=0.5.3\n", + " Using cached resolvelib-0.5.4-py2.py3-none-any.whl (12 kB)\n", + "Collecting cryptography\n", + " Using cached cryptography-3.4.7-cp36-abi3-manylinux2014_x86_64.whl (3.2 MB)\n", + "Requirement already satisfied: PyYAML in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from ansible-core<2.12,>=2.11.3->ansible) (5.4.1)\n", + "Requirement already satisfied: certifi>=14.05.14 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from kubernetes~=12.0->openshift) (2021.5.30)\n", + "Requirement already satisfied: urllib3>=1.24.2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from kubernetes~=12.0->openshift) (1.26.6)\n", + "Requirement already satisfied: python-dateutil>=2.5.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from kubernetes~=12.0->openshift) (2.8.2)\n", + "Collecting google-auth>=1.0.1\n", + " Using cached google_auth-1.34.0-py2.py3-none-any.whl (152 kB)\n", + "Collecting requests-oauthlib\n", + " Using cached requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)\n", + "Requirement already satisfied: setuptools>=21.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from kubernetes~=12.0->openshift) (52.0.0.post20210125)\n", + "Collecting rsa<5,>=3.1.4\n", + " Using cached rsa-4.7.2-py3-none-any.whl (34 kB)\n", + "Collecting cachetools<5.0,>=2.0.0\n", + " Using cached cachetools-4.2.2-py3-none-any.whl (11 kB)\n", + "Collecting pyasn1-modules>=0.2.1\n", + " Using cached pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)\n", + "Collecting pyasn1<0.5.0,>=0.4.6\n", + " Using cached pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)\n", + "Requirement already satisfied: charset-normalizer~=2.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests!=2.18.0,>=2.14.2->docker) (2.0.4)\n", + "Requirement already satisfied: idna<4,>=2.5 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests!=2.18.0,>=2.14.2->docker) (3.2)\n", + "Requirement already satisfied: cffi>=1.12 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from cryptography->ansible-core<2.12,>=2.11.3->ansible) (1.14.6)\n", + "Requirement already satisfied: pycparser in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from cffi>=1.12->cryptography->ansible-core<2.12,>=2.11.3->ansible) (2.20)\n", + "Requirement already satisfied: MarkupSafe>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from jinja2->openshift) (2.0.1)\n", + "Requirement already satisfied: pyparsing>=2.0.2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from packaging->ansible-core<2.12,>=2.11.3->ansible) (2.4.7)\n", + "Collecting oauthlib>=3.0.0\n", + " Using cached oauthlib-3.1.1-py2.py3-none-any.whl (146 kB)\n", + "Collecting ruamel.yaml.clib>=0.1.2\n", + " Using cached ruamel.yaml.clib-0.2.6-cp38-cp38-manylinux1_x86_64.whl (570 kB)\n", + "Installing collected packages: pyasn1, rsa, pyasn1-modules, oauthlib, cachetools, ruamel.yaml.clib, resolvelib, requests-oauthlib, google-auth, cryptography, ruamel.yaml, python-string-utils, kubernetes, ansible-core, passlib, openshift, ansible\n", + "Successfully installed ansible-4.3.0 ansible-core-2.11.3 cachetools-4.2.2 cryptography-3.4.7 google-auth-1.34.0 kubernetes-12.0.1 oauthlib-3.1.1 openshift-0.12.1 passlib-1.7.4 pyasn1-0.4.8 pyasn1-modules-0.2.8 python-string-utils-1.0.0 requests-oauthlib-1.3.0 resolvelib-0.5.4 rsa-4.7.2 ruamel.yaml-0.17.10 ruamel.yaml.clib-0.2.6\n" + ] + } + ], + "source": [ + "!pip install ansible openshift docker passlib" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "f6e0d020", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Cloning into '/home/sa/.ansible/tmp/ansible-local-3444016e_43ifbj/tmpl593c8ki/ansible-k8s-collectiongefpw6fb'...\n", + "remote: Enumerating objects: 676, done.\u001b[K\n", + "remote: Counting objects: 100% (676/676), done.\u001b[K\n", + "remote: Compressing objects: 100% (417/417), done.\u001b[K\n", + "remote: Total 676 (delta 282), reused 536 (delta 166), pack-reused 0\u001b[K\n", + "Receiving objects: 100% (676/676), 277.25 KiB | 2.50 MiB/s, done.\n", + "Resolving deltas: 100% (282/282), done.\n", + "Your branch is up-to-date with 'origin/master'.\n", + "Starting galaxy collection install process\n", + "Process install dependency map\n", + "Starting collection install process\n", + "Installing 'seldonio.k8s:0.3.0-dev' to '/home/sa/.ansible/collections/ansible_collections/seldonio/k8s'\n", + "Created collection for seldonio.k8s:0.3.0-dev at /home/sa/.ansible/collections/ansible_collections/seldonio/k8s\n", + "seldonio.k8s:0.3.0-dev was installed successfully\n", + "Skipping 'kubernetes.core:2.1.1' as it is already installed\n", + "Skipping 'community.docker:1.9.0' as it is already installed\n", + "Skipping 'community.crypto:1.7.1' as it is already installed\n" + ] + } + ], + "source": [ + "!ansible-galaxy collection install git+https://github.com/SeldonIO/ansible-k8s-collection.git" + ] + }, + { + "cell_type": "markdown", + "id": "f9f3501f", + "metadata": {}, + "source": [ + "### Setup kind cluster and install seldon-core" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "f4d2f264", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "PLAY [Create Kind Cluster and Install MetalLB] *********************************\n", + "\n", + "TASK [seldonio.k8s.kind : Check if Kind v0.11.1 already downloaded] ************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Create .resources directory if does not exist: /home/sa/code/seldon-core/ansible/.resources/] ***\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Download Kind v0.11.1 binary] ************************\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Make Kind v0.11.1 binary executable] *****************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Check if KinD Cluster already exists: ansible] *******\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Start KinD Cluster: 'ansible'] ***********************\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Echo output of \"kind create cluster ...\" command] ****\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Export kubeconfig for KinD Cluster: 'ansible'] *******\n", + "changed: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Create a k8s namespace: seldon] **********************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Set default for kubectl namespace: seldon] ***********\n", + "changed: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Download metrics-server manifest.] *******************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Modify the manifest to allow insecure TLS for testing.] ***\n", + "ok: [localhost] => (item=kubelet-preferred-address-types=InternalIP)\n", + "ok: [localhost] => (item=kubelet-insecure-tls)\n", + "\n", + "TASK [seldonio.k8s.kind : Deploy metrics-server into the cluster.] *************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.metallb : Get information about kind network in docker.] ****\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.metallb : Extract subnet of kind network] *******************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.metallb : Set ranges for MetalLB] ***************************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.metallb : Echo message about kind network 2] ****************\n", + "ok: [localhost] => {\n", + " \"msg\": [\n", + " \"metallb_range_start: 172.18.255.1\",\n", + " \"metallb_range_stop: 172.18.255.255\"\n", + " ]\n", + "}\n", + "\n", + "TASK [seldonio.k8s.metallb : Deploy MetalLB] ***********************************\n", + "ok: [localhost] => (item=https://raw.githubusercontent.com/metallb/metallb/v0.10.2/manifests/namespace.yaml)\n", + "ok: [localhost] => (item=https://raw.githubusercontent.com/metallb/metallb/v0.10.2/manifests/metallb.yaml)\n", + "\n", + "TASK [seldonio.k8s.metallb : Create OpenSSL secretkey] *************************\n", + "changed: [localhost]\n", + "\n", + "TASK [seldonio.k8s.metallb : Create memberlist secret] *************************\n", + "changed: [localhost]\n", + "\n", + "TASK [seldonio.k8s.metallb : Create MetalLB Config] ****************************\n", + "ok: [localhost]\n", + "\n", + "PLAY RECAP *********************************************************************\n", + "localhost : ok=18 changed=4 unreachable=0 failed=0 skipped=3 rescued=0 ignored=0 \n", + "\n", + "\n", + "PLAY [Install Seldon Core & Prerequisites] *************************************\n", + "\n", + "TASK [Load vars from vars/default.yaml] ****************************************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Check if Istio 1.10.3 already downloaded.] **********\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Create .resources directory if does not exist: /home/sa/code/seldon-core/ansible/.resources/] ***\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Download Istio 1.10.3] ******************************\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Install Istio 1.10.3] *******************************\n", + "changed: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Verify Install Istio 1.10.3] ************************\n", + "changed: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Create Seldon Gateway] ******************************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Wait for External IP Address to be ready] ***********\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Set fact about Istio Ingress Gateway External IP] ***\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Create temporary certificates directory] ************\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Generate CA Private Key with RSA 2048] **************\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Generate CA CSR] ************************************\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Generate CA Self Signed Certificate] ****************\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Generate Server OpenSSL private key with RSA 2048] ***\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Generate an OpenSSL Certificate Signing Request for server] ***\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Generate an OpenSSL certificate from the server CSR signed with our CA certificate] ***\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Set fact about Server SSL Certs Paths] **************\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Create Istio Ingressgateway SSL Certs Secret] *******\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Remove temporary certificates directory] ************\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.ambassador : Create a k8s namespace: ambassador] ************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.ambassador : Install ambassador] ****************************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.minio : Create a k8s namespaces] ****************************\n", + "ok: [localhost] => (item=minio-system)\n", + "ok: [localhost] => (item=seldon)\n", + "\n", + "TASK [seldonio.k8s.minio : Install MinIO] **************************************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.minio : Echo message about client configuration] ************\n", + "ok: [localhost] => {\n", + " \"msg\": [\n", + " \"MinIO installed in the cluster. To configure your local client launch\",\n", + " \"kubectl port-forward -n minio-system svc/minio 8090:9000\",\n", + " \"in one terminal and execute\",\n", + " \"mc config host add minio-seldon http://localhost:8090 ACCESS_KEY SECRET_KEY\"\n", + " ]\n", + "}\n", + "\n", + "TASK [seldonio.k8s.minio : Configure Minio VirtualService] *********************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.minio : Create MinIO Secret (rclone storage initializer format)] ***\n", + "ok: [localhost] => (item=seldon)\n", + "\n", + "TASK [seldonio.k8s.minio : Create MinIO Secret (kfserving storage initializer format)] ***\n", + "ok: [localhost] => (item=seldon)\n", + "\n", + "TASK [seldonio.k8s.seldon_core_analytics : Create a seldon-system namespaces] ***\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.seldon_core_analytics : Create Extra Resources from Templates] ***\n", + "\n", + "TASK [seldonio.k8s.seldon_core_analytics : Install Seldon Core Analytics] ******\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.seldon_core_analytics : Wait for Seldon Core Analytics Deployments] ***\n", + "ok: [localhost] => (item=seldon-core-analytics-grafana)\n", + "ok: [localhost] => (item=seldon-core-analytics-kube-state-metrics)\n", + "ok: [localhost] => (item=seldon-core-analytics-prometheus-alertmanager)\n", + "ok: [localhost] => (item=seldon-core-analytics-prometheus-pushgateway)\n", + "ok: [localhost] => (item=seldon-core-analytics-prometheus-seldon)\n", + "\n", + "TASK [seldonio.k8s.seldon_core : Create a k8s namespaces] **********************\n", + "ok: [localhost] => (item=seldon-system)\n", + "ok: [localhost] => (item=seldon)\n", + "\n", + "TASK [seldonio.k8s.seldon_core : Git clone Seldon Core repo and checkout master] ***\n", + "changed: [localhost]\n", + "\n", + "TASK [seldonio.k8s.seldon_core : Set Seldon Core Directory] ********************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.seldon_core : Deploy Seldon Core] ***************************\n", + "changed: [localhost]\n", + "\n", + "TASK [seldonio.k8s.seldon_core : Wait for Seldon Core deployments] *************\n", + "ok: [localhost] => (item=seldon-controller-manager)\n", + "\n", + "PLAY RECAP *********************************************************************\n", + "localhost : ok=22 changed=4 unreachable=0 failed=0 skipped=14 rescued=0 ignored=0 \n", + "\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "[WARNING]: The default idempotency check can fail to report changes in certain\n", + "cases. Install helm diff for better results.\n" + ] + } + ], + "source": [ + "%%bash\n", + "cd ../ansible\n", + "ansible-playbook playbooks/kind_cluster.yaml\n", + "ansible-playbook playbooks/main.yaml -e seldon_core_version=master " + ] + }, + { + "cell_type": "markdown", + "id": "144577cf", + "metadata": {}, + "source": [ + "## Train elasticnet wine model using `mlflow`" + ] + }, + { + "cell_type": "markdown", + "id": "a48e09c8", + "metadata": {}, + "source": [ + "### Install `mlflow` and required dependencies to train the model" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "65d444af", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: mlflow in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (1.19.0)\n", + "Requirement already satisfied: scikit-learn==0.23.2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (0.23.2)\n", + "Requirement already satisfied: pandas in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (1.3.1)\n", + "Collecting conda-pack\n", + " Using cached conda_pack-0.6.0-py2.py3-none-any.whl\n", + "Requirement already satisfied: scipy>=0.19.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from scikit-learn==0.23.2) (1.7.1)\n", + "Requirement already satisfied: numpy>=1.13.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from scikit-learn==0.23.2) (1.21.1)\n", + "Requirement already satisfied: threadpoolctl>=2.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from scikit-learn==0.23.2) (2.2.0)\n", + "Requirement already satisfied: joblib>=0.11 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from scikit-learn==0.23.2) (1.0.1)\n", + "Requirement already satisfied: cloudpickle in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (1.6.0)\n", + "Requirement already satisfied: alembic<=1.4.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (1.4.1)\n", + "Requirement already satisfied: packaging in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (21.0)\n", + "Requirement already satisfied: Flask in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (2.0.1)\n", + "Requirement already satisfied: entrypoints in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (0.3)\n", + "Requirement already satisfied: pyyaml>=5.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (5.4.1)\n", + "Requirement already satisfied: querystring-parser in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (1.2.4)\n", + "Requirement already satisfied: sqlalchemy in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (1.4.22)\n", + "Requirement already satisfied: sqlparse>=0.3.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (0.4.1)\n", + "Requirement already satisfied: docker>=4.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (5.0.0)\n", + "Requirement already satisfied: gitpython>=2.1.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (3.1.18)\n", + "Requirement already satisfied: click>=7.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (8.0.1)\n", + "Requirement already satisfied: pytz in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (2021.1)\n", + "Requirement already satisfied: protobuf>=3.7.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (3.17.3)\n", + "Requirement already satisfied: prometheus-flask-exporter in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (0.18.2)\n", + "Requirement already satisfied: requests>=2.17.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (2.26.0)\n", + "Requirement already satisfied: gunicorn in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (20.1.0)\n", + "Requirement already satisfied: databricks-cli>=0.8.7 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (0.15.0)\n", + "Requirement already satisfied: python-dateutil>=2.7.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from pandas) (2.8.2)\n", + "Requirement already satisfied: setuptools in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from conda-pack) (52.0.0.post20210125)\n", + "Requirement already satisfied: python-editor>=0.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from alembic<=1.4.1->mlflow) (1.0.4)\n", + "Requirement already satisfied: Mako in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from alembic<=1.4.1->mlflow) (1.1.4)\n", + "Requirement already satisfied: tabulate>=0.7.7 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from databricks-cli>=0.8.7->mlflow) (0.8.9)\n", + "Requirement already satisfied: six>=1.10.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from databricks-cli>=0.8.7->mlflow) (1.16.0)\n", + "Requirement already satisfied: websocket-client>=0.32.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from docker>=4.0.0->mlflow) (1.1.1)\n", + "Requirement already satisfied: gitdb<5,>=4.0.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from gitpython>=2.1.0->mlflow) (4.0.7)\n", + "Requirement already satisfied: smmap<5,>=3.0.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from gitdb<5,>=4.0.1->gitpython>=2.1.0->mlflow) (4.0.0)\n", + "Requirement already satisfied: charset-normalizer~=2.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow) (2.0.4)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow) (2021.5.30)\n", + "Requirement already satisfied: idna<4,>=2.5 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow) (3.2)\n", + "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow) (1.26.6)\n", + "Requirement already satisfied: greenlet!=0.4.17 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from sqlalchemy->mlflow) (1.1.1)\n", + "Requirement already satisfied: itsdangerous>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Flask->mlflow) (2.0.1)\n", + "Requirement already satisfied: Werkzeug>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Flask->mlflow) (2.0.1)\n", + "Requirement already satisfied: Jinja2>=3.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Flask->mlflow) (3.0.1)\n", + "Requirement already satisfied: MarkupSafe>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Jinja2>=3.0->Flask->mlflow) (2.0.1)\n", + "Requirement already satisfied: pyparsing>=2.0.2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from packaging->mlflow) (2.4.7)\n", + "Requirement already satisfied: prometheus-client in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from prometheus-flask-exporter->mlflow) (0.11.0)\n", + "Installing collected packages: conda-pack\n", + "Successfully installed conda-pack-0.6.0\n" + ] + } + ], + "source": [ + "!pip install mlflow scikit-learn==0.23.2 pandas" + ] + }, + { + "cell_type": "markdown", + "id": "3176a423", + "metadata": {}, + "source": [ + "### Define where the model artifacts will be saved" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "b66ccdff", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "from pathlib import Path\n", + "MODEL_DIR = Path(os.getcwd()) / \"elasticnet_wine_model\"" + ] + }, + { + "cell_type": "markdown", + "id": "a3dfcc20", + "metadata": {}, + "source": [ + "### Define training" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "57f8a675", + "metadata": {}, + "outputs": [], + "source": [ + "# Wine Quality Sample a copy from: \n", + "# https://github.com/mlflow/mlflow/blob/master/examples/sklearn_elasticnet_wine/train.ipynb\n", + "\n", + "def train(in_alpha, in_l1_ratio):\n", + " import os\n", + " import warnings\n", + " import sys\n", + "\n", + " import pandas as pd\n", + " import numpy as np\n", + " from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score\n", + " from sklearn.model_selection import train_test_split\n", + " from sklearn.linear_model import ElasticNet\n", + "\n", + " import mlflow\n", + " import mlflow.sklearn\n", + " \n", + " import logging\n", + " logging.basicConfig(level=logging.WARN)\n", + " logger = logging.getLogger(__name__)\n", + "\n", + " def eval_metrics(actual, pred):\n", + " rmse = np.sqrt(mean_squared_error(actual, pred))\n", + " mae = mean_absolute_error(actual, pred)\n", + " r2 = r2_score(actual, pred)\n", + " return rmse, mae, r2\n", + "\n", + "\n", + " warnings.filterwarnings(\"ignore\")\n", + " np.random.seed(40)\n", + "\n", + " # Read the wine-quality csv file from the URL\n", + " csv_url =\\\n", + " 'http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv'\n", + " try:\n", + " data = pd.read_csv(csv_url, sep=';')\n", + " except Exception as e:\n", + " logger.exception(\n", + " \"Unable to download training & test CSV, check your internet connection. Error: %s\", e)\n", + "\n", + " # Split the data into training and test sets. (0.75, 0.25) split.\n", + " train, test = train_test_split(data)\n", + "\n", + " # The predicted column is \"quality\" which is a scalar from [3, 9]\n", + " train_x = train.drop([\"quality\"], axis=1)\n", + " test_x = test.drop([\"quality\"], axis=1)\n", + " train_y = train[[\"quality\"]]\n", + " test_y = test[[\"quality\"]]\n", + "\n", + " # Set default values if no alpha is provided\n", + " if float(in_alpha) is None:\n", + " alpha = 0.5\n", + " else:\n", + " alpha = float(in_alpha)\n", + "\n", + " # Set default values if no l1_ratio is provided\n", + " if float(in_l1_ratio) is None:\n", + " l1_ratio = 0.5\n", + " else:\n", + " l1_ratio = float(in_l1_ratio)\n", + "\n", + " # Useful for multiple runs (only doing one run in this sample notebook) \n", + " with mlflow.start_run():\n", + " # Execute ElasticNet\n", + " lr = ElasticNet(alpha=alpha, l1_ratio=l1_ratio, random_state=42)\n", + " lr.fit(train_x, train_y)\n", + "\n", + " # Evaluate Metrics\n", + " predicted_qualities = lr.predict(test_x)\n", + " (rmse, mae, r2) = eval_metrics(test_y, predicted_qualities)\n", + "\n", + " # Print out metrics\n", + " print(\"Elasticnet model (alpha=%f, l1_ratio=%f):\" % (alpha, l1_ratio))\n", + " print(\" RMSE: %s\" % rmse)\n", + " print(\" MAE: %s\" % mae)\n", + " print(\" R2: %s\" % r2)\n", + "\n", + " # Log parameter, metrics, and model to MLflow\n", + " mlflow.log_param(\"alpha\", alpha)\n", + " mlflow.log_param(\"l1_ratio\", l1_ratio)\n", + " mlflow.log_metric(\"rmse\", rmse)\n", + " mlflow.log_metric(\"r2\", r2)\n", + " mlflow.log_metric(\"mae\", mae)\n", + "\n", + " mlflow.sklearn.save_model(lr, MODEL_DIR)\n", + " print(f\" Model saved to {MODEL_DIR}\")" + ] + }, + { + "cell_type": "markdown", + "id": "cfde8513", + "metadata": {}, + "source": [ + "### Train the elasticnet_wine model" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "33f84e54", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Elasticnet model (alpha=0.500000, l1_ratio=0.500000):\n", + " RMSE: 0.7931640229276851\n", + " MAE: 0.6271946374319587\n", + " R2: 0.10862644997792614\n", + " Model saved to /home/sa/code/seldon-core/notebooks/elasticnet_wine_model\n" + ] + } + ], + "source": [ + "train(0.5, 0.5)" + ] + }, + { + "cell_type": "markdown", + "id": "dd308902", + "metadata": {}, + "source": [ + "### Install dependencies to be able to pack and deploy the model on `seldon_core`" + ] + }, + { + "cell_type": "markdown", + "id": "b477787e", + "metadata": {}, + "source": [ + "We are going to use [`conda-pack`](https://conda.github.io/conda-pack/) to pack the python enviornment. We also need `mlserver` dependencies.\n", + "We are planning to simplify this workflow in future releases." + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "id": "00aeeccb", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: conda-pack in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (0.6.0)\n", + "Collecting mlserver==0.4.0\n", + " Using cached mlserver-0.4.0-py3-none-any.whl (61 kB)\n", + "Collecting mlserver-mlflow==0.4.0\n", + " Using cached mlserver_mlflow-0.4.0-py3-none-any.whl (8.3 kB)\n", + "Collecting uvicorn\n", + " Using cached uvicorn-0.14.0-py3-none-any.whl (50 kB)\n", + "Collecting orjson\n", + " Using cached orjson-3.6.1-cp38-cp38-manylinux_2_24_x86_64.whl (233 kB)\n", + "Requirement already satisfied: pandas in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlserver==0.4.0) (1.3.1)\n", + "Collecting fastapi\n", + " Using cached fastapi-0.68.0-py3-none-any.whl (52 kB)\n", + "Requirement already satisfied: protobuf in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlserver==0.4.0) (3.17.3)\n", + "Requirement already satisfied: numpy in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlserver==0.4.0) (1.21.1)\n", + "Requirement already satisfied: click in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlserver==0.4.0) (8.0.1)\n", + "Collecting grpcio\n", + " Using cached grpcio-1.39.0-cp38-cp38-manylinux2014_x86_64.whl (4.3 MB)\n", + "Requirement already satisfied: mlflow in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlserver-mlflow==0.4.0) (1.19.0)\n", + "Requirement already satisfied: setuptools in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from conda-pack) (52.0.0.post20210125)\n", + "Collecting starlette==0.14.2\n", + " Using cached starlette-0.14.2-py3-none-any.whl (60 kB)\n", + "Collecting pydantic!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0,>=1.6.2\n", + " Using cached pydantic-1.8.2-cp38-cp38-manylinux2014_x86_64.whl (13.7 MB)\n", + "Collecting typing-extensions>=3.7.4.3\n", + " Using cached typing_extensions-3.10.0.0-py3-none-any.whl (26 kB)\n", + "Requirement already satisfied: six>=1.5.2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from grpcio->mlserver==0.4.0) (1.16.0)\n", + "Requirement already satisfied: prometheus-flask-exporter in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (0.18.2)\n", + "Requirement already satisfied: sqlparse>=0.3.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (0.4.1)\n", + "Requirement already satisfied: sqlalchemy in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (1.4.22)\n", + "Requirement already satisfied: pyyaml>=5.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (5.4.1)\n", + "Requirement already satisfied: docker>=4.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (5.0.0)\n", + "Requirement already satisfied: querystring-parser in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (1.2.4)\n", + "Requirement already satisfied: gunicorn in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (20.1.0)\n", + "Requirement already satisfied: cloudpickle in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (1.6.0)\n", + "Requirement already satisfied: packaging in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (21.0)\n", + "Requirement already satisfied: requests>=2.17.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (2.26.0)\n", + "Requirement already satisfied: databricks-cli>=0.8.7 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (0.15.0)\n", + "Requirement already satisfied: pytz in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (2021.1)\n", + "Requirement already satisfied: Flask in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (2.0.1)\n", + "Requirement already satisfied: alembic<=1.4.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (1.4.1)\n", + "Requirement already satisfied: gitpython>=2.1.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (3.1.18)\n", + "Requirement already satisfied: entrypoints in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (0.3)\n", + "Requirement already satisfied: python-dateutil in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from alembic<=1.4.1->mlflow->mlserver-mlflow==0.4.0) (2.8.2)\n", + "Requirement already satisfied: Mako in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from alembic<=1.4.1->mlflow->mlserver-mlflow==0.4.0) (1.1.4)\n", + "Requirement already satisfied: python-editor>=0.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from alembic<=1.4.1->mlflow->mlserver-mlflow==0.4.0) (1.0.4)\n", + "Requirement already satisfied: tabulate>=0.7.7 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from databricks-cli>=0.8.7->mlflow->mlserver-mlflow==0.4.0) (0.8.9)\n", + "Requirement already satisfied: websocket-client>=0.32.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from docker>=4.0.0->mlflow->mlserver-mlflow==0.4.0) (1.1.1)\n", + "Requirement already satisfied: gitdb<5,>=4.0.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from gitpython>=2.1.0->mlflow->mlserver-mlflow==0.4.0) (4.0.7)\n", + "Requirement already satisfied: smmap<5,>=3.0.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from gitdb<5,>=4.0.1->gitpython>=2.1.0->mlflow->mlserver-mlflow==0.4.0) (4.0.0)\n", + "Requirement already satisfied: charset-normalizer~=2.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow->mlserver-mlflow==0.4.0) (2.0.4)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow->mlserver-mlflow==0.4.0) (2021.5.30)\n", + "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow->mlserver-mlflow==0.4.0) (1.26.6)\n", + "Requirement already satisfied: idna<4,>=2.5 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow->mlserver-mlflow==0.4.0) (3.2)\n", + "Requirement already satisfied: greenlet!=0.4.17 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from sqlalchemy->mlflow->mlserver-mlflow==0.4.0) (1.1.1)\n", + "Requirement already satisfied: itsdangerous>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Flask->mlflow->mlserver-mlflow==0.4.0) (2.0.1)\n", + "Requirement already satisfied: Jinja2>=3.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Flask->mlflow->mlserver-mlflow==0.4.0) (3.0.1)\n", + "Requirement already satisfied: Werkzeug>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Flask->mlflow->mlserver-mlflow==0.4.0) (2.0.1)\n", + "Requirement already satisfied: MarkupSafe>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Jinja2>=3.0->Flask->mlflow->mlserver-mlflow==0.4.0) (2.0.1)\n", + "Requirement already satisfied: pyparsing>=2.0.2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from packaging->mlflow->mlserver-mlflow==0.4.0) (2.4.7)\n", + "Requirement already satisfied: prometheus-client in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from prometheus-flask-exporter->mlflow->mlserver-mlflow==0.4.0) (0.11.0)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting asgiref>=3.3.4\n", + " Using cached asgiref-3.4.1-py3-none-any.whl (25 kB)\n", + "Collecting h11>=0.8\n", + " Using cached h11-0.12.0-py3-none-any.whl (54 kB)\n", + "Installing collected packages: typing-extensions, starlette, pydantic, h11, asgiref, uvicorn, orjson, grpcio, fastapi, mlserver, mlserver-mlflow\n", + "Successfully installed asgiref-3.4.1 fastapi-0.68.0 grpcio-1.39.0 h11-0.12.0 mlserver-0.4.0 mlserver-mlflow-0.4.0 orjson-3.6.1 pydantic-1.8.2 starlette-0.14.2 typing-extensions-3.10.0.0 uvicorn-0.14.0\n" + ] + } + ], + "source": [ + "!pip install conda-pack mlserver==0.4.0 mlserver-mlflow==0.4.0" + ] + }, + { + "cell_type": "markdown", + "id": "9cc9cb95", + "metadata": {}, + "source": [ + "### Pack the conda enviornment" + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "id": "0fbfe38f", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting packages...\n", + "Packing environment at '/home/sa/miniconda3/envs/python3.8-mlflow-example' to '/home/sa/code/seldon-core/notebooks/elasticnet_wine_model/environment.tar.gz'\n", + "[########################################] | 100% Completed | 42.9s\n" + ] + }, + { + "data": { + "text/plain": [ + "'/home/sa/code/seldon-core/notebooks/elasticnet_wine_model/environment.tar.gz'" + ] + }, + "execution_count": 61, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import conda_pack\n", + "env_file_path = MODEL_DIR / \"environment.tar.gz\"\n", + "conda_pack.pack(\n", + " output=str(env_file_path),\n", + " force=True,\n", + " verbose=True,\n", + " ignore_editable_packages=False,\n", + " ignore_missing_files=True,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "17652087", + "metadata": {}, + "source": [ + "### Configure `mc` to access the minio service in the local kind cluster\n", + "note: make sure that minio ip is reflected properly below, run `kubectl get service -n minio-system`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3a4834e2", + "metadata": {}, + "outputs": [], + "source": [ + "!mc config host add minio-seldon http://172.18.255.3:9000 minioadmin minioadmin" + ] + }, + { + "cell_type": "markdown", + "id": "35963189", + "metadata": {}, + "source": [ + "### Copy the model artifacts to minio" + ] + }, + { + "cell_type": "code", + "execution_count": 75, + "id": "6913d557", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Removing `minio-seldon/model/MLmodel`.\n", + "Removing `minio-seldon/model/conda.yaml`.\n", + "Removing `minio-seldon/model/environment.tar.gz`.\n", + "Removing `minio-seldon/model/model.pkl`.\n", + "Removing `minio-seldon/model/requirements.txt`.\n", + "`/home/sa/code/seldon-core/notebooks/elasticnet_wine_model/environment.tar.gz` -> `minio-seldon/model/elasticnet_wine_model/environment.tar.gz`\n", + "`/home/sa/code/seldon-core/notebooks/elasticnet_wine_model/model.pkl` -> `minio-seldon/model/elasticnet_wine_model/model.pkl`\n", + "`/home/sa/code/seldon-core/notebooks/elasticnet_wine_model/requirements.txt` -> `minio-seldon/model/elasticnet_wine_model/requirements.txt`\n", + "`/home/sa/code/seldon-core/notebooks/elasticnet_wine_model/conda.yaml` -> `minio-seldon/model/elasticnet_wine_model/conda.yaml`\n", + "`/home/sa/code/seldon-core/notebooks/elasticnet_wine_model/MLmodel` -> `minio-seldon/model/elasticnet_wine_model/MLmodel`\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "mc: Unable to make bucket `minio-seldon/model`. Your previous request to create the named bucket succeeded and you already own it.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total: 0 B, Transferred: 322.90 MiB, Speed: 469.47 MiB/s\n" + ] + }, + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 75, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import os\n", + "os.system(\"mc mb minio-seldon/model\")\n", + "os.system(f\"mc cp --recursive {MODEL_DIR} minio-seldon/model\")" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "id": "48611bc4", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Overwriting ./resources/elasticnet_wine_v2.yaml\n" + ] + } + ], + "source": [ + "%%writefile ./resources/mlflow_elasticnet_wine_v2.yaml\n", + "apiVersion: machinelearning.seldon.io/v1alpha2\n", + "kind: SeldonDeployment\n", + "metadata:\n", + " name: mlflow\n", + "spec:\n", + " protocol: kfserving # Activate v2 protocol\n", + " name: wines\n", + " predictors:\n", + " - graph:\n", + " children: []\n", + " implementation: MLFLOW_SERVER\n", + " modelUri: s3:/model\n", + " envSecretRefName: seldon-rclone-secret\n", + " name: classifier\n", + " name: default\n", + " replicas: 1" + ] + }, + { + "cell_type": "code", + "execution_count": 66, + "id": "38416d92", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "seldondeployment.machinelearning.seldon.io/mlflow created\r\n" + ] + } + ], + "source": [ + "!kubectl apply -f ./resources/mlflow_elasticnet_wine_v2.yaml" + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "id": "2ccecb6e", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "deployment \"mlflow-default-0-classifier\" successfully rolled out\r\n" + ] + } + ], + "source": [ + "!kubectl rollout status deploy/$(kubectl get deploy -l seldon-deployment-id=mlflow -o jsonpath='{.items[0].metadata.name}')" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "id": "a5e529b5", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " \"model_name\": \"classifier\",\n", + " \"model_version\": \"v1\",\n", + " \"id\": \"1b0648b3-b7ad-426f-9d37-395ab441b179\",\n", + " \"parameters\": null,\n", + " \"outputs\": [\n", + " {\n", + " \"name\": \"predict\",\n", + " \"shape\": [\n", + " 1\n", + " ],\n", + " \"datatype\": \"FP64\",\n", + " \"parameters\": null,\n", + " \"data\": [\n", + " 5.576883936610762\n", + " ]\n", + " }\n", + " ]\n", + "}\n" + ] + } + ], + "source": [ + "import json\n", + "\n", + "import requests\n", + "\n", + "inference_request = {\n", + " \"parameters\": {\n", + " \"content_type\": \"pd\"\n", + " },\n", + " \"inputs\": [\n", + " {\n", + " \"name\": \"fixed acidity\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [7.4],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"volatile acidity\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [0.7000],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"citric acidity\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [0],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"residual sugar\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [1.9],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"chlorides\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [0.076],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"free sulfur dioxide\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [11],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"total sulfur dioxide\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [34],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"density\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [0.9978],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"pH\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [3.51],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"sulphates\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [0.56],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"alcohol\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [9.4],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " ]\n", + "}\n", + "\n", + "# note is the local balancer for istion, make sure that the ip is reflected in the setup,\n", + "# run kubectl get service -n istio-system\n", + "endpoint = \"http://172.18.255.1/seldon/seldon/mlflow/v2/models/infer\"\n", + "response = requests.post(endpoint, json=inference_request)\n", + "\n", + "print(json.dumps(response.json(), indent=2))\n", + "assert response.ok" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "id": "f04b56c3", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "seldondeployment.machinelearning.seldon.io \"mlflow\" deleted\r\n" + ] + } + ], + "source": [ + "!kubectl delete -f ./resources/mlflow_elasticnet_wine_v2.yaml" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7dfe0f11", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.11" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 656405fb223645fa82f31c8df7c41d39794ba827 Mon Sep 17 00:00:00 2001 From: Sherif Akoush Date: Wed, 11 Aug 2021 17:02:45 +0100 Subject: [PATCH 02/10] add notebook to the docs --- .../mlflow_v2_protocol_end_to_end.nblink | 3 + doc/source/examples/notebooks.rst | 1 + .../mlflow_v2_protocol_end_to_end.ipynb | 568 ++++++++++++++++++ 3 files changed, 572 insertions(+) create mode 100644 doc/source/examples/mlflow_v2_protocol_end_to_end.nblink create mode 100644 examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb diff --git a/doc/source/examples/mlflow_v2_protocol_end_to_end.nblink b/doc/source/examples/mlflow_v2_protocol_end_to_end.nblink new file mode 100644 index 0000000000..2b27af462d --- /dev/null +++ b/doc/source/examples/mlflow_v2_protocol_end_to_end.nblink @@ -0,0 +1,3 @@ +{ + "path": "../../../examples/models/mlflow_v2_protocol_end_to_end.ipynb", +} diff --git a/doc/source/examples/notebooks.rst b/doc/source/examples/notebooks.rst index 971488f77a..52a341d396 100644 --- a/doc/source/examples/notebooks.rst +++ b/doc/source/examples/notebooks.rst @@ -22,6 +22,7 @@ Prepackaged Inference Server Examples Deploy a Scikit-learn Model Binary <../servers/sklearn.md> Deploy a Tensorflow Exported Model <../servers/tensorflow.md> MLflow Pre-packaged Model Server A/B Test + MLflow v2 Protocol End to End Workflow (Incubating) Deploy a XGBoost Model Binary <../servers/xgboost.md> Deploy Pre-packaged Model Server with Cluster's MinIO Custom Pre-packaged LightGBM Server diff --git a/examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb b/examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb new file mode 100644 index 0000000000..28f8aa38f4 --- /dev/null +++ b/examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb @@ -0,0 +1,568 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "6812a5fb", + "metadata": {}, + "source": [ + "# MLFlow v2 protocol elasticnet wine example\n", + "\n", + "In this example we are going to build a model using mlflow, pack and deploy it on seldon-core on a local kind cluster" + ] + }, + { + "cell_type": "markdown", + "id": "a842a699", + "metadata": {}, + "source": [ + "Prerequisites:\n", + "\n", + "- install and configure `mc`, follow the relevant section in this [link](https://docs.seldon.io/projects/seldon-core/en/latest/examples/minio_setup.html):\n", + "\n", + "- run this jupyter notebook in conda environment\n", + "```bash\n", + "$ conda create --name python3.8-mlflow-example python=3.8 -y\n", + "$ conda activate python3.8-mlflow-example\n", + "$ pip install jupyter\n", + "$ jupyter notebook\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "5d7c94b0", + "metadata": {}, + "source": [ + "## Setup local kind cluster using ansible" + ] + }, + { + "cell_type": "markdown", + "id": "246b23a4", + "metadata": {}, + "source": [ + "### Install ansible prerequisites" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ef719025", + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "!pip install ansible openshift docker passlib" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f6e0d020", + "metadata": {}, + "outputs": [], + "source": [ + "!ansible-galaxy collection install git+https://github.com/SeldonIO/ansible-k8s-collection.git" + ] + }, + { + "cell_type": "markdown", + "id": "f9f3501f", + "metadata": {}, + "source": [ + "### Setup kind cluster and install seldon-core" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f4d2f264", + "metadata": {}, + "outputs": [], + "source": [ + "%%bash\n", + "cd ../ansible\n", + "ansible-playbook playbooks/kind_cluster.yaml\n", + "ansible-playbook playbooks/main.yaml -e seldon_core_version=master " + ] + }, + { + "cell_type": "markdown", + "id": "144577cf", + "metadata": {}, + "source": [ + "## Train elasticnet wine model using `mlflow`" + ] + }, + { + "cell_type": "markdown", + "id": "d6201b16", + "metadata": {}, + "source": [ + "### Install `mlflow` and required dependencies to train the model" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "65d444af", + "metadata": {}, + "outputs": [], + "source": [ + "!pip install mlflow scikit-learn==0.23.2 pandas" + ] + }, + { + "cell_type": "markdown", + "id": "74c9dc2b", + "metadata": {}, + "source": [ + "### Define where the model artifacts will be saved" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b66ccdff", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "from pathlib import Path\n", + "MODEL_DIR = Path(os.getcwd()) / \"elasticnet_wine_model\"" + ] + }, + { + "cell_type": "markdown", + "id": "54993046", + "metadata": {}, + "source": [ + "### Define training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "57f8a675", + "metadata": {}, + "outputs": [], + "source": [ + "# Wine Quality Sample a copy from: \n", + "# https://github.com/mlflow/mlflow/blob/master/examples/sklearn_elasticnet_wine/train.ipynb\n", + "\n", + "def train(in_alpha, in_l1_ratio):\n", + " import os\n", + " import warnings\n", + " import sys\n", + "\n", + " import pandas as pd\n", + " import numpy as np\n", + " from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score\n", + " from sklearn.model_selection import train_test_split\n", + " from sklearn.linear_model import ElasticNet\n", + "\n", + " import mlflow\n", + " import mlflow.sklearn\n", + " \n", + " import logging\n", + " logging.basicConfig(level=logging.WARN)\n", + " logger = logging.getLogger(__name__)\n", + "\n", + " def eval_metrics(actual, pred):\n", + " rmse = np.sqrt(mean_squared_error(actual, pred))\n", + " mae = mean_absolute_error(actual, pred)\n", + " r2 = r2_score(actual, pred)\n", + " return rmse, mae, r2\n", + "\n", + "\n", + " warnings.filterwarnings(\"ignore\")\n", + " np.random.seed(40)\n", + "\n", + " # Read the wine-quality csv file from the URL\n", + " csv_url =\\\n", + " 'http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv'\n", + " try:\n", + " data = pd.read_csv(csv_url, sep=';')\n", + " except Exception as e:\n", + " logger.exception(\n", + " \"Unable to download training & test CSV, check your internet connection. Error: %s\", e)\n", + "\n", + " # Split the data into training and test sets. (0.75, 0.25) split.\n", + " train, test = train_test_split(data)\n", + "\n", + " # The predicted column is \"quality\" which is a scalar from [3, 9]\n", + " train_x = train.drop([\"quality\"], axis=1)\n", + " test_x = test.drop([\"quality\"], axis=1)\n", + " train_y = train[[\"quality\"]]\n", + " test_y = test[[\"quality\"]]\n", + "\n", + " # Set default values if no alpha is provided\n", + " if float(in_alpha) is None:\n", + " alpha = 0.5\n", + " else:\n", + " alpha = float(in_alpha)\n", + "\n", + " # Set default values if no l1_ratio is provided\n", + " if float(in_l1_ratio) is None:\n", + " l1_ratio = 0.5\n", + " else:\n", + " l1_ratio = float(in_l1_ratio)\n", + "\n", + " # Useful for multiple runs (only doing one run in this sample notebook) \n", + " with mlflow.start_run():\n", + " # Execute ElasticNet\n", + " lr = ElasticNet(alpha=alpha, l1_ratio=l1_ratio, random_state=42)\n", + " lr.fit(train_x, train_y)\n", + "\n", + " # Evaluate Metrics\n", + " predicted_qualities = lr.predict(test_x)\n", + " (rmse, mae, r2) = eval_metrics(test_y, predicted_qualities)\n", + "\n", + " # Print out metrics\n", + " print(\"Elasticnet model (alpha=%f, l1_ratio=%f):\" % (alpha, l1_ratio))\n", + " print(\" RMSE: %s\" % rmse)\n", + " print(\" MAE: %s\" % mae)\n", + " print(\" R2: %s\" % r2)\n", + "\n", + " # Log parameter, metrics, and model to MLflow\n", + " mlflow.log_param(\"alpha\", alpha)\n", + " mlflow.log_param(\"l1_ratio\", l1_ratio)\n", + " mlflow.log_metric(\"rmse\", rmse)\n", + " mlflow.log_metric(\"r2\", r2)\n", + " mlflow.log_metric(\"mae\", mae)\n", + "\n", + " mlflow.sklearn.save_model(lr, MODEL_DIR)\n", + " print(f\" Model saved to {MODEL_DIR}\")" + ] + }, + { + "cell_type": "markdown", + "id": "5e97b0ab", + "metadata": {}, + "source": [ + "### Train the elasticnet_wine model" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "33f84e54", + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "train(0.5, 0.5)" + ] + }, + { + "cell_type": "markdown", + "id": "4e440e3c", + "metadata": {}, + "source": [ + "### Install dependencies to be able to pack and deploy the model on `seldon_core`" + ] + }, + { + "cell_type": "markdown", + "id": "7be3a300", + "metadata": {}, + "source": [ + "We are going to use [`conda-pack`](https://conda.github.io/conda-pack/) to pack the python enviornment. We also need `mlserver` dependencies.\n", + "We are planning to simplify this workflow in future releases." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "00aeeccb", + "metadata": {}, + "outputs": [], + "source": [ + "!pip install conda-pack mlserver==0.4.0 mlserver-mlflow==0.4.0" + ] + }, + { + "cell_type": "markdown", + "id": "9cb7f760", + "metadata": {}, + "source": [ + "### Pack the conda enviornment" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0fbfe38f", + "metadata": {}, + "outputs": [], + "source": [ + "import conda_pack\n", + "env_file_path = MODEL_DIR / \"environment.tar.gz\"\n", + "conda_pack.pack(\n", + " output=str(env_file_path),\n", + " force=True,\n", + " verbose=True,\n", + " ignore_editable_packages=False,\n", + " ignore_missing_files=True,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "d851890f", + "metadata": {}, + "source": [ + "### Configure `mc` to access the minio service in the local kind cluster\n", + "note: make sure that minio ip is reflected properly below, run `kubectl get service -n minio-system`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e4373b0e", + "metadata": {}, + "outputs": [], + "source": [ + "!mc config host add minio-seldon http://172.18.255.3:9000 minioadmin minioadmin" + ] + }, + { + "cell_type": "markdown", + "id": "0a4d4733", + "metadata": {}, + "source": [ + "### Copy the model artifacts to minio" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7434bf31", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "target_bucket = \"minio-seldon/model\"\n", + "os.system(f\"mc rm --force --recursive {target_bucket}\")\n", + "os.system(f\"mc mb {target_bucket}\")\n", + "os.system(f\"mc cp --recursive {MODEL_DIR} {target_bucket}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "84ca9ee9", + "metadata": {}, + "outputs": [], + "source": [ + "%%writefile ./resources/mlflow_elasticnet_wine_v2.yaml\n", + "apiVersion: machinelearning.seldon.io/v1alpha2\n", + "kind: SeldonDeployment\n", + "metadata:\n", + " name: mlflow\n", + "spec:\n", + " protocol: kfserving # Activate v2 protocol\n", + " name: wines\n", + " predictors:\n", + " - graph:\n", + " children: []\n", + " implementation: MLFLOW_SERVER\n", + " modelUri: s3:/model\n", + " envSecretRefName: seldon-rclone-secret\n", + " name: classifier\n", + " name: default\n", + " replicas: 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a0050f5e", + "metadata": {}, + "outputs": [], + "source": [ + "!kubectl apply -f ./resources/mlflow_elasticnet_wine_v2.yaml" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "20d0891e", + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "!kubectl rollout status deploy/$(kubectl get deploy -l seldon-deployment-id=mlflow -o jsonpath='{.items[0].metadata.name}')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "33ff7b69", + "metadata": {}, + "outputs": [], + "source": [ + "import json\n", + "\n", + "import requests\n", + "\n", + "inference_request = {\n", + " \"parameters\": {\n", + " \"content_type\": \"pd\"\n", + " },\n", + " \"inputs\": [\n", + " {\n", + " \"name\": \"fixed acidity\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [7.4],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"volatile acidity\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [0.7000],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"citric acidity\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [0],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"residual sugar\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [1.9],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"chlorides\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [0.076],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"free sulfur dioxide\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [11],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"total sulfur dioxide\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [34],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"density\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [0.9978],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"pH\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [3.51],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"sulphates\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [0.56],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " {\n", + " \"name\": \"alcohol\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [9.4],\n", + " \"parameters\": {\n", + " \"content_type\": \"np\"\n", + " }\n", + " },\n", + " ]\n", + "}\n", + "\n", + "# note is the local balancer for istion, make sure that the ip is reflected in the setup,\n", + "# run kubectl get service -n istio-system\n", + "endpoint = \"http://172.18.255.1/seldon/seldon/mlflow/v2/models/infer\"\n", + "response = requests.post(endpoint, json=inference_request)\n", + "\n", + "print(json.dumps(response.json(), indent=2))\n", + "assert response.ok" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f82997a8", + "metadata": {}, + "outputs": [], + "source": [ + "!kubectl delete -f ./resources/mlflow_elasticnet_wine_v2.yaml" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d1c9ca28", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.11" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 3f5058eedc47b20157193734ea91e081f80f9607 Mon Sep 17 00:00:00 2001 From: Sherif Akoush Date: Wed, 11 Aug 2021 17:11:35 +0100 Subject: [PATCH 03/10] delete old notebook --- notebooks/mlflow_v2_protocol_end_to_end.ipynb | 1133 ----------------- 1 file changed, 1133 deletions(-) delete mode 100644 notebooks/mlflow_v2_protocol_end_to_end.ipynb diff --git a/notebooks/mlflow_v2_protocol_end_to_end.ipynb b/notebooks/mlflow_v2_protocol_end_to_end.ipynb deleted file mode 100644 index 1390adf0e0..0000000000 --- a/notebooks/mlflow_v2_protocol_end_to_end.ipynb +++ /dev/null @@ -1,1133 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "6812a5fb", - "metadata": {}, - "source": [ - "# MLFlow v2 protocol elasticnet wine example\n", - "\n", - "In this example we are going to build a model using mlflow, pack and deploy it on seldon-core on a local kind cluster" - ] - }, - { - "cell_type": "markdown", - "id": "a842a699", - "metadata": {}, - "source": [ - "Prerequisites:\n", - "\n", - "- install and configure `mc`, follow the relevant section in this [link](https://docs.seldon.io/projects/seldon-core/en/latest/examples/minio_setup.html):\n", - "\n", - "- run this jupyter notebook in conda environment\n", - "```bash\n", - "$ conda create --name python3.8-mlflow-example python=3.8 -y\n", - "$ conda activate python3.8-mlflow-example\n", - "$ pip install jupyter\n", - "$ jupyter notebook\n", - "```" - ] - }, - { - "cell_type": "markdown", - "id": "5d7c94b0", - "metadata": {}, - "source": [ - "## Setup local kind cluster using ansible" - ] - }, - { - "cell_type": "markdown", - "id": "246b23a4", - "metadata": {}, - "source": [ - "### Install ansible prerequisites" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "id": "ef719025", - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Collecting ansible\n", - " Using cached ansible-4.3.0-py3-none-any.whl\n", - "Collecting openshift\n", - " Using cached openshift-0.12.1-py3-none-any.whl\n", - "Requirement already satisfied: docker in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (5.0.0)\n", - "Collecting passlib\n", - " Using cached passlib-1.7.4-py2.py3-none-any.whl (525 kB)\n", - "Collecting ansible-core<2.12,>=2.11.3\n", - " Using cached ansible_core-2.11.3-py3-none-any.whl\n", - "Requirement already satisfied: six in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from openshift) (1.16.0)\n", - "Requirement already satisfied: jinja2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from openshift) (3.0.1)\n", - "Collecting python-string-utils\n", - " Using cached python_string_utils-1.0.0-py3-none-any.whl (26 kB)\n", - "Collecting ruamel.yaml\n", - " Using cached ruamel.yaml-0.17.10-py3-none-any.whl (108 kB)\n", - "Collecting kubernetes~=12.0\n", - " Using cached kubernetes-12.0.1-py2.py3-none-any.whl (1.7 MB)\n", - "Requirement already satisfied: websocket-client>=0.32.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from docker) (1.1.1)\n", - "Requirement already satisfied: requests!=2.18.0,>=2.14.2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from docker) (2.26.0)\n", - "Requirement already satisfied: packaging in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from ansible-core<2.12,>=2.11.3->ansible) (21.0)\n", - "Collecting resolvelib<0.6.0,>=0.5.3\n", - " Using cached resolvelib-0.5.4-py2.py3-none-any.whl (12 kB)\n", - "Collecting cryptography\n", - " Using cached cryptography-3.4.7-cp36-abi3-manylinux2014_x86_64.whl (3.2 MB)\n", - "Requirement already satisfied: PyYAML in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from ansible-core<2.12,>=2.11.3->ansible) (5.4.1)\n", - "Requirement already satisfied: certifi>=14.05.14 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from kubernetes~=12.0->openshift) (2021.5.30)\n", - "Requirement already satisfied: urllib3>=1.24.2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from kubernetes~=12.0->openshift) (1.26.6)\n", - "Requirement already satisfied: python-dateutil>=2.5.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from kubernetes~=12.0->openshift) (2.8.2)\n", - "Collecting google-auth>=1.0.1\n", - " Using cached google_auth-1.34.0-py2.py3-none-any.whl (152 kB)\n", - "Collecting requests-oauthlib\n", - " Using cached requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)\n", - "Requirement already satisfied: setuptools>=21.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from kubernetes~=12.0->openshift) (52.0.0.post20210125)\n", - "Collecting rsa<5,>=3.1.4\n", - " Using cached rsa-4.7.2-py3-none-any.whl (34 kB)\n", - "Collecting cachetools<5.0,>=2.0.0\n", - " Using cached cachetools-4.2.2-py3-none-any.whl (11 kB)\n", - "Collecting pyasn1-modules>=0.2.1\n", - " Using cached pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)\n", - "Collecting pyasn1<0.5.0,>=0.4.6\n", - " Using cached pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)\n", - "Requirement already satisfied: charset-normalizer~=2.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests!=2.18.0,>=2.14.2->docker) (2.0.4)\n", - "Requirement already satisfied: idna<4,>=2.5 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests!=2.18.0,>=2.14.2->docker) (3.2)\n", - "Requirement already satisfied: cffi>=1.12 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from cryptography->ansible-core<2.12,>=2.11.3->ansible) (1.14.6)\n", - "Requirement already satisfied: pycparser in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from cffi>=1.12->cryptography->ansible-core<2.12,>=2.11.3->ansible) (2.20)\n", - "Requirement already satisfied: MarkupSafe>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from jinja2->openshift) (2.0.1)\n", - "Requirement already satisfied: pyparsing>=2.0.2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from packaging->ansible-core<2.12,>=2.11.3->ansible) (2.4.7)\n", - "Collecting oauthlib>=3.0.0\n", - " Using cached oauthlib-3.1.1-py2.py3-none-any.whl (146 kB)\n", - "Collecting ruamel.yaml.clib>=0.1.2\n", - " Using cached ruamel.yaml.clib-0.2.6-cp38-cp38-manylinux1_x86_64.whl (570 kB)\n", - "Installing collected packages: pyasn1, rsa, pyasn1-modules, oauthlib, cachetools, ruamel.yaml.clib, resolvelib, requests-oauthlib, google-auth, cryptography, ruamel.yaml, python-string-utils, kubernetes, ansible-core, passlib, openshift, ansible\n", - "Successfully installed ansible-4.3.0 ansible-core-2.11.3 cachetools-4.2.2 cryptography-3.4.7 google-auth-1.34.0 kubernetes-12.0.1 oauthlib-3.1.1 openshift-0.12.1 passlib-1.7.4 pyasn1-0.4.8 pyasn1-modules-0.2.8 python-string-utils-1.0.0 requests-oauthlib-1.3.0 resolvelib-0.5.4 rsa-4.7.2 ruamel.yaml-0.17.10 ruamel.yaml.clib-0.2.6\n" - ] - } - ], - "source": [ - "!pip install ansible openshift docker passlib" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "id": "f6e0d020", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Cloning into '/home/sa/.ansible/tmp/ansible-local-3444016e_43ifbj/tmpl593c8ki/ansible-k8s-collectiongefpw6fb'...\n", - "remote: Enumerating objects: 676, done.\u001b[K\n", - "remote: Counting objects: 100% (676/676), done.\u001b[K\n", - "remote: Compressing objects: 100% (417/417), done.\u001b[K\n", - "remote: Total 676 (delta 282), reused 536 (delta 166), pack-reused 0\u001b[K\n", - "Receiving objects: 100% (676/676), 277.25 KiB | 2.50 MiB/s, done.\n", - "Resolving deltas: 100% (282/282), done.\n", - "Your branch is up-to-date with 'origin/master'.\n", - "Starting galaxy collection install process\n", - "Process install dependency map\n", - "Starting collection install process\n", - "Installing 'seldonio.k8s:0.3.0-dev' to '/home/sa/.ansible/collections/ansible_collections/seldonio/k8s'\n", - "Created collection for seldonio.k8s:0.3.0-dev at /home/sa/.ansible/collections/ansible_collections/seldonio/k8s\n", - "seldonio.k8s:0.3.0-dev was installed successfully\n", - "Skipping 'kubernetes.core:2.1.1' as it is already installed\n", - "Skipping 'community.docker:1.9.0' as it is already installed\n", - "Skipping 'community.crypto:1.7.1' as it is already installed\n" - ] - } - ], - "source": [ - "!ansible-galaxy collection install git+https://github.com/SeldonIO/ansible-k8s-collection.git" - ] - }, - { - "cell_type": "markdown", - "id": "f9f3501f", - "metadata": {}, - "source": [ - "### Setup kind cluster and install seldon-core" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "id": "f4d2f264", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "PLAY [Create Kind Cluster and Install MetalLB] *********************************\n", - "\n", - "TASK [seldonio.k8s.kind : Check if Kind v0.11.1 already downloaded] ************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Create .resources directory if does not exist: /home/sa/code/seldon-core/ansible/.resources/] ***\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Download Kind v0.11.1 binary] ************************\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Make Kind v0.11.1 binary executable] *****************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Check if KinD Cluster already exists: ansible] *******\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Start KinD Cluster: 'ansible'] ***********************\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Echo output of \"kind create cluster ...\" command] ****\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Export kubeconfig for KinD Cluster: 'ansible'] *******\n", - "changed: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Create a k8s namespace: seldon] **********************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Set default for kubectl namespace: seldon] ***********\n", - "changed: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Download metrics-server manifest.] *******************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Modify the manifest to allow insecure TLS for testing.] ***\n", - "ok: [localhost] => (item=kubelet-preferred-address-types=InternalIP)\n", - "ok: [localhost] => (item=kubelet-insecure-tls)\n", - "\n", - "TASK [seldonio.k8s.kind : Deploy metrics-server into the cluster.] *************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.metallb : Get information about kind network in docker.] ****\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.metallb : Extract subnet of kind network] *******************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.metallb : Set ranges for MetalLB] ***************************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.metallb : Echo message about kind network 2] ****************\n", - "ok: [localhost] => {\n", - " \"msg\": [\n", - " \"metallb_range_start: 172.18.255.1\",\n", - " \"metallb_range_stop: 172.18.255.255\"\n", - " ]\n", - "}\n", - "\n", - "TASK [seldonio.k8s.metallb : Deploy MetalLB] ***********************************\n", - "ok: [localhost] => (item=https://raw.githubusercontent.com/metallb/metallb/v0.10.2/manifests/namespace.yaml)\n", - "ok: [localhost] => (item=https://raw.githubusercontent.com/metallb/metallb/v0.10.2/manifests/metallb.yaml)\n", - "\n", - "TASK [seldonio.k8s.metallb : Create OpenSSL secretkey] *************************\n", - "changed: [localhost]\n", - "\n", - "TASK [seldonio.k8s.metallb : Create memberlist secret] *************************\n", - "changed: [localhost]\n", - "\n", - "TASK [seldonio.k8s.metallb : Create MetalLB Config] ****************************\n", - "ok: [localhost]\n", - "\n", - "PLAY RECAP *********************************************************************\n", - "localhost : ok=18 changed=4 unreachable=0 failed=0 skipped=3 rescued=0 ignored=0 \n", - "\n", - "\n", - "PLAY [Install Seldon Core & Prerequisites] *************************************\n", - "\n", - "TASK [Load vars from vars/default.yaml] ****************************************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Check if Istio 1.10.3 already downloaded.] **********\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Create .resources directory if does not exist: /home/sa/code/seldon-core/ansible/.resources/] ***\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Download Istio 1.10.3] ******************************\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Install Istio 1.10.3] *******************************\n", - "changed: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Verify Install Istio 1.10.3] ************************\n", - "changed: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Create Seldon Gateway] ******************************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Wait for External IP Address to be ready] ***********\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Set fact about Istio Ingress Gateway External IP] ***\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Create temporary certificates directory] ************\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Generate CA Private Key with RSA 2048] **************\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Generate CA CSR] ************************************\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Generate CA Self Signed Certificate] ****************\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Generate Server OpenSSL private key with RSA 2048] ***\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Generate an OpenSSL Certificate Signing Request for server] ***\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Generate an OpenSSL certificate from the server CSR signed with our CA certificate] ***\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Set fact about Server SSL Certs Paths] **************\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Create Istio Ingressgateway SSL Certs Secret] *******\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Remove temporary certificates directory] ************\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.ambassador : Create a k8s namespace: ambassador] ************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.ambassador : Install ambassador] ****************************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.minio : Create a k8s namespaces] ****************************\n", - "ok: [localhost] => (item=minio-system)\n", - "ok: [localhost] => (item=seldon)\n", - "\n", - "TASK [seldonio.k8s.minio : Install MinIO] **************************************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.minio : Echo message about client configuration] ************\n", - "ok: [localhost] => {\n", - " \"msg\": [\n", - " \"MinIO installed in the cluster. To configure your local client launch\",\n", - " \"kubectl port-forward -n minio-system svc/minio 8090:9000\",\n", - " \"in one terminal and execute\",\n", - " \"mc config host add minio-seldon http://localhost:8090 ACCESS_KEY SECRET_KEY\"\n", - " ]\n", - "}\n", - "\n", - "TASK [seldonio.k8s.minio : Configure Minio VirtualService] *********************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.minio : Create MinIO Secret (rclone storage initializer format)] ***\n", - "ok: [localhost] => (item=seldon)\n", - "\n", - "TASK [seldonio.k8s.minio : Create MinIO Secret (kfserving storage initializer format)] ***\n", - "ok: [localhost] => (item=seldon)\n", - "\n", - "TASK [seldonio.k8s.seldon_core_analytics : Create a seldon-system namespaces] ***\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.seldon_core_analytics : Create Extra Resources from Templates] ***\n", - "\n", - "TASK [seldonio.k8s.seldon_core_analytics : Install Seldon Core Analytics] ******\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.seldon_core_analytics : Wait for Seldon Core Analytics Deployments] ***\n", - "ok: [localhost] => (item=seldon-core-analytics-grafana)\n", - "ok: [localhost] => (item=seldon-core-analytics-kube-state-metrics)\n", - "ok: [localhost] => (item=seldon-core-analytics-prometheus-alertmanager)\n", - "ok: [localhost] => (item=seldon-core-analytics-prometheus-pushgateway)\n", - "ok: [localhost] => (item=seldon-core-analytics-prometheus-seldon)\n", - "\n", - "TASK [seldonio.k8s.seldon_core : Create a k8s namespaces] **********************\n", - "ok: [localhost] => (item=seldon-system)\n", - "ok: [localhost] => (item=seldon)\n", - "\n", - "TASK [seldonio.k8s.seldon_core : Git clone Seldon Core repo and checkout master] ***\n", - "changed: [localhost]\n", - "\n", - "TASK [seldonio.k8s.seldon_core : Set Seldon Core Directory] ********************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.seldon_core : Deploy Seldon Core] ***************************\n", - "changed: [localhost]\n", - "\n", - "TASK [seldonio.k8s.seldon_core : Wait for Seldon Core deployments] *************\n", - "ok: [localhost] => (item=seldon-controller-manager)\n", - "\n", - "PLAY RECAP *********************************************************************\n", - "localhost : ok=22 changed=4 unreachable=0 failed=0 skipped=14 rescued=0 ignored=0 \n", - "\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "[WARNING]: The default idempotency check can fail to report changes in certain\n", - "cases. Install helm diff for better results.\n" - ] - } - ], - "source": [ - "%%bash\n", - "cd ../ansible\n", - "ansible-playbook playbooks/kind_cluster.yaml\n", - "ansible-playbook playbooks/main.yaml -e seldon_core_version=master " - ] - }, - { - "cell_type": "markdown", - "id": "144577cf", - "metadata": {}, - "source": [ - "## Train elasticnet wine model using `mlflow`" - ] - }, - { - "cell_type": "markdown", - "id": "a48e09c8", - "metadata": {}, - "source": [ - "### Install `mlflow` and required dependencies to train the model" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "65d444af", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Requirement already satisfied: mlflow in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (1.19.0)\n", - "Requirement already satisfied: scikit-learn==0.23.2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (0.23.2)\n", - "Requirement already satisfied: pandas in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (1.3.1)\n", - "Collecting conda-pack\n", - " Using cached conda_pack-0.6.0-py2.py3-none-any.whl\n", - "Requirement already satisfied: scipy>=0.19.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from scikit-learn==0.23.2) (1.7.1)\n", - "Requirement already satisfied: numpy>=1.13.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from scikit-learn==0.23.2) (1.21.1)\n", - "Requirement already satisfied: threadpoolctl>=2.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from scikit-learn==0.23.2) (2.2.0)\n", - "Requirement already satisfied: joblib>=0.11 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from scikit-learn==0.23.2) (1.0.1)\n", - "Requirement already satisfied: cloudpickle in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (1.6.0)\n", - "Requirement already satisfied: alembic<=1.4.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (1.4.1)\n", - "Requirement already satisfied: packaging in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (21.0)\n", - "Requirement already satisfied: Flask in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (2.0.1)\n", - "Requirement already satisfied: entrypoints in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (0.3)\n", - "Requirement already satisfied: pyyaml>=5.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (5.4.1)\n", - "Requirement already satisfied: querystring-parser in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (1.2.4)\n", - "Requirement already satisfied: sqlalchemy in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (1.4.22)\n", - "Requirement already satisfied: sqlparse>=0.3.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (0.4.1)\n", - "Requirement already satisfied: docker>=4.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (5.0.0)\n", - "Requirement already satisfied: gitpython>=2.1.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (3.1.18)\n", - "Requirement already satisfied: click>=7.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (8.0.1)\n", - "Requirement already satisfied: pytz in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (2021.1)\n", - "Requirement already satisfied: protobuf>=3.7.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (3.17.3)\n", - "Requirement already satisfied: prometheus-flask-exporter in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (0.18.2)\n", - "Requirement already satisfied: requests>=2.17.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (2.26.0)\n", - "Requirement already satisfied: gunicorn in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (20.1.0)\n", - "Requirement already satisfied: databricks-cli>=0.8.7 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (0.15.0)\n", - "Requirement already satisfied: python-dateutil>=2.7.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from pandas) (2.8.2)\n", - "Requirement already satisfied: setuptools in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from conda-pack) (52.0.0.post20210125)\n", - "Requirement already satisfied: python-editor>=0.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from alembic<=1.4.1->mlflow) (1.0.4)\n", - "Requirement already satisfied: Mako in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from alembic<=1.4.1->mlflow) (1.1.4)\n", - "Requirement already satisfied: tabulate>=0.7.7 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from databricks-cli>=0.8.7->mlflow) (0.8.9)\n", - "Requirement already satisfied: six>=1.10.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from databricks-cli>=0.8.7->mlflow) (1.16.0)\n", - "Requirement already satisfied: websocket-client>=0.32.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from docker>=4.0.0->mlflow) (1.1.1)\n", - "Requirement already satisfied: gitdb<5,>=4.0.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from gitpython>=2.1.0->mlflow) (4.0.7)\n", - "Requirement already satisfied: smmap<5,>=3.0.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from gitdb<5,>=4.0.1->gitpython>=2.1.0->mlflow) (4.0.0)\n", - "Requirement already satisfied: charset-normalizer~=2.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow) (2.0.4)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow) (2021.5.30)\n", - "Requirement already satisfied: idna<4,>=2.5 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow) (3.2)\n", - "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow) (1.26.6)\n", - "Requirement already satisfied: greenlet!=0.4.17 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from sqlalchemy->mlflow) (1.1.1)\n", - "Requirement already satisfied: itsdangerous>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Flask->mlflow) (2.0.1)\n", - "Requirement already satisfied: Werkzeug>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Flask->mlflow) (2.0.1)\n", - "Requirement already satisfied: Jinja2>=3.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Flask->mlflow) (3.0.1)\n", - "Requirement already satisfied: MarkupSafe>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Jinja2>=3.0->Flask->mlflow) (2.0.1)\n", - "Requirement already satisfied: pyparsing>=2.0.2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from packaging->mlflow) (2.4.7)\n", - "Requirement already satisfied: prometheus-client in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from prometheus-flask-exporter->mlflow) (0.11.0)\n", - "Installing collected packages: conda-pack\n", - "Successfully installed conda-pack-0.6.0\n" - ] - } - ], - "source": [ - "!pip install mlflow scikit-learn==0.23.2 pandas" - ] - }, - { - "cell_type": "markdown", - "id": "3176a423", - "metadata": {}, - "source": [ - "### Define where the model artifacts will be saved" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "b66ccdff", - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "from pathlib import Path\n", - "MODEL_DIR = Path(os.getcwd()) / \"elasticnet_wine_model\"" - ] - }, - { - "cell_type": "markdown", - "id": "a3dfcc20", - "metadata": {}, - "source": [ - "### Define training" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "57f8a675", - "metadata": {}, - "outputs": [], - "source": [ - "# Wine Quality Sample a copy from: \n", - "# https://github.com/mlflow/mlflow/blob/master/examples/sklearn_elasticnet_wine/train.ipynb\n", - "\n", - "def train(in_alpha, in_l1_ratio):\n", - " import os\n", - " import warnings\n", - " import sys\n", - "\n", - " import pandas as pd\n", - " import numpy as np\n", - " from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score\n", - " from sklearn.model_selection import train_test_split\n", - " from sklearn.linear_model import ElasticNet\n", - "\n", - " import mlflow\n", - " import mlflow.sklearn\n", - " \n", - " import logging\n", - " logging.basicConfig(level=logging.WARN)\n", - " logger = logging.getLogger(__name__)\n", - "\n", - " def eval_metrics(actual, pred):\n", - " rmse = np.sqrt(mean_squared_error(actual, pred))\n", - " mae = mean_absolute_error(actual, pred)\n", - " r2 = r2_score(actual, pred)\n", - " return rmse, mae, r2\n", - "\n", - "\n", - " warnings.filterwarnings(\"ignore\")\n", - " np.random.seed(40)\n", - "\n", - " # Read the wine-quality csv file from the URL\n", - " csv_url =\\\n", - " 'http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv'\n", - " try:\n", - " data = pd.read_csv(csv_url, sep=';')\n", - " except Exception as e:\n", - " logger.exception(\n", - " \"Unable to download training & test CSV, check your internet connection. Error: %s\", e)\n", - "\n", - " # Split the data into training and test sets. (0.75, 0.25) split.\n", - " train, test = train_test_split(data)\n", - "\n", - " # The predicted column is \"quality\" which is a scalar from [3, 9]\n", - " train_x = train.drop([\"quality\"], axis=1)\n", - " test_x = test.drop([\"quality\"], axis=1)\n", - " train_y = train[[\"quality\"]]\n", - " test_y = test[[\"quality\"]]\n", - "\n", - " # Set default values if no alpha is provided\n", - " if float(in_alpha) is None:\n", - " alpha = 0.5\n", - " else:\n", - " alpha = float(in_alpha)\n", - "\n", - " # Set default values if no l1_ratio is provided\n", - " if float(in_l1_ratio) is None:\n", - " l1_ratio = 0.5\n", - " else:\n", - " l1_ratio = float(in_l1_ratio)\n", - "\n", - " # Useful for multiple runs (only doing one run in this sample notebook) \n", - " with mlflow.start_run():\n", - " # Execute ElasticNet\n", - " lr = ElasticNet(alpha=alpha, l1_ratio=l1_ratio, random_state=42)\n", - " lr.fit(train_x, train_y)\n", - "\n", - " # Evaluate Metrics\n", - " predicted_qualities = lr.predict(test_x)\n", - " (rmse, mae, r2) = eval_metrics(test_y, predicted_qualities)\n", - "\n", - " # Print out metrics\n", - " print(\"Elasticnet model (alpha=%f, l1_ratio=%f):\" % (alpha, l1_ratio))\n", - " print(\" RMSE: %s\" % rmse)\n", - " print(\" MAE: %s\" % mae)\n", - " print(\" R2: %s\" % r2)\n", - "\n", - " # Log parameter, metrics, and model to MLflow\n", - " mlflow.log_param(\"alpha\", alpha)\n", - " mlflow.log_param(\"l1_ratio\", l1_ratio)\n", - " mlflow.log_metric(\"rmse\", rmse)\n", - " mlflow.log_metric(\"r2\", r2)\n", - " mlflow.log_metric(\"mae\", mae)\n", - "\n", - " mlflow.sklearn.save_model(lr, MODEL_DIR)\n", - " print(f\" Model saved to {MODEL_DIR}\")" - ] - }, - { - "cell_type": "markdown", - "id": "cfde8513", - "metadata": {}, - "source": [ - "### Train the elasticnet_wine model" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "33f84e54", - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Elasticnet model (alpha=0.500000, l1_ratio=0.500000):\n", - " RMSE: 0.7931640229276851\n", - " MAE: 0.6271946374319587\n", - " R2: 0.10862644997792614\n", - " Model saved to /home/sa/code/seldon-core/notebooks/elasticnet_wine_model\n" - ] - } - ], - "source": [ - "train(0.5, 0.5)" - ] - }, - { - "cell_type": "markdown", - "id": "dd308902", - "metadata": {}, - "source": [ - "### Install dependencies to be able to pack and deploy the model on `seldon_core`" - ] - }, - { - "cell_type": "markdown", - "id": "b477787e", - "metadata": {}, - "source": [ - "We are going to use [`conda-pack`](https://conda.github.io/conda-pack/) to pack the python enviornment. We also need `mlserver` dependencies.\n", - "We are planning to simplify this workflow in future releases." - ] - }, - { - "cell_type": "code", - "execution_count": 60, - "id": "00aeeccb", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Requirement already satisfied: conda-pack in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (0.6.0)\n", - "Collecting mlserver==0.4.0\n", - " Using cached mlserver-0.4.0-py3-none-any.whl (61 kB)\n", - "Collecting mlserver-mlflow==0.4.0\n", - " Using cached mlserver_mlflow-0.4.0-py3-none-any.whl (8.3 kB)\n", - "Collecting uvicorn\n", - " Using cached uvicorn-0.14.0-py3-none-any.whl (50 kB)\n", - "Collecting orjson\n", - " Using cached orjson-3.6.1-cp38-cp38-manylinux_2_24_x86_64.whl (233 kB)\n", - "Requirement already satisfied: pandas in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlserver==0.4.0) (1.3.1)\n", - "Collecting fastapi\n", - " Using cached fastapi-0.68.0-py3-none-any.whl (52 kB)\n", - "Requirement already satisfied: protobuf in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlserver==0.4.0) (3.17.3)\n", - "Requirement already satisfied: numpy in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlserver==0.4.0) (1.21.1)\n", - "Requirement already satisfied: click in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlserver==0.4.0) (8.0.1)\n", - "Collecting grpcio\n", - " Using cached grpcio-1.39.0-cp38-cp38-manylinux2014_x86_64.whl (4.3 MB)\n", - "Requirement already satisfied: mlflow in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlserver-mlflow==0.4.0) (1.19.0)\n", - "Requirement already satisfied: setuptools in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from conda-pack) (52.0.0.post20210125)\n", - "Collecting starlette==0.14.2\n", - " Using cached starlette-0.14.2-py3-none-any.whl (60 kB)\n", - "Collecting pydantic!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0,>=1.6.2\n", - " Using cached pydantic-1.8.2-cp38-cp38-manylinux2014_x86_64.whl (13.7 MB)\n", - "Collecting typing-extensions>=3.7.4.3\n", - " Using cached typing_extensions-3.10.0.0-py3-none-any.whl (26 kB)\n", - "Requirement already satisfied: six>=1.5.2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from grpcio->mlserver==0.4.0) (1.16.0)\n", - "Requirement already satisfied: prometheus-flask-exporter in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (0.18.2)\n", - "Requirement already satisfied: sqlparse>=0.3.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (0.4.1)\n", - "Requirement already satisfied: sqlalchemy in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (1.4.22)\n", - "Requirement already satisfied: pyyaml>=5.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (5.4.1)\n", - "Requirement already satisfied: docker>=4.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (5.0.0)\n", - "Requirement already satisfied: querystring-parser in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (1.2.4)\n", - "Requirement already satisfied: gunicorn in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (20.1.0)\n", - "Requirement already satisfied: cloudpickle in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (1.6.0)\n", - "Requirement already satisfied: packaging in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (21.0)\n", - "Requirement already satisfied: requests>=2.17.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (2.26.0)\n", - "Requirement already satisfied: databricks-cli>=0.8.7 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (0.15.0)\n", - "Requirement already satisfied: pytz in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (2021.1)\n", - "Requirement already satisfied: Flask in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (2.0.1)\n", - "Requirement already satisfied: alembic<=1.4.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (1.4.1)\n", - "Requirement already satisfied: gitpython>=2.1.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (3.1.18)\n", - "Requirement already satisfied: entrypoints in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow->mlserver-mlflow==0.4.0) (0.3)\n", - "Requirement already satisfied: python-dateutil in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from alembic<=1.4.1->mlflow->mlserver-mlflow==0.4.0) (2.8.2)\n", - "Requirement already satisfied: Mako in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from alembic<=1.4.1->mlflow->mlserver-mlflow==0.4.0) (1.1.4)\n", - "Requirement already satisfied: python-editor>=0.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from alembic<=1.4.1->mlflow->mlserver-mlflow==0.4.0) (1.0.4)\n", - "Requirement already satisfied: tabulate>=0.7.7 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from databricks-cli>=0.8.7->mlflow->mlserver-mlflow==0.4.0) (0.8.9)\n", - "Requirement already satisfied: websocket-client>=0.32.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from docker>=4.0.0->mlflow->mlserver-mlflow==0.4.0) (1.1.1)\n", - "Requirement already satisfied: gitdb<5,>=4.0.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from gitpython>=2.1.0->mlflow->mlserver-mlflow==0.4.0) (4.0.7)\n", - "Requirement already satisfied: smmap<5,>=3.0.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from gitdb<5,>=4.0.1->gitpython>=2.1.0->mlflow->mlserver-mlflow==0.4.0) (4.0.0)\n", - "Requirement already satisfied: charset-normalizer~=2.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow->mlserver-mlflow==0.4.0) (2.0.4)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow->mlserver-mlflow==0.4.0) (2021.5.30)\n", - "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow->mlserver-mlflow==0.4.0) (1.26.6)\n", - "Requirement already satisfied: idna<4,>=2.5 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow->mlserver-mlflow==0.4.0) (3.2)\n", - "Requirement already satisfied: greenlet!=0.4.17 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from sqlalchemy->mlflow->mlserver-mlflow==0.4.0) (1.1.1)\n", - "Requirement already satisfied: itsdangerous>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Flask->mlflow->mlserver-mlflow==0.4.0) (2.0.1)\n", - "Requirement already satisfied: Jinja2>=3.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Flask->mlflow->mlserver-mlflow==0.4.0) (3.0.1)\n", - "Requirement already satisfied: Werkzeug>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Flask->mlflow->mlserver-mlflow==0.4.0) (2.0.1)\n", - "Requirement already satisfied: MarkupSafe>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Jinja2>=3.0->Flask->mlflow->mlserver-mlflow==0.4.0) (2.0.1)\n", - "Requirement already satisfied: pyparsing>=2.0.2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from packaging->mlflow->mlserver-mlflow==0.4.0) (2.4.7)\n", - "Requirement already satisfied: prometheus-client in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from prometheus-flask-exporter->mlflow->mlserver-mlflow==0.4.0) (0.11.0)\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Collecting asgiref>=3.3.4\n", - " Using cached asgiref-3.4.1-py3-none-any.whl (25 kB)\n", - "Collecting h11>=0.8\n", - " Using cached h11-0.12.0-py3-none-any.whl (54 kB)\n", - "Installing collected packages: typing-extensions, starlette, pydantic, h11, asgiref, uvicorn, orjson, grpcio, fastapi, mlserver, mlserver-mlflow\n", - "Successfully installed asgiref-3.4.1 fastapi-0.68.0 grpcio-1.39.0 h11-0.12.0 mlserver-0.4.0 mlserver-mlflow-0.4.0 orjson-3.6.1 pydantic-1.8.2 starlette-0.14.2 typing-extensions-3.10.0.0 uvicorn-0.14.0\n" - ] - } - ], - "source": [ - "!pip install conda-pack mlserver==0.4.0 mlserver-mlflow==0.4.0" - ] - }, - { - "cell_type": "markdown", - "id": "9cc9cb95", - "metadata": {}, - "source": [ - "### Pack the conda enviornment" - ] - }, - { - "cell_type": "code", - "execution_count": 61, - "id": "0fbfe38f", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Collecting packages...\n", - "Packing environment at '/home/sa/miniconda3/envs/python3.8-mlflow-example' to '/home/sa/code/seldon-core/notebooks/elasticnet_wine_model/environment.tar.gz'\n", - "[########################################] | 100% Completed | 42.9s\n" - ] - }, - { - "data": { - "text/plain": [ - "'/home/sa/code/seldon-core/notebooks/elasticnet_wine_model/environment.tar.gz'" - ] - }, - "execution_count": 61, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "import conda_pack\n", - "env_file_path = MODEL_DIR / \"environment.tar.gz\"\n", - "conda_pack.pack(\n", - " output=str(env_file_path),\n", - " force=True,\n", - " verbose=True,\n", - " ignore_editable_packages=False,\n", - " ignore_missing_files=True,\n", - ")" - ] - }, - { - "cell_type": "markdown", - "id": "17652087", - "metadata": {}, - "source": [ - "### Configure `mc` to access the minio service in the local kind cluster\n", - "note: make sure that minio ip is reflected properly below, run `kubectl get service -n minio-system`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "3a4834e2", - "metadata": {}, - "outputs": [], - "source": [ - "!mc config host add minio-seldon http://172.18.255.3:9000 minioadmin minioadmin" - ] - }, - { - "cell_type": "markdown", - "id": "35963189", - "metadata": {}, - "source": [ - "### Copy the model artifacts to minio" - ] - }, - { - "cell_type": "code", - "execution_count": 75, - "id": "6913d557", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Removing `minio-seldon/model/MLmodel`.\n", - "Removing `minio-seldon/model/conda.yaml`.\n", - "Removing `minio-seldon/model/environment.tar.gz`.\n", - "Removing `minio-seldon/model/model.pkl`.\n", - "Removing `minio-seldon/model/requirements.txt`.\n", - "`/home/sa/code/seldon-core/notebooks/elasticnet_wine_model/environment.tar.gz` -> `minio-seldon/model/elasticnet_wine_model/environment.tar.gz`\n", - "`/home/sa/code/seldon-core/notebooks/elasticnet_wine_model/model.pkl` -> `minio-seldon/model/elasticnet_wine_model/model.pkl`\n", - "`/home/sa/code/seldon-core/notebooks/elasticnet_wine_model/requirements.txt` -> `minio-seldon/model/elasticnet_wine_model/requirements.txt`\n", - "`/home/sa/code/seldon-core/notebooks/elasticnet_wine_model/conda.yaml` -> `minio-seldon/model/elasticnet_wine_model/conda.yaml`\n", - "`/home/sa/code/seldon-core/notebooks/elasticnet_wine_model/MLmodel` -> `minio-seldon/model/elasticnet_wine_model/MLmodel`\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "mc: Unable to make bucket `minio-seldon/model`. Your previous request to create the named bucket succeeded and you already own it.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total: 0 B, Transferred: 322.90 MiB, Speed: 469.47 MiB/s\n" - ] - }, - { - "data": { - "text/plain": [ - "0" - ] - }, - "execution_count": 75, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "import os\n", - "os.system(\"mc mb minio-seldon/model\")\n", - "os.system(f\"mc cp --recursive {MODEL_DIR} minio-seldon/model\")" - ] - }, - { - "cell_type": "code", - "execution_count": 63, - "id": "48611bc4", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Overwriting ./resources/elasticnet_wine_v2.yaml\n" - ] - } - ], - "source": [ - "%%writefile ./resources/mlflow_elasticnet_wine_v2.yaml\n", - "apiVersion: machinelearning.seldon.io/v1alpha2\n", - "kind: SeldonDeployment\n", - "metadata:\n", - " name: mlflow\n", - "spec:\n", - " protocol: kfserving # Activate v2 protocol\n", - " name: wines\n", - " predictors:\n", - " - graph:\n", - " children: []\n", - " implementation: MLFLOW_SERVER\n", - " modelUri: s3:/model\n", - " envSecretRefName: seldon-rclone-secret\n", - " name: classifier\n", - " name: default\n", - " replicas: 1" - ] - }, - { - "cell_type": "code", - "execution_count": 66, - "id": "38416d92", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "seldondeployment.machinelearning.seldon.io/mlflow created\r\n" - ] - } - ], - "source": [ - "!kubectl apply -f ./resources/mlflow_elasticnet_wine_v2.yaml" - ] - }, - { - "cell_type": "code", - "execution_count": 68, - "id": "2ccecb6e", - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "deployment \"mlflow-default-0-classifier\" successfully rolled out\r\n" - ] - } - ], - "source": [ - "!kubectl rollout status deploy/$(kubectl get deploy -l seldon-deployment-id=mlflow -o jsonpath='{.items[0].metadata.name}')" - ] - }, - { - "cell_type": "code", - "execution_count": 73, - "id": "a5e529b5", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{\n", - " \"model_name\": \"classifier\",\n", - " \"model_version\": \"v1\",\n", - " \"id\": \"1b0648b3-b7ad-426f-9d37-395ab441b179\",\n", - " \"parameters\": null,\n", - " \"outputs\": [\n", - " {\n", - " \"name\": \"predict\",\n", - " \"shape\": [\n", - " 1\n", - " ],\n", - " \"datatype\": \"FP64\",\n", - " \"parameters\": null,\n", - " \"data\": [\n", - " 5.576883936610762\n", - " ]\n", - " }\n", - " ]\n", - "}\n" - ] - } - ], - "source": [ - "import json\n", - "\n", - "import requests\n", - "\n", - "inference_request = {\n", - " \"parameters\": {\n", - " \"content_type\": \"pd\"\n", - " },\n", - " \"inputs\": [\n", - " {\n", - " \"name\": \"fixed acidity\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [7.4],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", - " },\n", - " {\n", - " \"name\": \"volatile acidity\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [0.7000],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", - " },\n", - " {\n", - " \"name\": \"citric acidity\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [0],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", - " },\n", - " {\n", - " \"name\": \"residual sugar\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [1.9],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", - " },\n", - " {\n", - " \"name\": \"chlorides\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [0.076],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", - " },\n", - " {\n", - " \"name\": \"free sulfur dioxide\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [11],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", - " },\n", - " {\n", - " \"name\": \"total sulfur dioxide\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [34],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", - " },\n", - " {\n", - " \"name\": \"density\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [0.9978],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", - " },\n", - " {\n", - " \"name\": \"pH\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [3.51],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", - " },\n", - " {\n", - " \"name\": \"sulphates\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [0.56],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", - " },\n", - " {\n", - " \"name\": \"alcohol\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [9.4],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", - " },\n", - " ]\n", - "}\n", - "\n", - "# note is the local balancer for istion, make sure that the ip is reflected in the setup,\n", - "# run kubectl get service -n istio-system\n", - "endpoint = \"http://172.18.255.1/seldon/seldon/mlflow/v2/models/infer\"\n", - "response = requests.post(endpoint, json=inference_request)\n", - "\n", - "print(json.dumps(response.json(), indent=2))\n", - "assert response.ok" - ] - }, - { - "cell_type": "code", - "execution_count": 65, - "id": "f04b56c3", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "seldondeployment.machinelearning.seldon.io \"mlflow\" deleted\r\n" - ] - } - ], - "source": [ - "!kubectl delete -f ./resources/mlflow_elasticnet_wine_v2.yaml" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "7dfe0f11", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.11" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} From 8f02e7317e8070e4bade39e6409de5b3c83b596c Mon Sep 17 00:00:00 2001 From: Sherif Akoush Date: Wed, 11 Aug 2021 17:20:54 +0100 Subject: [PATCH 04/10] fix link in file --- .../examples/mlflow_v2_protocol_end_to_end.nblink | 2 +- .../mlflow_v2_protocol_end_to_end.ipynb | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/doc/source/examples/mlflow_v2_protocol_end_to_end.nblink b/doc/source/examples/mlflow_v2_protocol_end_to_end.nblink index 2b27af462d..58ffb3e891 100644 --- a/doc/source/examples/mlflow_v2_protocol_end_to_end.nblink +++ b/doc/source/examples/mlflow_v2_protocol_end_to_end.nblink @@ -1,3 +1,3 @@ { - "path": "../../../examples/models/mlflow_v2_protocol_end_to_end.ipynb", + "path": "../../../examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb" } diff --git a/examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb b/examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb index 28f8aa38f4..d616fac4e1 100644 --- a/examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb +++ b/examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb @@ -5,7 +5,7 @@ "id": "6812a5fb", "metadata": {}, "source": [ - "# MLFlow v2 protocol elasticnet wine example\n", + "# MLflow v2 protocol elasticnet wine example\n", "\n", "In this example we are going to build a model using mlflow, pack and deploy it on seldon-core on a local kind cluster" ] @@ -534,14 +534,6 @@ "source": [ "!kubectl delete -f ./resources/mlflow_elasticnet_wine_v2.yaml" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "d1c9ca28", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { From 3d327785814bca42c0319c8edb88abec93fd3f80 Mon Sep 17 00:00:00 2001 From: Sherif Akoush Date: Wed, 11 Aug 2021 17:29:43 +0100 Subject: [PATCH 05/10] fixes to the notebook --- .../mlflow_v2_protocol_end_to_end.ipynb | 374 +++++++++++++++++- 1 file changed, 358 insertions(+), 16 deletions(-) diff --git a/examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb b/examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb index d616fac4e1..f740ed5261 100644 --- a/examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb +++ b/examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb @@ -76,13 +76,230 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "f4d2f264", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "PLAY [Create Kind Cluster and Install MetalLB] *********************************\n", + "\n", + "TASK [seldonio.k8s.kind : Check if Kind v0.11.1 already downloaded] ************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Create .resources directory if does not exist: /home/sa/code/seldon-core/ansible/.resources/] ***\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Download Kind v0.11.1 binary] ************************\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Make Kind v0.11.1 binary executable] *****************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Check if KinD Cluster already exists: ansible] *******\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Start KinD Cluster: 'ansible'] ***********************\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Echo output of \"kind create cluster ...\" command] ****\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Export kubeconfig for KinD Cluster: 'ansible'] *******\n", + "changed: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Create a k8s namespace: seldon] **********************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Set default for kubectl namespace: seldon] ***********\n", + "changed: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Download metrics-server manifest.] *******************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.kind : Modify the manifest to allow insecure TLS for testing.] ***\n", + "ok: [localhost] => (item=kubelet-preferred-address-types=InternalIP)\n", + "ok: [localhost] => (item=kubelet-insecure-tls)\n", + "\n", + "TASK [seldonio.k8s.kind : Deploy metrics-server into the cluster.] *************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.metallb : Get information about kind network in docker.] ****\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.metallb : Extract subnet of kind network] *******************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.metallb : Set ranges for MetalLB] ***************************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.metallb : Echo message about kind network 2] ****************\n", + "ok: [localhost] => {\n", + " \"msg\": [\n", + " \"metallb_range_start: 172.18.255.1\",\n", + " \"metallb_range_stop: 172.18.255.255\"\n", + " ]\n", + "}\n", + "\n", + "TASK [seldonio.k8s.metallb : Deploy MetalLB] ***********************************\n", + "ok: [localhost] => (item=https://raw.githubusercontent.com/metallb/metallb/v0.10.2/manifests/namespace.yaml)\n", + "ok: [localhost] => (item=https://raw.githubusercontent.com/metallb/metallb/v0.10.2/manifests/metallb.yaml)\n", + "\n", + "TASK [seldonio.k8s.metallb : Create OpenSSL secretkey] *************************\n", + "changed: [localhost]\n", + "\n", + "TASK [seldonio.k8s.metallb : Create memberlist secret] *************************\n", + "changed: [localhost]\n", + "\n", + "TASK [seldonio.k8s.metallb : Create MetalLB Config] ****************************\n", + "ok: [localhost]\n", + "\n", + "PLAY RECAP *********************************************************************\n", + "localhost : ok=18 changed=4 unreachable=0 failed=0 skipped=3 rescued=0 ignored=0 \n", + "\n", + "\n", + "PLAY [Install Seldon Core & Prerequisites] *************************************\n", + "\n", + "TASK [Load vars from vars/default.yaml] ****************************************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Check if Istio 1.10.3 already downloaded.] **********\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Create .resources directory if does not exist: /home/sa/code/seldon-core/ansible/.resources/] ***\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Download Istio 1.10.3] ******************************\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Install Istio 1.10.3] *******************************\n", + "changed: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Verify Install Istio 1.10.3] ************************\n", + "changed: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Create Seldon Gateway] ******************************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Wait for External IP Address to be ready] ***********\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Set fact about Istio Ingress Gateway External IP] ***\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Create temporary certificates directory] ************\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Generate CA Private Key with RSA 2048] **************\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Generate CA CSR] ************************************\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Generate CA Self Signed Certificate] ****************\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Generate Server OpenSSL private key with RSA 2048] ***\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Generate an OpenSSL Certificate Signing Request for server] ***\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Generate an OpenSSL certificate from the server CSR signed with our CA certificate] ***\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Set fact about Server SSL Certs Paths] **************\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Create Istio Ingressgateway SSL Certs Secret] *******\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.istio : Remove temporary certificates directory] ************\n", + "skipping: [localhost]\n", + "\n", + "TASK [seldonio.k8s.ambassador : Create a k8s namespace: ambassador] ************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.ambassador : Install ambassador] ****************************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.minio : Create a k8s namespaces] ****************************\n", + "ok: [localhost] => (item=minio-system)\n", + "ok: [localhost] => (item=seldon)\n", + "\n", + "TASK [seldonio.k8s.minio : Install MinIO] **************************************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.minio : Echo message about client configuration] ************\n", + "ok: [localhost] => {\n", + " \"msg\": [\n", + " \"MinIO installed in the cluster. To configure your local client launch\",\n", + " \"kubectl port-forward -n minio-system svc/minio 8090:9000\",\n", + " \"in one terminal and execute\",\n", + " \"mc config host add minio-seldon http://localhost:8090 ACCESS_KEY SECRET_KEY\"\n", + " ]\n", + "}\n", + "\n", + "TASK [seldonio.k8s.minio : Configure Minio VirtualService] *********************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.minio : Create MinIO Secret (rclone storage initializer format)] ***\n", + "ok: [localhost] => (item=seldon)\n", + "\n", + "TASK [seldonio.k8s.minio : Create MinIO Secret (kfserving storage initializer format)] ***\n", + "ok: [localhost] => (item=seldon)\n", + "\n", + "TASK [seldonio.k8s.seldon_core_analytics : Create a seldon-system namespaces] ***\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.seldon_core_analytics : Create Extra Resources from Templates] ***\n", + "\n", + "TASK [seldonio.k8s.seldon_core_analytics : Install Seldon Core Analytics] ******\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.seldon_core_analytics : Wait for Seldon Core Analytics Deployments] ***\n", + "ok: [localhost] => (item=seldon-core-analytics-grafana)\n", + "ok: [localhost] => (item=seldon-core-analytics-kube-state-metrics)\n", + "ok: [localhost] => (item=seldon-core-analytics-prometheus-alertmanager)\n", + "ok: [localhost] => (item=seldon-core-analytics-prometheus-pushgateway)\n", + "ok: [localhost] => (item=seldon-core-analytics-prometheus-seldon)\n", + "\n", + "TASK [seldonio.k8s.seldon_core : Create a k8s namespaces] **********************\n", + "ok: [localhost] => (item=seldon-system)\n", + "ok: [localhost] => (item=seldon)\n", + "\n", + "TASK [seldonio.k8s.seldon_core : Git clone Seldon Core repo and checkout master] ***\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.seldon_core : Set Seldon Core Directory] ********************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.seldon_core : Deploy Seldon Core] ***************************\n", + "ok: [localhost]\n", + "\n", + "TASK [seldonio.k8s.seldon_core : Wait for Seldon Core deployments] *************\n", + "ok: [localhost] => (item=seldon-controller-manager)\n", + "\n", + "PLAY RECAP *********************************************************************\n", + "localhost : ok=22 changed=2 unreachable=0 failed=0 skipped=14 rescued=0 ignored=0 \n", + "\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "[WARNING]: The default idempotency check can fail to report changes in certain\n", + "cases. Install helm diff for better results.\n" + ] + } + ], "source": [ "%%bash\n", - "cd ../ansible\n", + "cd ../../../ansible\n", "ansible-playbook playbooks/kind_cluster.yaml\n", "ansible-playbook playbooks/main.yaml -e seldon_core_version=master " ] @@ -105,10 +322,62 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "65d444af", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: mlflow in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (1.19.0)\n", + "Requirement already satisfied: scikit-learn==0.23.2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (0.23.2)\n", + "Requirement already satisfied: pandas in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (1.3.1)\n", + "Requirement already satisfied: threadpoolctl>=2.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from scikit-learn==0.23.2) (2.2.0)\n", + "Requirement already satisfied: joblib>=0.11 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from scikit-learn==0.23.2) (1.0.1)\n", + "Requirement already satisfied: numpy>=1.13.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from scikit-learn==0.23.2) (1.21.1)\n", + "Requirement already satisfied: scipy>=0.19.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from scikit-learn==0.23.2) (1.7.1)\n", + "Requirement already satisfied: click>=7.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (8.0.1)\n", + "Requirement already satisfied: gunicorn in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (20.1.0)\n", + "Requirement already satisfied: alembic<=1.4.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (1.4.1)\n", + "Requirement already satisfied: cloudpickle in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (1.6.0)\n", + "Requirement already satisfied: sqlalchemy in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (1.4.22)\n", + "Requirement already satisfied: querystring-parser in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (1.2.4)\n", + "Requirement already satisfied: Flask in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (2.0.1)\n", + "Requirement already satisfied: gitpython>=2.1.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (3.1.18)\n", + "Requirement already satisfied: databricks-cli>=0.8.7 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (0.15.0)\n", + "Requirement already satisfied: protobuf>=3.7.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (3.17.3)\n", + "Requirement already satisfied: pyyaml>=5.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (5.4.1)\n", + "Requirement already satisfied: entrypoints in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (0.3)\n", + "Requirement already satisfied: packaging in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (21.0)\n", + "Requirement already satisfied: prometheus-flask-exporter in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (0.18.2)\n", + "Requirement already satisfied: sqlparse>=0.3.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (0.4.1)\n", + "Requirement already satisfied: pytz in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (2021.1)\n", + "Requirement already satisfied: docker>=4.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (5.0.0)\n", + "Requirement already satisfied: requests>=2.17.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (2.26.0)\n", + "Requirement already satisfied: python-dateutil>=2.7.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from pandas) (2.8.2)\n", + "Requirement already satisfied: python-editor>=0.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from alembic<=1.4.1->mlflow) (1.0.4)\n", + "Requirement already satisfied: Mako in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from alembic<=1.4.1->mlflow) (1.1.4)\n", + "Requirement already satisfied: six>=1.10.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from databricks-cli>=0.8.7->mlflow) (1.16.0)\n", + "Requirement already satisfied: tabulate>=0.7.7 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from databricks-cli>=0.8.7->mlflow) (0.8.9)\n", + "Requirement already satisfied: websocket-client>=0.32.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from docker>=4.0.0->mlflow) (1.1.1)\n", + "Requirement already satisfied: gitdb<5,>=4.0.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from gitpython>=2.1.0->mlflow) (4.0.7)\n", + "Requirement already satisfied: smmap<5,>=3.0.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from gitdb<5,>=4.0.1->gitpython>=2.1.0->mlflow) (4.0.0)\n", + "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow) (1.26.6)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow) (2021.5.30)\n", + "Requirement already satisfied: idna<4,>=2.5 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow) (3.2)\n", + "Requirement already satisfied: charset-normalizer~=2.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow) (2.0.4)\n", + "Requirement already satisfied: greenlet!=0.4.17 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from sqlalchemy->mlflow) (1.1.1)\n", + "Requirement already satisfied: Jinja2>=3.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Flask->mlflow) (3.0.1)\n", + "Requirement already satisfied: Werkzeug>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Flask->mlflow) (2.0.1)\n", + "Requirement already satisfied: itsdangerous>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Flask->mlflow) (2.0.1)\n", + "Requirement already satisfied: MarkupSafe>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Jinja2>=3.0->Flask->mlflow) (2.0.1)\n", + "Requirement already satisfied: setuptools>=3.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from gunicorn->mlflow) (52.0.0.post20210125)\n", + "Requirement already satisfied: pyparsing>=2.0.2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from packaging->mlflow) (2.4.7)\n", + "Requirement already satisfied: prometheus-client in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from prometheus-flask-exporter->mlflow) (0.11.0)\n" + ] + } + ], "source": [ "!pip install mlflow scikit-learn==0.23.2 pandas" ] @@ -123,7 +392,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "b66ccdff", "metadata": {}, "outputs": [], @@ -143,7 +412,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "57f8a675", "metadata": {}, "outputs": [], @@ -246,12 +515,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "id": "33f84e54", "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Elasticnet model (alpha=0.500000, l1_ratio=0.500000):\n", + " RMSE: 0.7931640229276851\n", + " MAE: 0.6271946374319587\n", + " R2: 0.10862644997792614\n", + " Model saved to /home/sa/code/seldon-core/examples/models/mlflow_v2_protocol_end_to_end/elasticnet_wine_model\n" + ] + } + ], "source": [ "train(0.5, 0.5)" ] @@ -293,10 +574,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "0fbfe38f", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting packages...\n", + "Packing environment at '/home/sa/miniconda3/envs/python3.8-mlflow-example' to '/home/sa/code/seldon-core/examples/models/mlflow_v2_protocol_end_to_end/elasticnet_wine_model/environment.tar.gz'\n", + "[########################################] | 100% Completed | 47.4s\n" + ] + }, + { + "data": { + "text/plain": [ + "'/home/sa/code/seldon-core/examples/models/mlflow_v2_protocol_end_to_end/elasticnet_wine_model/environment.tar.gz'" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "import conda_pack\n", "env_file_path = MODEL_DIR / \"environment.tar.gz\"\n", @@ -338,10 +639,51 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "7434bf31", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Removing `minio-seldon/model/elasticnet_wine_model/MLmodel`.\n", + "Removing `minio-seldon/model/elasticnet_wine_model/conda.yaml`.\n", + "Removing `minio-seldon/model/elasticnet_wine_model/environment.tar.gz`.\n", + "Removing `minio-seldon/model/elasticnet_wine_model/model.pkl`.\n", + "Removing `minio-seldon/model/elasticnet_wine_model/requirements.txt`.\n", + "`/home/sa/code/seldon-core/examples/models/mlflow_v2_protocol_end_to_end/elasticnet_wine_model/model.pkl` -> `minio-seldon/model/elasticnet_wine_model/model.pkl`\n", + "`/home/sa/code/seldon-core/examples/models/mlflow_v2_protocol_end_to_end/elasticnet_wine_model/MLmodel` -> `minio-seldon/model/elasticnet_wine_model/MLmodel`\n", + "`/home/sa/code/seldon-core/examples/models/mlflow_v2_protocol_end_to_end/elasticnet_wine_model/conda.yaml` -> `minio-seldon/model/elasticnet_wine_model/conda.yaml`\n", + "`/home/sa/code/seldon-core/examples/models/mlflow_v2_protocol_end_to_end/elasticnet_wine_model/requirements.txt` -> `minio-seldon/model/elasticnet_wine_model/requirements.txt`\n", + "`/home/sa/code/seldon-core/examples/models/mlflow_v2_protocol_end_to_end/elasticnet_wine_model/environment.tar.gz` -> `minio-seldon/model/elasticnet_wine_model/environment.tar.gz`\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "mc: Unable to make bucket `minio-seldon/model`. Your previous request to create the named bucket succeeded and you already own it.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total: 0 B, Transferred: 322.91 MiB, Speed: 653.87 MiB/s\n" + ] + }, + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "import os\n", "target_bucket = \"minio-seldon/model\"\n", @@ -357,7 +699,7 @@ "metadata": {}, "outputs": [], "source": [ - "%%writefile ./resources/mlflow_elasticnet_wine_v2.yaml\n", + "%%writefile mlflow_elasticnet_wine_v2.yaml\n", "apiVersion: machinelearning.seldon.io/v1alpha2\n", "kind: SeldonDeployment\n", "metadata:\n", @@ -383,7 +725,7 @@ "metadata": {}, "outputs": [], "source": [ - "!kubectl apply -f ./resources/mlflow_elasticnet_wine_v2.yaml" + "!kubectl apply -f mlflow_elasticnet_wine_v2.yaml" ] }, { @@ -532,7 +874,7 @@ "metadata": {}, "outputs": [], "source": [ - "!kubectl delete -f ./resources/mlflow_elasticnet_wine_v2.yaml" + "!kubectl delete -f mlflow_elasticnet_wine_v2.yaml" ] } ], From b455dbc7bf7ab63067ee84267955c0be267af7b2 Mon Sep 17 00:00:00 2001 From: Sherif Akoush Date: Wed, 11 Aug 2021 18:58:29 +0100 Subject: [PATCH 06/10] PR comments --- .../mlflow_v2_protocol_end_to_end.ipynb | 430 +++--------------- 1 file changed, 69 insertions(+), 361 deletions(-) diff --git a/examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb b/examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb index f740ed5261..1650183971 100644 --- a/examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb +++ b/examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb @@ -15,9 +15,9 @@ "id": "a842a699", "metadata": {}, "source": [ - "Prerequisites:\n", + "Prerequisites before running this notebook:\n", "\n", - "- install and configure `mc`, follow the relevant section in this [link](https://docs.seldon.io/projects/seldon-core/en/latest/examples/minio_setup.html):\n", + "- install and configure `mc`, follow the relevant section in this [link](https://docs.seldon.io/projects/seldon-core/en/latest/examples/minio_setup.html)\n", "\n", "- run this jupyter notebook in conda environment\n", "```bash\n", @@ -28,12 +28,30 @@ "```" ] }, + { + "cell_type": "markdown", + "id": "6674657a-3a92-440b-9e40-79dddb0c3834", + "metadata": {}, + "source": [ + "## Setup `seldon-core` and `minio`\n", + "\n", + "\n", + "### Setup Seldon Core\n", + "\n", + "Use the setup notebook to [Setup Cluster](https://docs.seldon.io/projects/seldon-core/en/latest/examples/seldon_core_setup.html#Setup-Cluster) with [Ambassador Ingress](https://docs.seldon.io/projects/seldon-core/en/latest/examples/seldon_core_setup.html#Ambassador) and [Install Seldon Core](https://docs.seldon.io/projects/seldon-core/en/latest/examples/seldon_core_setup.html#Install-Seldon-Core). Instructions [also online](https://docs.seldon.io/projects/seldon-core/en/latest/examples/seldon_core_setup.html).\n", + "\n", + "### Setup MinIO\n", + "\n", + "Use the provided [notebook](https://docs.seldon.io/projects/seldon-core/en/latest/examples/minio_setup.html) to install Minio in your cluster and configure `mc` CLI tool. \n", + "Instructions [also online](https://docs.seldon.io/projects/seldon-core/en/latest/examples/minio_setup.html)." + ] + }, { "cell_type": "markdown", "id": "5d7c94b0", "metadata": {}, "source": [ - "## Setup local kind cluster using ansible" + "## Alternatively setup `seldon-core` and `minio` using `ansible`" ] }, { @@ -41,7 +59,7 @@ "id": "246b23a4", "metadata": {}, "source": [ - "### Install ansible prerequisites" + "### Install `ansible` prerequisites" ] }, { @@ -71,232 +89,15 @@ "id": "f9f3501f", "metadata": {}, "source": [ - "### Setup kind cluster and install seldon-core" + "### Setup kind cluster and install `seldon-core`" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "f4d2f264", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "PLAY [Create Kind Cluster and Install MetalLB] *********************************\n", - "\n", - "TASK [seldonio.k8s.kind : Check if Kind v0.11.1 already downloaded] ************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Create .resources directory if does not exist: /home/sa/code/seldon-core/ansible/.resources/] ***\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Download Kind v0.11.1 binary] ************************\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Make Kind v0.11.1 binary executable] *****************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Check if KinD Cluster already exists: ansible] *******\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Start KinD Cluster: 'ansible'] ***********************\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Echo output of \"kind create cluster ...\" command] ****\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Export kubeconfig for KinD Cluster: 'ansible'] *******\n", - "changed: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Create a k8s namespace: seldon] **********************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Set default for kubectl namespace: seldon] ***********\n", - "changed: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Download metrics-server manifest.] *******************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.kind : Modify the manifest to allow insecure TLS for testing.] ***\n", - "ok: [localhost] => (item=kubelet-preferred-address-types=InternalIP)\n", - "ok: [localhost] => (item=kubelet-insecure-tls)\n", - "\n", - "TASK [seldonio.k8s.kind : Deploy metrics-server into the cluster.] *************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.metallb : Get information about kind network in docker.] ****\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.metallb : Extract subnet of kind network] *******************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.metallb : Set ranges for MetalLB] ***************************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.metallb : Echo message about kind network 2] ****************\n", - "ok: [localhost] => {\n", - " \"msg\": [\n", - " \"metallb_range_start: 172.18.255.1\",\n", - " \"metallb_range_stop: 172.18.255.255\"\n", - " ]\n", - "}\n", - "\n", - "TASK [seldonio.k8s.metallb : Deploy MetalLB] ***********************************\n", - "ok: [localhost] => (item=https://raw.githubusercontent.com/metallb/metallb/v0.10.2/manifests/namespace.yaml)\n", - "ok: [localhost] => (item=https://raw.githubusercontent.com/metallb/metallb/v0.10.2/manifests/metallb.yaml)\n", - "\n", - "TASK [seldonio.k8s.metallb : Create OpenSSL secretkey] *************************\n", - "changed: [localhost]\n", - "\n", - "TASK [seldonio.k8s.metallb : Create memberlist secret] *************************\n", - "changed: [localhost]\n", - "\n", - "TASK [seldonio.k8s.metallb : Create MetalLB Config] ****************************\n", - "ok: [localhost]\n", - "\n", - "PLAY RECAP *********************************************************************\n", - "localhost : ok=18 changed=4 unreachable=0 failed=0 skipped=3 rescued=0 ignored=0 \n", - "\n", - "\n", - "PLAY [Install Seldon Core & Prerequisites] *************************************\n", - "\n", - "TASK [Load vars from vars/default.yaml] ****************************************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Check if Istio 1.10.3 already downloaded.] **********\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Create .resources directory if does not exist: /home/sa/code/seldon-core/ansible/.resources/] ***\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Download Istio 1.10.3] ******************************\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Install Istio 1.10.3] *******************************\n", - "changed: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Verify Install Istio 1.10.3] ************************\n", - "changed: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Create Seldon Gateway] ******************************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Wait for External IP Address to be ready] ***********\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Set fact about Istio Ingress Gateway External IP] ***\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Create temporary certificates directory] ************\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Generate CA Private Key with RSA 2048] **************\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Generate CA CSR] ************************************\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Generate CA Self Signed Certificate] ****************\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Generate Server OpenSSL private key with RSA 2048] ***\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Generate an OpenSSL Certificate Signing Request for server] ***\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Generate an OpenSSL certificate from the server CSR signed with our CA certificate] ***\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Set fact about Server SSL Certs Paths] **************\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Create Istio Ingressgateway SSL Certs Secret] *******\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.istio : Remove temporary certificates directory] ************\n", - "skipping: [localhost]\n", - "\n", - "TASK [seldonio.k8s.ambassador : Create a k8s namespace: ambassador] ************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.ambassador : Install ambassador] ****************************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.minio : Create a k8s namespaces] ****************************\n", - "ok: [localhost] => (item=minio-system)\n", - "ok: [localhost] => (item=seldon)\n", - "\n", - "TASK [seldonio.k8s.minio : Install MinIO] **************************************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.minio : Echo message about client configuration] ************\n", - "ok: [localhost] => {\n", - " \"msg\": [\n", - " \"MinIO installed in the cluster. To configure your local client launch\",\n", - " \"kubectl port-forward -n minio-system svc/minio 8090:9000\",\n", - " \"in one terminal and execute\",\n", - " \"mc config host add minio-seldon http://localhost:8090 ACCESS_KEY SECRET_KEY\"\n", - " ]\n", - "}\n", - "\n", - "TASK [seldonio.k8s.minio : Configure Minio VirtualService] *********************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.minio : Create MinIO Secret (rclone storage initializer format)] ***\n", - "ok: [localhost] => (item=seldon)\n", - "\n", - "TASK [seldonio.k8s.minio : Create MinIO Secret (kfserving storage initializer format)] ***\n", - "ok: [localhost] => (item=seldon)\n", - "\n", - "TASK [seldonio.k8s.seldon_core_analytics : Create a seldon-system namespaces] ***\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.seldon_core_analytics : Create Extra Resources from Templates] ***\n", - "\n", - "TASK [seldonio.k8s.seldon_core_analytics : Install Seldon Core Analytics] ******\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.seldon_core_analytics : Wait for Seldon Core Analytics Deployments] ***\n", - "ok: [localhost] => (item=seldon-core-analytics-grafana)\n", - "ok: [localhost] => (item=seldon-core-analytics-kube-state-metrics)\n", - "ok: [localhost] => (item=seldon-core-analytics-prometheus-alertmanager)\n", - "ok: [localhost] => (item=seldon-core-analytics-prometheus-pushgateway)\n", - "ok: [localhost] => (item=seldon-core-analytics-prometheus-seldon)\n", - "\n", - "TASK [seldonio.k8s.seldon_core : Create a k8s namespaces] **********************\n", - "ok: [localhost] => (item=seldon-system)\n", - "ok: [localhost] => (item=seldon)\n", - "\n", - "TASK [seldonio.k8s.seldon_core : Git clone Seldon Core repo and checkout master] ***\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.seldon_core : Set Seldon Core Directory] ********************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.seldon_core : Deploy Seldon Core] ***************************\n", - "ok: [localhost]\n", - "\n", - "TASK [seldonio.k8s.seldon_core : Wait for Seldon Core deployments] *************\n", - "ok: [localhost] => (item=seldon-controller-manager)\n", - "\n", - "PLAY RECAP *********************************************************************\n", - "localhost : ok=22 changed=2 unreachable=0 failed=0 skipped=14 rescued=0 ignored=0 \n", - "\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "[WARNING]: The default idempotency check can fail to report changes in certain\n", - "cases. Install helm diff for better results.\n" - ] - } - ], + "outputs": [], "source": [ "%%bash\n", "cd ../../../ansible\n", @@ -322,62 +123,10 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "65d444af", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Requirement already satisfied: mlflow in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (1.19.0)\n", - "Requirement already satisfied: scikit-learn==0.23.2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (0.23.2)\n", - "Requirement already satisfied: pandas in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (1.3.1)\n", - "Requirement already satisfied: threadpoolctl>=2.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from scikit-learn==0.23.2) (2.2.0)\n", - "Requirement already satisfied: joblib>=0.11 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from scikit-learn==0.23.2) (1.0.1)\n", - "Requirement already satisfied: numpy>=1.13.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from scikit-learn==0.23.2) (1.21.1)\n", - "Requirement already satisfied: scipy>=0.19.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from scikit-learn==0.23.2) (1.7.1)\n", - "Requirement already satisfied: click>=7.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (8.0.1)\n", - "Requirement already satisfied: gunicorn in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (20.1.0)\n", - "Requirement already satisfied: alembic<=1.4.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (1.4.1)\n", - "Requirement already satisfied: cloudpickle in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (1.6.0)\n", - "Requirement already satisfied: sqlalchemy in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (1.4.22)\n", - "Requirement already satisfied: querystring-parser in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (1.2.4)\n", - "Requirement already satisfied: Flask in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (2.0.1)\n", - "Requirement already satisfied: gitpython>=2.1.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (3.1.18)\n", - "Requirement already satisfied: databricks-cli>=0.8.7 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (0.15.0)\n", - "Requirement already satisfied: protobuf>=3.7.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (3.17.3)\n", - "Requirement already satisfied: pyyaml>=5.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (5.4.1)\n", - "Requirement already satisfied: entrypoints in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (0.3)\n", - "Requirement already satisfied: packaging in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (21.0)\n", - "Requirement already satisfied: prometheus-flask-exporter in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (0.18.2)\n", - "Requirement already satisfied: sqlparse>=0.3.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (0.4.1)\n", - "Requirement already satisfied: pytz in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (2021.1)\n", - "Requirement already satisfied: docker>=4.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (5.0.0)\n", - "Requirement already satisfied: requests>=2.17.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from mlflow) (2.26.0)\n", - "Requirement already satisfied: python-dateutil>=2.7.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from pandas) (2.8.2)\n", - "Requirement already satisfied: python-editor>=0.3 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from alembic<=1.4.1->mlflow) (1.0.4)\n", - "Requirement already satisfied: Mako in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from alembic<=1.4.1->mlflow) (1.1.4)\n", - "Requirement already satisfied: six>=1.10.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from databricks-cli>=0.8.7->mlflow) (1.16.0)\n", - "Requirement already satisfied: tabulate>=0.7.7 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from databricks-cli>=0.8.7->mlflow) (0.8.9)\n", - "Requirement already satisfied: websocket-client>=0.32.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from docker>=4.0.0->mlflow) (1.1.1)\n", - "Requirement already satisfied: gitdb<5,>=4.0.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from gitpython>=2.1.0->mlflow) (4.0.7)\n", - "Requirement already satisfied: smmap<5,>=3.0.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from gitdb<5,>=4.0.1->gitpython>=2.1.0->mlflow) (4.0.0)\n", - "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow) (1.26.6)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow) (2021.5.30)\n", - "Requirement already satisfied: idna<4,>=2.5 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow) (3.2)\n", - "Requirement already satisfied: charset-normalizer~=2.0.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from requests>=2.17.3->mlflow) (2.0.4)\n", - "Requirement already satisfied: greenlet!=0.4.17 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from sqlalchemy->mlflow) (1.1.1)\n", - "Requirement already satisfied: Jinja2>=3.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Flask->mlflow) (3.0.1)\n", - "Requirement already satisfied: Werkzeug>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Flask->mlflow) (2.0.1)\n", - "Requirement already satisfied: itsdangerous>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Flask->mlflow) (2.0.1)\n", - "Requirement already satisfied: MarkupSafe>=2.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from Jinja2>=3.0->Flask->mlflow) (2.0.1)\n", - "Requirement already satisfied: setuptools>=3.0 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from gunicorn->mlflow) (52.0.0.post20210125)\n", - "Requirement already satisfied: pyparsing>=2.0.2 in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from packaging->mlflow) (2.4.7)\n", - "Requirement already satisfied: prometheus-client in /home/sa/miniconda3/envs/python3.8-mlflow-example/lib/python3.8/site-packages (from prometheus-flask-exporter->mlflow) (0.11.0)\n" - ] - } - ], + "outputs": [], "source": [ "!pip install mlflow scikit-learn==0.23.2 pandas" ] @@ -392,7 +141,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "b66ccdff", "metadata": {}, "outputs": [], @@ -407,12 +156,12 @@ "id": "54993046", "metadata": {}, "source": [ - "### Define training" + "### Define training function" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "id": "57f8a675", "metadata": {}, "outputs": [], @@ -515,24 +264,12 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "id": "33f84e54", "metadata": { "scrolled": true }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Elasticnet model (alpha=0.500000, l1_ratio=0.500000):\n", - " RMSE: 0.7931640229276851\n", - " MAE: 0.6271946374319587\n", - " R2: 0.10862644997792614\n", - " Model saved to /home/sa/code/seldon-core/examples/models/mlflow_v2_protocol_end_to_end/elasticnet_wine_model\n" - ] - } - ], + "outputs": [], "source": [ "train(0.5, 0.5)" ] @@ -574,30 +311,10 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "id": "0fbfe38f", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Collecting packages...\n", - "Packing environment at '/home/sa/miniconda3/envs/python3.8-mlflow-example' to '/home/sa/code/seldon-core/examples/models/mlflow_v2_protocol_end_to_end/elasticnet_wine_model/environment.tar.gz'\n", - "[########################################] | 100% Completed | 47.4s\n" - ] - }, - { - "data": { - "text/plain": [ - "'/home/sa/code/seldon-core/examples/models/mlflow_v2_protocol_end_to_end/elasticnet_wine_model/environment.tar.gz'" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "import conda_pack\n", "env_file_path = MODEL_DIR / \"environment.tar.gz\"\n", @@ -639,59 +356,26 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "id": "7434bf31", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Removing `minio-seldon/model/elasticnet_wine_model/MLmodel`.\n", - "Removing `minio-seldon/model/elasticnet_wine_model/conda.yaml`.\n", - "Removing `minio-seldon/model/elasticnet_wine_model/environment.tar.gz`.\n", - "Removing `minio-seldon/model/elasticnet_wine_model/model.pkl`.\n", - "Removing `minio-seldon/model/elasticnet_wine_model/requirements.txt`.\n", - "`/home/sa/code/seldon-core/examples/models/mlflow_v2_protocol_end_to_end/elasticnet_wine_model/model.pkl` -> `minio-seldon/model/elasticnet_wine_model/model.pkl`\n", - "`/home/sa/code/seldon-core/examples/models/mlflow_v2_protocol_end_to_end/elasticnet_wine_model/MLmodel` -> `minio-seldon/model/elasticnet_wine_model/MLmodel`\n", - "`/home/sa/code/seldon-core/examples/models/mlflow_v2_protocol_end_to_end/elasticnet_wine_model/conda.yaml` -> `minio-seldon/model/elasticnet_wine_model/conda.yaml`\n", - "`/home/sa/code/seldon-core/examples/models/mlflow_v2_protocol_end_to_end/elasticnet_wine_model/requirements.txt` -> `minio-seldon/model/elasticnet_wine_model/requirements.txt`\n", - "`/home/sa/code/seldon-core/examples/models/mlflow_v2_protocol_end_to_end/elasticnet_wine_model/environment.tar.gz` -> `minio-seldon/model/elasticnet_wine_model/environment.tar.gz`\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "mc: Unable to make bucket `minio-seldon/model`. Your previous request to create the named bucket succeeded and you already own it.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total: 0 B, Transferred: 322.91 MiB, Speed: 653.87 MiB/s\n" - ] - }, - { - "data": { - "text/plain": [ - "0" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "import os\n", "target_bucket = \"minio-seldon/model\"\n", - "os.system(f\"mc rm --force --recursive {target_bucket}\")\n", + "os.system(f\"mc rb --force {target_bucket}\")\n", "os.system(f\"mc mb {target_bucket}\")\n", "os.system(f\"mc cp --recursive {MODEL_DIR} {target_bucket}\")" ] }, + { + "cell_type": "markdown", + "id": "6325166a-01b8-4742-b00f-1fbb8d6c5cf7", + "metadata": {}, + "source": [ + "### Create model deployment configuration" + ] + }, { "cell_type": "code", "execution_count": null, @@ -718,6 +402,14 @@ " replicas: 1" ] }, + { + "cell_type": "markdown", + "id": "63994123-0f7f-4cb8-b940-231138f69f48", + "metadata": {}, + "source": [ + "### Deploy the model on the local kind cluster" + ] + }, { "cell_type": "code", "execution_count": null, @@ -740,6 +432,14 @@ "!kubectl rollout status deploy/$(kubectl get deploy -l seldon-deployment-id=mlflow -o jsonpath='{.items[0].metadata.name}')" ] }, + { + "cell_type": "markdown", + "id": "1a2e1a24-7407-4bf5-a589-f87d5c352218", + "metadata": {}, + "source": [ + "### Get prediction from the service using REST" + ] + }, { "cell_type": "code", "execution_count": null, @@ -867,6 +567,14 @@ "assert response.ok" ] }, + { + "cell_type": "markdown", + "id": "fc974c57-57b3-44aa-b02b-4cc61892f871", + "metadata": {}, + "source": [ + "### Delete the model deployment" + ] + }, { "cell_type": "code", "execution_count": null, From bbdf19c91c4388029c47c65d970f1e693b65d8a7 Mon Sep 17 00:00:00 2001 From: Sherif Akoush Date: Thu, 12 Aug 2021 09:01:41 +0100 Subject: [PATCH 07/10] add README.md --- ...protocol_end_to_end.ipynb => README.ipynb} | 0 .../mlflow_v2_protocol_end_to_end/README.md | 378 ++++++++++++++++++ 2 files changed, 378 insertions(+) rename examples/models/mlflow_v2_protocol_end_to_end/{mlflow_v2_protocol_end_to_end.ipynb => README.ipynb} (100%) create mode 100644 examples/models/mlflow_v2_protocol_end_to_end/README.md diff --git a/examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb b/examples/models/mlflow_v2_protocol_end_to_end/README.ipynb similarity index 100% rename from examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb rename to examples/models/mlflow_v2_protocol_end_to_end/README.ipynb diff --git a/examples/models/mlflow_v2_protocol_end_to_end/README.md b/examples/models/mlflow_v2_protocol_end_to_end/README.md new file mode 100644 index 0000000000..3d79e7554b --- /dev/null +++ b/examples/models/mlflow_v2_protocol_end_to_end/README.md @@ -0,0 +1,378 @@ +# MLflow v2 protocol elasticnet wine example + +In this example we are going to build a model using mlflow, pack and deploy it on seldon-core on a local kind cluster + +Prerequisites before running this notebook: + +- install and configure `mc`, follow the relevant section in this [link](https://docs.seldon.io/projects/seldon-core/en/latest/examples/minio_setup.html) + +- run this jupyter notebook in conda environment +```bash +$ conda create --name python3.8-mlflow-example python=3.8 -y +$ conda activate python3.8-mlflow-example +$ pip install jupyter +$ jupyter notebook +``` + +## Setup `seldon-core` and `minio` + + +### Setup Seldon Core + +Use the setup notebook to [Setup Cluster](https://docs.seldon.io/projects/seldon-core/en/latest/examples/seldon_core_setup.html#Setup-Cluster) with [Ambassador Ingress](https://docs.seldon.io/projects/seldon-core/en/latest/examples/seldon_core_setup.html#Ambassador) and [Install Seldon Core](https://docs.seldon.io/projects/seldon-core/en/latest/examples/seldon_core_setup.html#Install-Seldon-Core). Instructions [also online](https://docs.seldon.io/projects/seldon-core/en/latest/examples/seldon_core_setup.html). + +### Setup MinIO + +Use the provided [notebook](https://docs.seldon.io/projects/seldon-core/en/latest/examples/minio_setup.html) to install Minio in your cluster and configure `mc` CLI tool. +Instructions [also online](https://docs.seldon.io/projects/seldon-core/en/latest/examples/minio_setup.html). + +## Alternatively setup `seldon-core` and `minio` using `ansible` + +### Install `ansible` prerequisites + + +```python +!pip install ansible openshift docker passlib +``` + + +```python +!ansible-galaxy collection install git+https://github.com/SeldonIO/ansible-k8s-collection.git +``` + +### Setup kind cluster and install `seldon-core` + + +```bash +%%bash +cd ../../../ansible +ansible-playbook playbooks/kind_cluster.yaml +ansible-playbook playbooks/main.yaml -e seldon_core_version=master +``` + +## Train elasticnet wine model using `mlflow` + +### Install `mlflow` and required dependencies to train the model + + +```python +!pip install mlflow scikit-learn==0.23.2 pandas +``` + +### Define where the model artifacts will be saved + + +```python +import os +from pathlib import Path +MODEL_DIR = Path(os.getcwd()) / "elasticnet_wine_model" +``` + +### Define training function + + +```python +# Wine Quality Sample a copy from: +# https://github.com/mlflow/mlflow/blob/master/examples/sklearn_elasticnet_wine/train.ipynb + +def train(in_alpha, in_l1_ratio): + import os + import warnings + import sys + + import pandas as pd + import numpy as np + from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score + from sklearn.model_selection import train_test_split + from sklearn.linear_model import ElasticNet + + import mlflow + import mlflow.sklearn + + import logging + logging.basicConfig(level=logging.WARN) + logger = logging.getLogger(__name__) + + def eval_metrics(actual, pred): + rmse = np.sqrt(mean_squared_error(actual, pred)) + mae = mean_absolute_error(actual, pred) + r2 = r2_score(actual, pred) + return rmse, mae, r2 + + + warnings.filterwarnings("ignore") + np.random.seed(40) + + # Read the wine-quality csv file from the URL + csv_url =\ + 'http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv' + try: + data = pd.read_csv(csv_url, sep=';') + except Exception as e: + logger.exception( + "Unable to download training & test CSV, check your internet connection. Error: %s", e) + + # Split the data into training and test sets. (0.75, 0.25) split. + train, test = train_test_split(data) + + # The predicted column is "quality" which is a scalar from [3, 9] + train_x = train.drop(["quality"], axis=1) + test_x = test.drop(["quality"], axis=1) + train_y = train[["quality"]] + test_y = test[["quality"]] + + # Set default values if no alpha is provided + if float(in_alpha) is None: + alpha = 0.5 + else: + alpha = float(in_alpha) + + # Set default values if no l1_ratio is provided + if float(in_l1_ratio) is None: + l1_ratio = 0.5 + else: + l1_ratio = float(in_l1_ratio) + + # Useful for multiple runs (only doing one run in this sample notebook) + with mlflow.start_run(): + # Execute ElasticNet + lr = ElasticNet(alpha=alpha, l1_ratio=l1_ratio, random_state=42) + lr.fit(train_x, train_y) + + # Evaluate Metrics + predicted_qualities = lr.predict(test_x) + (rmse, mae, r2) = eval_metrics(test_y, predicted_qualities) + + # Print out metrics + print("Elasticnet model (alpha=%f, l1_ratio=%f):" % (alpha, l1_ratio)) + print(" RMSE: %s" % rmse) + print(" MAE: %s" % mae) + print(" R2: %s" % r2) + + # Log parameter, metrics, and model to MLflow + mlflow.log_param("alpha", alpha) + mlflow.log_param("l1_ratio", l1_ratio) + mlflow.log_metric("rmse", rmse) + mlflow.log_metric("r2", r2) + mlflow.log_metric("mae", mae) + + mlflow.sklearn.save_model(lr, MODEL_DIR) + print(f" Model saved to {MODEL_DIR}") +``` + +### Train the elasticnet_wine model + + +```python +train(0.5, 0.5) +``` + +### Install dependencies to be able to pack and deploy the model on `seldon_core` + +We are going to use [`conda-pack`](https://conda.github.io/conda-pack/) to pack the python enviornment. We also need `mlserver` dependencies. +We are planning to simplify this workflow in future releases. + + +```python +!pip install conda-pack mlserver==0.4.0 mlserver-mlflow==0.4.0 +``` + +### Pack the conda enviornment + + +```python +import conda_pack +env_file_path = MODEL_DIR / "environment.tar.gz" +conda_pack.pack( + output=str(env_file_path), + force=True, + verbose=True, + ignore_editable_packages=False, + ignore_missing_files=True, +) +``` + +### Configure `mc` to access the minio service in the local kind cluster +note: make sure that minio ip is reflected properly below, run `kubectl get service -n minio-system` + + +```python +!mc config host add minio-seldon http://172.18.255.3:9000 minioadmin minioadmin +``` + +### Copy the model artifacts to minio + + +```python +import os +target_bucket = "minio-seldon/model" +os.system(f"mc rb --force {target_bucket}") +os.system(f"mc mb {target_bucket}") +os.system(f"mc cp --recursive {MODEL_DIR} {target_bucket}") +``` + +### Create model deployment configuration + + +```python +%%writefile mlflow_elasticnet_wine_v2.yaml +apiVersion: machinelearning.seldon.io/v1alpha2 +kind: SeldonDeployment +metadata: + name: mlflow +spec: + protocol: kfserving # Activate v2 protocol + name: wines + predictors: + - graph: + children: [] + implementation: MLFLOW_SERVER + modelUri: s3:/model + envSecretRefName: seldon-rclone-secret + name: classifier + name: default + replicas: 1 +``` + +### Deploy the model on the local kind cluster + + +```python +!kubectl apply -f mlflow_elasticnet_wine_v2.yaml +``` + + +```python +!kubectl rollout status deploy/$(kubectl get deploy -l seldon-deployment-id=mlflow -o jsonpath='{.items[0].metadata.name}') +``` + +### Get prediction from the service using REST + + +```python +import json + +import requests + +inference_request = { + "parameters": { + "content_type": "pd" + }, + "inputs": [ + { + "name": "fixed acidity", + "shape": [1], + "datatype": "FP32", + "data": [7.4], + "parameters": { + "content_type": "np" + } + }, + { + "name": "volatile acidity", + "shape": [1], + "datatype": "FP32", + "data": [0.7000], + "parameters": { + "content_type": "np" + } + }, + { + "name": "citric acidity", + "shape": [1], + "datatype": "FP32", + "data": [0], + "parameters": { + "content_type": "np" + } + }, + { + "name": "residual sugar", + "shape": [1], + "datatype": "FP32", + "data": [1.9], + "parameters": { + "content_type": "np" + } + }, + { + "name": "chlorides", + "shape": [1], + "datatype": "FP32", + "data": [0.076], + "parameters": { + "content_type": "np" + } + }, + { + "name": "free sulfur dioxide", + "shape": [1], + "datatype": "FP32", + "data": [11], + "parameters": { + "content_type": "np" + } + }, + { + "name": "total sulfur dioxide", + "shape": [1], + "datatype": "FP32", + "data": [34], + "parameters": { + "content_type": "np" + } + }, + { + "name": "density", + "shape": [1], + "datatype": "FP32", + "data": [0.9978], + "parameters": { + "content_type": "np" + } + }, + { + "name": "pH", + "shape": [1], + "datatype": "FP32", + "data": [3.51], + "parameters": { + "content_type": "np" + } + }, + { + "name": "sulphates", + "shape": [1], + "datatype": "FP32", + "data": [0.56], + "parameters": { + "content_type": "np" + } + }, + { + "name": "alcohol", + "shape": [1], + "datatype": "FP32", + "data": [9.4], + "parameters": { + "content_type": "np" + } + }, + ] +} + +# note is the local balancer for istion, make sure that the ip is reflected in the setup, +# run kubectl get service -n istio-system +endpoint = "http://172.18.255.1/seldon/seldon/mlflow/v2/models/infer" +response = requests.post(endpoint, json=inference_request) + +print(json.dumps(response.json(), indent=2)) +assert response.ok +``` + +### Delete the model deployment + + +```python +!kubectl delete -f mlflow_elasticnet_wine_v2.yaml +``` From 1f2a141e8ec1f1e9b3259c42f50e89f30dc9146f Mon Sep 17 00:00:00 2001 From: Sherif Akoush Date: Thu, 12 Aug 2021 09:05:33 +0100 Subject: [PATCH 08/10] update nblink file --- doc/source/examples/mlflow_v2_protocol_end_to_end.nblink | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/examples/mlflow_v2_protocol_end_to_end.nblink b/doc/source/examples/mlflow_v2_protocol_end_to_end.nblink index 58ffb3e891..59c0aca887 100644 --- a/doc/source/examples/mlflow_v2_protocol_end_to_end.nblink +++ b/doc/source/examples/mlflow_v2_protocol_end_to_end.nblink @@ -1,3 +1,3 @@ { - "path": "../../../examples/models/mlflow_v2_protocol_end_to_end/mlflow_v2_protocol_end_to_end.ipynb" + "path": "../../../examples/models/mlflow_v2_protocol_end_to_end/README.ipynb" } From 4bf0ed27748d105eed26c4d2ec3ac9043ab14588 Mon Sep 17 00:00:00 2001 From: Sherif Akoush Date: Thu, 12 Aug 2021 11:37:03 +0100 Subject: [PATCH 09/10] fix issue with notebook --- .../README.ipynb | 75 ++++--------------- .../mlflow_v2_protocol_end_to_end/README.md | 35 +++------ 2 files changed, 22 insertions(+), 88 deletions(-) diff --git a/examples/models/mlflow_v2_protocol_end_to_end/README.ipynb b/examples/models/mlflow_v2_protocol_end_to_end/README.ipynb index 1650183971..6c6fc013ba 100644 --- a/examples/models/mlflow_v2_protocol_end_to_end/README.ipynb +++ b/examples/models/mlflow_v2_protocol_end_to_end/README.ipynb @@ -46,65 +46,6 @@ "Instructions [also online](https://docs.seldon.io/projects/seldon-core/en/latest/examples/minio_setup.html)." ] }, - { - "cell_type": "markdown", - "id": "5d7c94b0", - "metadata": {}, - "source": [ - "## Alternatively setup `seldon-core` and `minio` using `ansible`" - ] - }, - { - "cell_type": "markdown", - "id": "246b23a4", - "metadata": {}, - "source": [ - "### Install `ansible` prerequisites" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ef719025", - "metadata": { - "scrolled": true - }, - "outputs": [], - "source": [ - "!pip install ansible openshift docker passlib" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "f6e0d020", - "metadata": {}, - "outputs": [], - "source": [ - "!ansible-galaxy collection install git+https://github.com/SeldonIO/ansible-k8s-collection.git" - ] - }, - { - "cell_type": "markdown", - "id": "f9f3501f", - "metadata": {}, - "source": [ - "### Setup kind cluster and install `seldon-core`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "f4d2f264", - "metadata": {}, - "outputs": [], - "source": [ - "%%bash\n", - "cd ../../../ansible\n", - "ansible-playbook playbooks/kind_cluster.yaml\n", - "ansible-playbook playbooks/main.yaml -e seldon_core_version=master " - ] - }, { "cell_type": "markdown", "id": "144577cf", @@ -147,8 +88,10 @@ "outputs": [], "source": [ "import os\n", + "import shutil\n", "from pathlib import Path\n", - "MODEL_DIR = Path(os.getcwd()) / \"elasticnet_wine_model\"" + "MODEL_DIR = Path(os.getcwd()) / \"elasticnet_wine_model\"\n", + "shutil.rmtree(MODEL_DIR, ignore_errors=True)" ] }, { @@ -362,7 +305,7 @@ "outputs": [], "source": [ "import os\n", - "target_bucket = \"minio-seldon/model\"\n", + "target_bucket = \"minio-seldon/models\"\n", "os.system(f\"mc rb --force {target_bucket}\")\n", "os.system(f\"mc mb {target_bucket}\")\n", "os.system(f\"mc cp --recursive {MODEL_DIR} {target_bucket}\")" @@ -395,7 +338,7 @@ " - graph:\n", " children: []\n", " implementation: MLFLOW_SERVER\n", - " modelUri: s3:/model\n", + " modelUri: s3://models/elasticnet_wine_model # note: s3 points to minio-seldon in the local kind cluster\n", " envSecretRefName: seldon-rclone-secret\n", " name: classifier\n", " name: default\n", @@ -584,6 +527,14 @@ "source": [ "!kubectl delete -f mlflow_elasticnet_wine_v2.yaml" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4886debf-c2ed-415f-9e8c-619511552aa5", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/examples/models/mlflow_v2_protocol_end_to_end/README.md b/examples/models/mlflow_v2_protocol_end_to_end/README.md index 3d79e7554b..93f8cbf914 100644 --- a/examples/models/mlflow_v2_protocol_end_to_end/README.md +++ b/examples/models/mlflow_v2_protocol_end_to_end/README.md @@ -26,30 +26,6 @@ Use the setup notebook to [Setup Cluster](https://docs.seldon.io/projects/seldon Use the provided [notebook](https://docs.seldon.io/projects/seldon-core/en/latest/examples/minio_setup.html) to install Minio in your cluster and configure `mc` CLI tool. Instructions [also online](https://docs.seldon.io/projects/seldon-core/en/latest/examples/minio_setup.html). -## Alternatively setup `seldon-core` and `minio` using `ansible` - -### Install `ansible` prerequisites - - -```python -!pip install ansible openshift docker passlib -``` - - -```python -!ansible-galaxy collection install git+https://github.com/SeldonIO/ansible-k8s-collection.git -``` - -### Setup kind cluster and install `seldon-core` - - -```bash -%%bash -cd ../../../ansible -ansible-playbook playbooks/kind_cluster.yaml -ansible-playbook playbooks/main.yaml -e seldon_core_version=master -``` - ## Train elasticnet wine model using `mlflow` ### Install `mlflow` and required dependencies to train the model @@ -64,8 +40,10 @@ ansible-playbook playbooks/main.yaml -e seldon_core_version=master ```python import os +import shutil from pathlib import Path MODEL_DIR = Path(os.getcwd()) / "elasticnet_wine_model" +shutil.rmtree(MODEL_DIR, ignore_errors=True) ``` ### Define training function @@ -205,7 +183,7 @@ note: make sure that minio ip is reflected properly below, run `kubectl get serv ```python import os -target_bucket = "minio-seldon/model" +target_bucket = "minio-seldon/models" os.system(f"mc rb --force {target_bucket}") os.system(f"mc mb {target_bucket}") os.system(f"mc cp --recursive {MODEL_DIR} {target_bucket}") @@ -227,7 +205,7 @@ spec: - graph: children: [] implementation: MLFLOW_SERVER - modelUri: s3:/model + modelUri: s3://models/elasticnet_wine_model # note: s3 points to minio-seldon in the local kind cluster envSecretRefName: seldon-rclone-secret name: classifier name: default @@ -376,3 +354,8 @@ assert response.ok ```python !kubectl delete -f mlflow_elasticnet_wine_v2.yaml ``` + + +```python + +``` From 8038ebd7ec1c62253702dd29e6280dfbdf25d5fb Mon Sep 17 00:00:00 2001 From: Sherif Akoush Date: Thu, 12 Aug 2021 11:44:31 +0100 Subject: [PATCH 10/10] add licenses fix licenses fix licenses 2 no licenses manually --- python/licenses/license.txt | 969 ++++++------------- python/licenses/license_info.csv | 44 +- python/licenses/license_info.no_versions.csv | 3 +- 3 files changed, 340 insertions(+), 676 deletions(-) diff --git a/python/licenses/license.txt b/python/licenses/license.txt index d1be841a71..1de871ac4c 100644 --- a/python/licenses/license.txt +++ b/python/licenses/license.txt @@ -1,5 +1,5 @@ Flask -1.1.4 +1.1.2 BSD License Copyright 2010 Pallets @@ -75,7 +75,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Jinja2 -2.11.3 +3.0.1 BSD License Copyright 2007 Pallets @@ -239,7 +239,7 @@ SOFTWARE. Werkzeug -1.0.1 +2.0.1 BSD License Copyright 2007 Pallets @@ -573,23 +573,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -cached-property -1.5.2 -BSD License -Copyright (c) 2015, Daniel Greenfeld -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -* Neither the name of cached-property nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - cachetools 4.2.2 MIT License @@ -642,7 +625,7 @@ one at http://mozilla.org/MPL/2.0/. cffi -1.14.5 +1.14.6 MIT License Except when otherwise stated (look for LICENSE files in directories or @@ -672,514 +655,35 @@ documentation is licensed as follows: -chardet -4.0.0 -GNU Library or Lesser General Public License (LGPL) - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. +charset-normalizer +2.0.4 +MIT License +MIT License - , 1 April 1990 - Ty Coon, President of Vice +Copyright (c) 2019 TAHRI Ahmed R. -That's all there is to it! +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +clang +5.0 +University of Illinois/NCSA Open Source License +UNKNOWN click 8.0.1 @@ -1216,7 +720,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. cryptography 3.4 -Apache Software License, BSD License +Apache Software License; BSD License This software is made available under the terms of *either* of the licenses found in LICENSE.APACHE or LICENSE.BSD. Contributions to cryptography are made under the terms of *both* these licenses. @@ -1265,7 +769,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. google-auth -1.31.0 +1.34.0 Apache Software License Apache License Version 2.0, January 2004 @@ -1471,11 +975,12 @@ Apache Software License google-auth-oauthlib -0.4.4 +0.4.5 Apache Software License - Apache License + + Apache License Version 2.0, January 2004 - https://www.apache.org/licenses/ + http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION @@ -1667,7 +1172,7 @@ Apache Software License you may not use this file except in compliance with the License. You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -1883,7 +1388,7 @@ Apache Software License grpcio -1.38.0 +1.39.0 Apache Software License Apache License @@ -2566,112 +2071,70 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. idna -2.10 +3.2 BSD License -License -------- - -License: bsd-3-clause +BSD 3-Clause License -Copyright (c) 2013-2020, Kim Davies. All rights reserved. +Copyright (c) 2013-2021, Kim Davies +All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -#. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - -#. Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided with - the distribution. - -#. Neither the name of the copyright holder nor the names of the - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -#. THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS "AS IS" AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - DAMAGE. - - -importlib-metadata -4.5.0 -Apache Software License -Copyright 2017-2019 Jason R. Coombs, Barry Warsaw +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. -http://www.apache.org/licenses/LICENSE-2.0 +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. itsdangerous -1.1.0 +2.0.1 BSD License -`BSD 3-Clause `_ - -Copyright © 2011 by the Pallets team. - -Some rights reserved. +Copyright 2011 Pallets Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -- Redistributions of source code must retain the above copyright +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -- Neither the name of the copyright holder nor the names of its +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -We kindly ask you to use these themes in an unmodified manner only with -Pallets and Pallets-related projects, not for unrelated projects. If you -like the visual style and want to use it for your own projects, please -consider making some larger changes to the themes (such as changing font -faces, sizes, colors or margins). - -THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, -BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE AND DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE. - ----- - -The initial implementation of itsdangerous was inspired by Django's -signing module. - -Copyright © Django Software Foundation and individual contributors. -All rights reserved. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. jaeger-client @@ -2703,15 +2166,205 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -keras-nightly -2.5.0.dev2021032900 +keras +2.6.0 Apache Software License -UNKNOWN +Copyright 2015-present The Keras Authors. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + + + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS numpy -1.20.3 -BSD License -Copyright (c) 2005-2021, NumPy Developers. +1.19.5 +BSD +Copyright (c) 2005-2020, NumPy Developers. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -4190,9 +3843,9 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. pyrsistent -0.17.3 +0.18.0 MIT License -Copyright (c) 2019 Tobias Gustafsson +Copyright (c) 2021 Tobias Gustafsson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation @@ -4216,7 +3869,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. requests -2.25.1 +2.26.0 Apache Software License Apache License @@ -4693,7 +4346,7 @@ SOFTWARE. six -1.16.0 +1.15.0 MIT License Copyright (c) 2010-2020 Benjamin Peterson @@ -4716,7 +4369,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. tensorboard -2.5.0 +2.6.0 Apache Software License # TensorBoard License @@ -5298,10 +4951,8 @@ Apache 2.0 UNKNOWN tensorflow -2.5.0 +2.6.0 Apache Software License -Copyright 2019 The TensorFlow Authors. All rights reserved. - Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -5504,9 +5155,10 @@ Copyright 2019 The TensorFlow Authors. All rights reserved. See the License for the specific language governing permissions and limitations under the License. -MIT License +------------------ +Files: third_party/compute_library/... -Copyright (c) 2017-2021 Arm Limited +MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -5526,6 +5178,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------ +Files: ACKNOWLEDGEMENTS LICENSE Redistribution and use in source and binary forms, with or without @@ -5549,9 +5203,44 @@ modification, are permitted provided that the following conditions are met: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +------------------ +Files: third_party/hexagon + +Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted (subject to the limitations in the +disclaimer below) provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of The Linux Foundation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE +GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT +HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + tensorflow-estimator -2.5.0 +2.6.0 Apache Software License UNKNOWN @@ -6158,27 +5847,3 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -zipp -3.4.1 -MIT License -Copyright Jason R. Coombs - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. - - diff --git a/python/licenses/license_info.csv b/python/licenses/license_info.csv index f87f6ae694..6a76e75595 100644 --- a/python/licenses/license_info.csv +++ b/python/licenses/license_info.csv @@ -1,40 +1,39 @@ "Name","Version","License" -"Flask","1.1.4","BSD License" +"Flask","1.1.2","BSD License" "Flask-Cors","3.0.10","MIT License" "Flask-OpenTracing","1.1.0","BSD License" -"Jinja2","2.11.3","BSD License" +"Jinja2","3.0.1","BSD License" "Keras-Preprocessing","1.1.2","MIT License" "Markdown","3.3.4","BSD License" "MarkupSafe","2.0.1","BSD License" "PyYAML","5.4.1","MIT License" -"Werkzeug","1.0.1","BSD License" +"Werkzeug","2.0.1","BSD License" "absl-py","0.13.0","Apache Software License" "astunparse","1.6.3","BSD License" "attrs","21.2.0","MIT License" -"cached-property","1.5.2","BSD License" "cachetools","4.2.2","MIT License" "certifi","2021.5.30","Mozilla Public License 2.0 (MPL 2.0)" -"cffi","1.14.5","MIT License" -"chardet","4.0.0","GNU Library or Lesser General Public License (LGPL)" +"cffi","1.14.6","MIT License" +"charset-normalizer","2.0.4","MIT License" +"clang","5.0","University of Illinois/NCSA Open Source License" "click","8.0.1","BSD License" -"cryptography","3.4","Apache Software License, BSD License" +"cryptography","3.4","Apache Software License; BSD License" "flatbuffers","1.12","Apache Software License" "gast","0.4.0","BSD License" -"google-auth","1.31.0","Apache Software License" -"google-auth-oauthlib","0.4.4","Apache Software License" +"google-auth","1.34.0","Apache Software License" +"google-auth-oauthlib","0.4.5","Apache Software License" "google-pasta","0.2.0","Apache Software License" -"grpcio","1.38.0","Apache Software License" +"grpcio","1.39.0","Apache Software License" "grpcio-opentracing","1.1.4","Apache Software License" "grpcio-reflection","1.34.1","Apache Software License" "gunicorn","20.1.0","MIT License" "h5py","3.1.0","BSD License" -"idna","2.10","BSD License" -"importlib-metadata","4.5.0","Apache Software License" -"itsdangerous","1.1.0","BSD License" +"idna","3.2","BSD License" +"itsdangerous","2.0.1","BSD License" "jaeger-client","4.4.0","Apache Software License" "jsonschema","3.2.0","MIT License" -"keras-nightly","2.5.0.dev2021032900","Apache Software License" -"numpy","1.20.3","BSD License" +"keras","2.6.0","Apache Software License" +"numpy","1.19.5","BSD" "oauthlib","3.1.1","BSD License" "opentracing","2.4.0","Apache Software License" "opt-einsum","3.3.0","MIT" @@ -43,19 +42,19 @@ "pyasn1","0.4.8","BSD License" "pyasn1-modules","0.2.8","BSD License" "pycparser","2.20","BSD License" -"pyrsistent","0.17.3","MIT License" -"requests","2.25.1","Apache Software License" +"pyrsistent","0.18.0","MIT License" +"requests","2.26.0","Apache Software License" "requests-oauthlib","1.3.0","BSD License" "rsa","4.7.2","Apache Software License" "seldon-core","1.10.0.dev0","Apache 2.0" "semantic-version","2.8.5","BSD License" "setuptools-rust","0.12.1","MIT License" -"six","1.16.0","MIT License" -"tensorboard","2.5.0","Apache Software License" +"six","1.15.0","MIT License" +"tensorboard","2.6.0","Apache Software License" "tensorboard-data-server","0.6.1","Apache Software License" "tensorboard-plugin-wit","1.8.0","Apache 2.0" -"tensorflow","2.5.0","Apache Software License" -"tensorflow-estimator","2.5.0","Apache Software License" +"tensorflow","2.6.0","Apache Software License" +"tensorflow-estimator","2.6.0","Apache Software License" "termcolor","1.1.0","MIT License" "threadloop","1.0.2","MIT License" "thrift","0.13.0","Apache Software License" @@ -63,5 +62,4 @@ "tornado","6.1","Apache Software License" "typing-extensions","3.7.4.3","Python Software Foundation License" "urllib3","1.25.9","MIT License" -"wrapt","1.12.1","BSD License" -"zipp","3.4.1","MIT License" \ No newline at end of file +"wrapt","1.12.1","BSD License" \ No newline at end of file diff --git a/python/licenses/license_info.no_versions.csv b/python/licenses/license_info.no_versions.csv index 149425447e..cfb748dc15 100644 --- a/python/licenses/license_info.no_versions.csv +++ b/python/licenses/license_info.no_versions.csv @@ -16,6 +16,7 @@ "certifi","Mozilla Public License 2.0 (MPL 2.0)" "cffi","MIT License" "charset-normalizer","MIT License" +"clang","University of Illinois/NCSA Open Source License" "click","BSD License" "cryptography","Apache Software License; BSD License" "flatbuffers","Apache Software License" @@ -33,7 +34,7 @@ "itsdangerous","BSD License" "jaeger-client","Apache Software License" "jsonschema","MIT License" -"keras-nightly","Apache Software License" +"keras","Apache Software License" "numpy","BSD" "oauthlib","BSD License" "opentracing","Apache Software License"