diff --git a/components/drift-detection/cifar10/cifar10_drift.ipynb b/components/drift-detection/cifar10/cifar10_drift.ipynb index a1e42cb12e..bcada6c63d 100644 --- a/components/drift-detection/cifar10/cifar10_drift.ipynb +++ b/components/drift-detection/cifar10/cifar10_drift.ipynb @@ -328,8 +328,8 @@ "metadata": {}, "outputs": [], "source": [ - "CLUSTER_IPS=!(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')\n", - "CLUSTER_IP=CLUSTER_IPS[0]\n", + "CLUSTER_IPS = !(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')\n", + "CLUSTER_IP = CLUSTER_IPS[0]\n", "print(CLUSTER_IP)" ] }, @@ -355,8 +355,8 @@ "metadata": {}, "outputs": [], "source": [ - "SERVICE_HOSTNAMES=!(kubectl get ksvc -n cifar10drift drift-detector -o jsonpath='{.status.url}' | cut -d \"/\" -f 3)\n", - "SERVICE_HOSTNAME_CD=SERVICE_HOSTNAMES[0]\n", + "SERVICE_HOSTNAMES = !(kubectl get ksvc -n cifar10drift drift-detector -o jsonpath='{.status.url}' | cut -d \"/\" -f 3)\n", + "SERVICE_HOSTNAME_CD = SERVICE_HOSTNAMES[0]\n", "print(SERVICE_HOSTNAME_CD)" ] }, @@ -519,13 +519,13 @@ "metadata": {}, "outputs": [], "source": [ - "res=!kubectl logs -n cifar10drift $(kubectl get pod -n cifar10drift -l app=hello-display -o jsonpath='{.items[0].metadata.name}') \n", - "data= []\n", - "for i in range(0,len(res)):\n", - " if res[i] == 'Data,':\n", - " data.append(res[i+1])\n", + "res = !kubectl logs -n cifar10drift $(kubectl get pod -n cifar10drift -l app=hello-display -o jsonpath='{.items[0].metadata.name}')\n", + "data = []\n", + "for i in range(0, len(res)):\n", + " if res[i] == \"Data,\":\n", + " data.append(res[i + 1])\n", "j = json.loads(json.loads(data[0]))\n", - "print(\"Drift\",j[\"data\"][\"is_drift\"]==1)" + "print(\"Drift\", j[\"data\"][\"is_drift\"] == 1)" ] }, { @@ -590,13 +590,13 @@ "metadata": {}, "outputs": [], "source": [ - "res=!kubectl logs -n cifar10drift $(kubectl get pod -n cifar10drift -l app=hello-display -o jsonpath='{.items[0].metadata.name}') \n", - "data= []\n", - "for i in range(0,len(res)):\n", - " if res[i] == 'Data,':\n", - " data.append(res[i+1])\n", + "res = !kubectl logs -n cifar10drift $(kubectl get pod -n cifar10drift -l app=hello-display -o jsonpath='{.items[0].metadata.name}')\n", + "data = []\n", + "for i in range(0, len(res)):\n", + " if res[i] == \"Data,\":\n", + " data.append(res[i + 1])\n", "j = json.loads(json.loads(data[-1]))\n", - "print(\"Drift\",j[\"data\"][\"is_drift\"]==1)" + "print(\"Drift\", j[\"data\"][\"is_drift\"] == 1)" ] }, { diff --git a/components/drift-detection/nvidia-triton-cifar10/cifar10_drift.ipynb b/components/drift-detection/nvidia-triton-cifar10/cifar10_drift.ipynb index 7f596a2d90..5abb4c2d2f 100644 --- a/components/drift-detection/nvidia-triton-cifar10/cifar10_drift.ipynb +++ b/components/drift-detection/nvidia-triton-cifar10/cifar10_drift.ipynb @@ -411,8 +411,8 @@ } ], "source": [ - "CLUSTER_IPS=!(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')\n", - "CLUSTER_IP=CLUSTER_IPS[0]\n", + "CLUSTER_IPS = !(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')\n", + "CLUSTER_IP = CLUSTER_IPS[0]\n", "print(CLUSTER_IP)" ] }, @@ -462,8 +462,8 @@ } ], "source": [ - "SERVICE_HOSTNAMES=!(kubectl get ksvc -n cifar10drift drift-detector -o jsonpath='{.status.url}' | cut -d \"/\" -f 3)\n", - "SERVICE_HOSTNAME_CD=SERVICE_HOSTNAMES[0]\n", + "SERVICE_HOSTNAMES = !(kubectl get ksvc -n cifar10drift drift-detector -o jsonpath='{.status.url}' | cut -d \"/\" -f 3)\n", + "SERVICE_HOSTNAME_CD = SERVICE_HOSTNAMES[0]\n", "print(SERVICE_HOSTNAME_CD)" ] }, @@ -696,13 +696,13 @@ } ], "source": [ - "res=!kubectl logs -n cifar10drift $(kubectl get pod -n cifar10drift -l app=hello-display -o jsonpath='{.items[0].metadata.name}') \n", - "data= []\n", - "for i in range(0,len(res)):\n", - " if res[i] == 'Data,':\n", - " data.append(res[i+1])\n", + "res = !kubectl logs -n cifar10drift $(kubectl get pod -n cifar10drift -l app=hello-display -o jsonpath='{.items[0].metadata.name}')\n", + "data = []\n", + "for i in range(0, len(res)):\n", + " if res[i] == \"Data,\":\n", + " data.append(res[i + 1])\n", "j = json.loads(json.loads(data[0]))\n", - "print(\"Drift\",j[\"data\"][\"is_drift\"]==1)" + "print(\"Drift\", j[\"data\"][\"is_drift\"] == 1)" ] }, { @@ -829,13 +829,13 @@ } ], "source": [ - "res=!kubectl logs -n cifar10drift $(kubectl get pod -n cifar10drift -l app=hello-display -o jsonpath='{.items[0].metadata.name}') \n", - "data= []\n", - "for i in range(0,len(res)):\n", - " if res[i] == 'Data,':\n", - " data.append(res[i+1])\n", + "res = !kubectl logs -n cifar10drift $(kubectl get pod -n cifar10drift -l app=hello-display -o jsonpath='{.items[0].metadata.name}')\n", + "data = []\n", + "for i in range(0, len(res)):\n", + " if res[i] == \"Data,\":\n", + " data.append(res[i + 1])\n", "j = json.loads(json.loads(data[-1]))\n", - "print(\"Drift\",j[\"data\"][\"is_drift\"]==1)" + "print(\"Drift\", j[\"data\"][\"is_drift\"] == 1)" ] }, { diff --git a/components/outlier-detection/cifar10/cifar10_outlier.ipynb b/components/outlier-detection/cifar10/cifar10_outlier.ipynb index 75aa9ab3f1..5bc0bbb485 100644 --- a/components/outlier-detection/cifar10/cifar10_outlier.ipynb +++ b/components/outlier-detection/cifar10/cifar10_outlier.ipynb @@ -337,8 +337,8 @@ "metadata": {}, "outputs": [], "source": [ - "CLUSTER_IPS=!(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')\n", - "CLUSTER_IP=CLUSTER_IPS[0]\n", + "CLUSTER_IPS = !(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')\n", + "CLUSTER_IP = CLUSTER_IPS[0]\n", "print(CLUSTER_IP)" ] }, @@ -380,8 +380,8 @@ "metadata": {}, "outputs": [], "source": [ - "SERVICE_HOSTNAMES=!(kubectl get ksvc -n cifar10 vae-outlier -o jsonpath='{.status.url}' | cut -d \"/\" -f 3)\n", - "SERVICE_HOSTNAME_VAEOD=SERVICE_HOSTNAMES[0]\n", + "SERVICE_HOSTNAMES = !(kubectl get ksvc -n cifar10 vae-outlier -o jsonpath='{.status.url}' | cut -d \"/\" -f 3)\n", + "SERVICE_HOSTNAME_VAEOD = SERVICE_HOSTNAMES[0]\n", "print(SERVICE_HOSTNAME_VAEOD)" ] }, @@ -507,13 +507,13 @@ "metadata": {}, "outputs": [], "source": [ - "res=!kubectl logs -n cifar10 $(kubectl get pod -n cifar10 -l app=hello-display -o jsonpath='{.items[0].metadata.name}') \n", - "data= []\n", - "for i in range(0,len(res)):\n", - " if res[i] == 'Data,':\n", - " data.append(res[i+1])\n", + "res = !kubectl logs -n cifar10 $(kubectl get pod -n cifar10 -l app=hello-display -o jsonpath='{.items[0].metadata.name}')\n", + "data = []\n", + "for i in range(0, len(res)):\n", + " if res[i] == \"Data,\":\n", + " data.append(res[i + 1])\n", "j = json.loads(json.loads(data[0]))\n", - "print(\"Outlier\",j[\"data\"][\"is_outlier\"]==[1])" + "print(\"Outlier\", j[\"data\"][\"is_outlier\"] == [1])" ] }, { @@ -564,13 +564,13 @@ "metadata": {}, "outputs": [], "source": [ - "res=!kubectl logs -n cifar10 $(kubectl get pod -n cifar10 -l app=hello-display -o jsonpath='{.items[0].metadata.name}') \n", - "data= []\n", - "for i in range(0,len(res)):\n", - " if res[i] == 'Data,':\n", - " data.append(res[i+1])\n", + "res = !kubectl logs -n cifar10 $(kubectl get pod -n cifar10 -l app=hello-display -o jsonpath='{.items[0].metadata.name}')\n", + "data = []\n", + "for i in range(0, len(res)):\n", + " if res[i] == \"Data,\":\n", + " data.append(res[i + 1])\n", "j = json.loads(json.loads(data[-1]))\n", - "print(\"Outlier\",j[\"data\"][\"is_outlier\"]==[1])" + "print(\"Outlier\", j[\"data\"][\"is_outlier\"] == [1])" ] }, { diff --git a/components/outlier-detection/nvidia-triton-cifar10/cifar10_outlier.ipynb b/components/outlier-detection/nvidia-triton-cifar10/cifar10_outlier.ipynb index 8f76306da3..2adc1c74e3 100644 --- a/components/outlier-detection/nvidia-triton-cifar10/cifar10_outlier.ipynb +++ b/components/outlier-detection/nvidia-triton-cifar10/cifar10_outlier.ipynb @@ -409,8 +409,8 @@ } ], "source": [ - "CLUSTER_IPS=!(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')\n", - "CLUSTER_IP=CLUSTER_IPS[0]\n", + "CLUSTER_IPS = !(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')\n", + "CLUSTER_IP = CLUSTER_IPS[0]\n", "print(CLUSTER_IP)" ] }, @@ -460,8 +460,8 @@ } ], "source": [ - "SERVICE_HOSTNAMES=!(kubectl get ksvc -n cifar10 vae-outlier -o jsonpath='{.status.url}' | cut -d \"/\" -f 3)\n", - "SERVICE_HOSTNAME_VAEOD=SERVICE_HOSTNAMES[0]\n", + "SERVICE_HOSTNAMES = !(kubectl get ksvc -n cifar10 vae-outlier -o jsonpath='{.status.url}' | cut -d \"/\" -f 3)\n", + "SERVICE_HOSTNAME_VAEOD = SERVICE_HOSTNAMES[0]\n", "print(SERVICE_HOSTNAME_VAEOD)" ] }, @@ -644,13 +644,13 @@ } ], "source": [ - "res=!kubectl logs -n cifar10 $(kubectl get pod -n cifar10 -l app=hello-display -o jsonpath='{.items[0].metadata.name}') \n", - "data= []\n", - "for i in range(0,len(res)):\n", - " if res[i] == 'Data,':\n", - " data.append(res[i+1])\n", + "res = !kubectl logs -n cifar10 $(kubectl get pod -n cifar10 -l app=hello-display -o jsonpath='{.items[0].metadata.name}')\n", + "data = []\n", + "for i in range(0, len(res)):\n", + " if res[i] == \"Data,\":\n", + " data.append(res[i + 1])\n", "j = json.loads(json.loads(data[0]))\n", - "print(\"Outlier\",j[\"data\"][\"is_outlier\"]==[1])" + "print(\"Outlier\", j[\"data\"][\"is_outlier\"] == [1])" ] }, { @@ -732,13 +732,13 @@ } ], "source": [ - "res=!kubectl logs -n cifar10 $(kubectl get pod -n cifar10 -l app=hello-display -o jsonpath='{.items[0].metadata.name}') \n", - "data= []\n", - "for i in range(0,len(res)):\n", - " if res[i] == 'Data,':\n", - " data.append(res[i+1])\n", + "res = !kubectl logs -n cifar10 $(kubectl get pod -n cifar10 -l app=hello-display -o jsonpath='{.items[0].metadata.name}')\n", + "data = []\n", + "for i in range(0, len(res)):\n", + " if res[i] == \"Data,\":\n", + " data.append(res[i + 1])\n", "j = json.loads(json.loads(data[-1]))\n", - "print(\"Outlier\",j[\"data\"][\"is_outlier\"]==[1])" + "print(\"Outlier\", j[\"data\"][\"is_outlier\"] == [1])" ] }, { diff --git a/components/routers/epsilon-greedy/egreedy.ipynb b/components/routers/epsilon-greedy/egreedy.ipynb index b1dbd0454f..82b57a4a9c 100644 --- a/components/routers/epsilon-greedy/egreedy.ipynb +++ b/components/routers/epsilon-greedy/egreedy.ipynb @@ -98,8 +98,8 @@ } ], "source": [ - "VERSION=!cat ../../../version.txt\n", - "VERSION=VERSION[0]\n", + "VERSION = !cat ../../../version.txt\n", + "VERSION = VERSION[0]\n", "VERSION" ] }, diff --git a/examples/ambassador/canary/ambassador_canary.ipynb b/examples/ambassador/canary/ambassador_canary.ipynb index 199115fb2f..aa700a2996 100644 --- a/examples/ambassador/canary/ambassador_canary.ipynb +++ b/examples/ambassador/canary/ambassador_canary.ipynb @@ -82,8 +82,8 @@ } ], "source": [ - "VERSION=!cat ../../../version.txt\n", - "VERSION=VERSION[0]\n", + "VERSION = !cat ../../../version.txt\n", + "VERSION = VERSION[0]\n", "VERSION" ] }, @@ -385,7 +385,7 @@ "metadata": {}, "outputs": [], "source": [ - "default_count=!kubectl logs $(kubectl get pod -lseldon-app=example-main -o jsonpath='{.items[0].metadata.name}') classifier | grep \"root:predict\" | wc -l " + "default_count = !kubectl logs $(kubectl get pod -lseldon-app=example-main -o jsonpath='{.items[0].metadata.name}') classifier | grep \"root:predict\" | wc -l" ] }, { @@ -394,7 +394,7 @@ "metadata": {}, "outputs": [], "source": [ - "canary_count=!kubectl logs $(kubectl get pod -lseldon-app=example-canary -o jsonpath='{.items[0].metadata.name}') classifier | grep \"root:predict\" | wc -l" + "canary_count = !kubectl logs $(kubectl get pod -lseldon-app=example-canary -o jsonpath='{.items[0].metadata.name}') classifier | grep \"root:predict\" | wc -l" ] }, { diff --git a/examples/ambassador/custom/ambassador_custom.ipynb b/examples/ambassador/custom/ambassador_custom.ipynb index 8dd6dd76e3..e735f25ced 100644 --- a/examples/ambassador/custom/ambassador_custom.ipynb +++ b/examples/ambassador/custom/ambassador_custom.ipynb @@ -41,8 +41,8 @@ } ], "source": [ - "VERSION=!cat ../../../version.txt\n", - "VERSION=VERSION[0]\n", + "VERSION = !cat ../../../version.txt\n", + "VERSION = VERSION[0]\n", "VERSION" ] }, diff --git a/examples/ambassador/headers/ambassador_headers.ipynb b/examples/ambassador/headers/ambassador_headers.ipynb index a6cd694a81..10dd3e7bad 100644 --- a/examples/ambassador/headers/ambassador_headers.ipynb +++ b/examples/ambassador/headers/ambassador_headers.ipynb @@ -84,8 +84,8 @@ } ], "source": [ - "VERSION=!cat ../../../version.txt\n", - "VERSION=VERSION[0]\n", + "VERSION = !cat ../../../version.txt\n", + "VERSION = VERSION[0]\n", "VERSION" ] }, @@ -356,7 +356,7 @@ "metadata": {}, "outputs": [], "source": [ - "default_count=!kubectl logs $(kubectl get pod -lseldon-app=example-single -o jsonpath='{.items[0].metadata.name}') classifier | grep \"root.predict\" | wc -l " + "default_count = !kubectl logs $(kubectl get pod -lseldon-app=example-single -o jsonpath='{.items[0].metadata.name}') classifier | grep \"root.predict\" | wc -l" ] }, { @@ -421,7 +421,7 @@ "metadata": {}, "outputs": [], "source": [ - "header_count=!kubectl logs $(kubectl get pod -lseldon-app=example-header-single -o jsonpath='{.items[0].metadata.name}') classifier | grep \"root.predict\" | wc -l " + "header_count = !kubectl logs $(kubectl get pod -lseldon-app=example-header-single -o jsonpath='{.items[0].metadata.name}') classifier | grep \"root.predict\" | wc -l" ] }, { diff --git a/examples/ambassador/shadow/ambassador_shadow.ipynb b/examples/ambassador/shadow/ambassador_shadow.ipynb index 6ee43314a6..d2f29bee52 100644 --- a/examples/ambassador/shadow/ambassador_shadow.ipynb +++ b/examples/ambassador/shadow/ambassador_shadow.ipynb @@ -86,8 +86,8 @@ } ], "source": [ - "VERSION=!cat ../../../version.txt\n", - "VERSION=VERSION[0]\n", + "VERSION = !cat ../../../version.txt\n", + "VERSION = VERSION[0]\n", "VERSION" ] }, @@ -340,7 +340,7 @@ "metadata": {}, "outputs": [], "source": [ - "default_count=!kubectl logs $(kubectl get pod -lseldon-app=example-default -o jsonpath='{.items[0].metadata.name}') classifier | grep \"root.predict\" | wc -l " + "default_count = !kubectl logs $(kubectl get pod -lseldon-app=example-default -o jsonpath='{.items[0].metadata.name}') classifier | grep \"root.predict\" | wc -l" ] }, { @@ -349,7 +349,7 @@ "metadata": {}, "outputs": [], "source": [ - "shadow_count=!kubectl logs $(kubectl get pod -lseldon-app=example-shadow -o jsonpath='{.items[0].metadata.name}') classifier | grep \"root.predict\" | wc -l " + "shadow_count = !kubectl logs $(kubectl get pod -lseldon-app=example-shadow -o jsonpath='{.items[0].metadata.name}') classifier | grep \"root.predict\" | wc -l" ] }, { diff --git a/examples/batch/argo-workflows-batch/README.ipynb b/examples/batch/argo-workflows-batch/README.ipynb index 8668edcb6b..b636ab9994 100644 --- a/examples/batch/argo-workflows-batch/README.ipynb +++ b/examples/batch/argo-workflows-batch/README.ipynb @@ -565,6 +565,7 @@ ], "source": [ "import json\n", + "\n", "wf_arr = !argo get -n default seldon-batch-process -o json\n", "wf = json.loads(\"\".join(wf_arr))\n", "WF_UID = wf[\"metadata\"][\"uid\"]\n", diff --git a/examples/cicd/sig-mlops-jenkins-classic/models/image_classifier/README.ipynb b/examples/cicd/sig-mlops-jenkins-classic/models/image_classifier/README.ipynb index 64193dedae..a8da7ed8fb 100644 --- a/examples/cicd/sig-mlops-jenkins-classic/models/image_classifier/README.ipynb +++ b/examples/cicd/sig-mlops-jenkins-classic/models/image_classifier/README.ipynb @@ -705,18 +705,20 @@ } ], "source": [ - "from seldon_core.seldon_client import SeldonClient\n", "import numpy as np\n", "\n", + "from seldon_core.seldon_client import SeldonClient\n", + "\n", "url = !kubectl get svc ambassador -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'\n", "\n", "sc = SeldonClient(\n", - " gateway=\"ambassador\", \n", + " gateway=\"ambassador\",\n", " gateway_endpoint=\"localhost:80\",\n", " deployment_name=\"mlops-server\",\n", " payload_type=\"ndarray\",\n", " namespace=\"jx-staging\",\n", - " transport=\"rest\")\n", + " transport=\"rest\",\n", + ")\n", "\n", "response = sc.predict(data=np.array([twenty_test.data[0]]))\n", "\n", diff --git a/examples/cicd/sig-mlops-jenkins-classic/models/news_classifier/README.ipynb b/examples/cicd/sig-mlops-jenkins-classic/models/news_classifier/README.ipynb index caa9f491da..127145c9c3 100644 --- a/examples/cicd/sig-mlops-jenkins-classic/models/news_classifier/README.ipynb +++ b/examples/cicd/sig-mlops-jenkins-classic/models/news_classifier/README.ipynb @@ -569,18 +569,20 @@ } ], "source": [ - "from seldon_core.seldon_client import SeldonClient\n", "import numpy as np\n", "\n", + "from seldon_core.seldon_client import SeldonClient\n", + "\n", "url = !kubectl get svc ambassador -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'\n", "\n", "sc = SeldonClient(\n", - " gateway=\"ambassador\", \n", + " gateway=\"ambassador\",\n", " gateway_endpoint=\"localhost:80\",\n", " deployment_name=\"mlops-server\",\n", " payload_type=\"ndarray\",\n", " namespace=\"staging\",\n", - " transport=\"rest\")\n", + " transport=\"rest\",\n", + ")\n", "\n", "response = sc.predict(data=np.array([twenty_test.data[0]]))\n", "\n", diff --git a/examples/cicd/sig-mlops-seldon-jenkins-x/README.ipynb b/examples/cicd/sig-mlops-seldon-jenkins-x/README.ipynb index e53add05f0..f3d9ec20b7 100644 --- a/examples/cicd/sig-mlops-seldon-jenkins-x/README.ipynb +++ b/examples/cicd/sig-mlops-seldon-jenkins-x/README.ipynb @@ -620,18 +620,20 @@ } ], "source": [ - "from seldon_core.seldon_client import SeldonClient\n", "import numpy as np\n", "\n", + "from seldon_core.seldon_client import SeldonClient\n", + "\n", "url = !kubectl get svc ambassador -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'\n", "\n", "sc = SeldonClient(\n", - " gateway=\"ambassador\", \n", + " gateway=\"ambassador\",\n", " gateway_endpoint=\"localhost:80\",\n", " deployment_name=\"mlops-server\",\n", " payload_type=\"ndarray\",\n", " namespace=\"jx-staging\",\n", - " transport=\"rest\")\n", + " transport=\"rest\",\n", + ")\n", "\n", "response = sc.predict(data=np.array([twenty_test.data[0]]))\n", "\n", @@ -1018,18 +1020,20 @@ "metadata": {}, "outputs": [], "source": [ - "from seldon_core.seldon_client import SeldonClient\n", "import numpy as np\n", "\n", + "from seldon_core.seldon_client import SeldonClient\n", + "\n", "url = !kubectl get svc ambassador -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'\n", "\n", "sc = SeldonClient(\n", - " gateway=\"ambassador\", \n", + " gateway=\"ambassador\",\n", " gateway_endpoint=\"localhost:80\",\n", " deployment_name=\"mlops-server\",\n", " payload_type=\"ndarray\",\n", " namespace=\"jx-production\",\n", - " transport=\"rest\")\n", + " transport=\"rest\",\n", + ")\n", "\n", "response = sc.predict(data=np.array([twenty_test.data[0]]))\n", "\n", diff --git a/examples/istio/canary/istio_canary.ipynb b/examples/istio/canary/istio_canary.ipynb index fbc922e393..651c03f5cf 100644 --- a/examples/istio/canary/istio_canary.ipynb +++ b/examples/istio/canary/istio_canary.ipynb @@ -91,10 +91,10 @@ } ], "source": [ - "ISTIO_GATEWAY=\"localhost:8004\"\n", + "ISTIO_GATEWAY = \"localhost:8004\"\n", "\n", - "VERSION=!cat ../../../version.txt\n", - "VERSION=VERSION[0]\n", + "VERSION = !cat ../../../version.txt\n", + "VERSION = VERSION[0]\n", "VERSION" ] }, @@ -383,7 +383,7 @@ "metadata": {}, "outputs": [], "source": [ - "default_count=!kubectl logs $(kubectl get pod -lseldon-app=example-main -o jsonpath='{.items[0].metadata.name}') classifier | grep \"root:predict\" | wc -l " + "default_count = !kubectl logs $(kubectl get pod -lseldon-app=example-main -o jsonpath='{.items[0].metadata.name}') classifier | grep \"root:predict\" | wc -l" ] }, { @@ -392,7 +392,7 @@ "metadata": {}, "outputs": [], "source": [ - "canary_count=!kubectl logs $(kubectl get pod -lseldon-app=example-canary -o jsonpath='{.items[0].metadata.name}') classifier | grep \"root:predict\" | wc -l" + "canary_count = !kubectl logs $(kubectl get pod -lseldon-app=example-canary -o jsonpath='{.items[0].metadata.name}') classifier | grep \"root:predict\" | wc -l" ] }, { diff --git a/examples/iter8/progressive_rollout/separate_sdeps/abtest.ipynb b/examples/iter8/progressive_rollout/separate_sdeps/abtest.ipynb index d694ac1e65..3fc47a339b 100644 --- a/examples/iter8/progressive_rollout/separate_sdeps/abtest.ipynb +++ b/examples/iter8/progressive_rollout/separate_sdeps/abtest.ipynb @@ -740,7 +740,7 @@ } ], "source": [ - "!kubectl get experiment quickstart-exp " + "!kubectl get experiment quickstart-exp" ] }, { diff --git a/examples/kafka/cifar10/cifar10_kafka.ipynb b/examples/kafka/cifar10/cifar10_kafka.ipynb index 3c6da34667..9023e7aa5f 100644 --- a/examples/kafka/cifar10/cifar10_kafka.ipynb +++ b/examples/kafka/cifar10/cifar10_kafka.ipynb @@ -102,17 +102,17 @@ "outputs": [], "source": [ "if clusterType == \"kind\":\n", - " res=!kubectl get service my-cluster-kafka-external-bootstrap -n default -o=jsonpath='{.spec.ports[0].nodePort}'\n", - " port=res[0]\n", + " res = !kubectl get service my-cluster-kafka-external-bootstrap -n default -o=jsonpath='{.spec.ports[0].nodePort}'\n", + " port = res[0]\n", " %env BROKER=172.17.0.2:$port\n", "else:\n", - " res=!kubectl get service my-cluster-kafka-external-bootstrap -o=jsonpath='{.status.loadBalancer.ingress[0].hostname}'\n", + " res = !kubectl get service my-cluster-kafka-external-bootstrap -o=jsonpath='{.status.loadBalancer.ingress[0].hostname}'\n", " if len(res) == 1:\n", - " hostname=res[0]\n", + " hostname = res[0]\n", " %env BROKER=$h:9094\n", " else:\n", - " res=!kubectl get service my-cluster-kafka-external-bootstrap -o=jsonpath='{.status.loadBalancer.ingress[0].ip}'\n", - " ip=res[0]\n", + " res = !kubectl get service my-cluster-kafka-external-bootstrap -o=jsonpath='{.status.loadBalancer.ingress[0].ip}'\n", + " ip = res[0]\n", " %env BROKER=$ip:9094" ] }, @@ -231,8 +231,8 @@ "metadata": {}, "outputs": [], "source": [ - "res=!kubectl get service my-cluster-kafka-external-bootstrap -o=jsonpath='{.spec.clusterIP}'\n", - "ip=res[0]\n", + "res = !kubectl get service my-cluster-kafka-external-bootstrap -o=jsonpath='{.spec.clusterIP}'\n", + "ip = res[0]\n", "%env BROKER_CIP=$ip" ] }, @@ -339,8 +339,8 @@ "metadata": {}, "outputs": [], "source": [ - "res=!kubectl get service my-cluster-kafka-external-bootstrap -o=jsonpath='{.spec.clusterIP}'\n", - "ip=res[0]\n", + "res = !kubectl get service my-cluster-kafka-external-bootstrap -o=jsonpath='{.spec.clusterIP}'\n", + "ip = res[0]\n", "%env BROKER_CIP=$ip" ] }, diff --git a/examples/keda/keda_prom_auto_scale.ipynb b/examples/keda/keda_prom_auto_scale.ipynb index e2b1f352bf..dcbd219077 100644 --- a/examples/keda/keda_prom_auto_scale.ipynb +++ b/examples/keda/keda_prom_auto_scale.ipynb @@ -111,8 +111,8 @@ "metadata": {}, "outputs": [], "source": [ - "VERSION=!cat ../../version.txt\n", - "VERSION=VERSION[0]\n", + "VERSION = !cat ../../version.txt\n", + "VERSION = VERSION[0]\n", "VERSION" ] }, @@ -261,11 +261,13 @@ "import json\n", "import time\n", "\n", + "\n", "def getNumberPods():\n", - " dp=!kubectl get deployment seldon-model-example-0-classifier -o json\n", - " dp=json.loads(\"\".join(dp))\n", + " dp = !kubectl get deployment seldon-model-example-0-classifier -o json\n", + " dp = json.loads(\"\".join(dp))\n", " return dp[\"status\"][\"replicas\"]\n", - " \n", + "\n", + "\n", "scaled = False\n", "for i in range(60):\n", " pods = getNumberPods()\n", @@ -274,7 +276,7 @@ " scaled = True\n", " break\n", " time.sleep(5)\n", - "assert(scaled)" + "assert scaled" ] }, { @@ -364,4 +366,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} \ No newline at end of file +} diff --git a/examples/minio/minio.ipynb b/examples/minio/minio.ipynb index 5fb2c9173f..3f7eef7741 100644 --- a/examples/minio/minio.ipynb +++ b/examples/minio/minio.ipynb @@ -15,14 +15,14 @@ "## 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)." - ] - }, - { + "\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", "metadata": {}, "source": [ @@ -377,19 +377,16 @@ "outputs": [], "source": [ "import json\n", - "data = !curl -s -X POST -H 'Content-Type: application/json' -d '{\"data\":{\"ndarray\":[[5.964, 4.006, 2.081, 1.031]]}}' http://localhost:8003/seldon/seldon/minio-sklearn/api/v1.0/predictions \n", + "\n", + "data = !curl -s -X POST -H 'Content-Type: application/json' -d '{\"data\":{\"ndarray\":[[5.964, 4.006, 2.081, 1.031]]}}' http://localhost:8003/seldon/seldon/minio-sklearn/api/v1.0/predictions\n", "data = json.loads(data[0])\n", "\n", "assert data == {\n", - " 'data': {\n", - " 'names': ['t:0', 't:1', 't:2'],\n", - " 'ndarray': [[\n", - " 0.9548873249364169,\n", - " 0.04505474761561406,\n", - " 5.7927447968952436e-05\n", - " ]]\n", + " \"data\": {\n", + " \"names\": [\"t:0\", \"t:1\", \"t:2\"],\n", + " \"ndarray\": [[0.9548873249364169, 0.04505474761561406, 5.7927447968952436e-05]],\n", " },\n", - " 'meta': {}\n", + " \"meta\": {},\n", "}" ] }, @@ -400,19 +397,16 @@ "outputs": [], "source": [ "import json\n", - "meta = !curl -s http://localhost:8003/seldon/seldon/minio-sklearn/api/v1.0/metadata/classifier \n", + "\n", + "meta = !curl -s http://localhost:8003/seldon/seldon/minio-sklearn/api/v1.0/metadata/classifier\n", "meta = json.loads(meta[0])\n", "\n", "assert data == {\n", - " 'data': {\n", - " 'names': ['t:0', 't:1', 't:2'],\n", - " 'ndarray': [[\n", - " 0.9548873249364169,\n", - " 0.04505474761561406,\n", - " 5.7927447968952436e-05\n", - " ]]\n", + " \"data\": {\n", + " \"names\": [\"t:0\", \"t:1\", \"t:2\"],\n", + " \"ndarray\": [[0.9548873249364169, 0.04505474761561406, 5.7927447968952436e-05]],\n", " },\n", - " 'meta': {}\n", + " \"meta\": {},\n", "}" ] }, diff --git a/examples/models/autoscaling/autoscaling_example.ipynb b/examples/models/autoscaling/autoscaling_example.ipynb index 2dd92466fa..6d8a8d1efb 100644 --- a/examples/models/autoscaling/autoscaling_example.ipynb +++ b/examples/models/autoscaling/autoscaling_example.ipynb @@ -282,11 +282,13 @@ "import json\n", "import time\n", "\n", + "\n", "def getNumberPods():\n", - " dp=!kubectl get deployment seldon-model-example-0-classifier -o json\n", - " dp=json.loads(\"\".join(dp))\n", + " dp = !kubectl get deployment seldon-model-example-0-classifier -o json\n", + " dp = json.loads(\"\".join(dp))\n", " return dp[\"status\"][\"replicas\"]\n", - " \n", + "\n", + "\n", "scaled = False\n", "for i in range(60):\n", " pods = getNumberPods()\n", @@ -295,7 +297,7 @@ " scaled = True\n", " break\n", " time.sleep(5)\n", - "assert(scaled)" + "assert scaled" ] }, { diff --git a/examples/models/custom_metrics/customMetrics.ipynb b/examples/models/custom_metrics/customMetrics.ipynb index 695dc19672..b1198c0250 100644 --- a/examples/models/custom_metrics/customMetrics.ipynb +++ b/examples/models/custom_metrics/customMetrics.ipynb @@ -179,7 +179,7 @@ "metadata": {}, "outputs": [], "source": [ - "responseRaw=!curl -s -H \"Content-Type: application/json\" -d '{\"data\": {\"ndarray\":[[1.0, 2.0, 5.0]]}}' http://localhost:8003/seldon/seldon/seldon-model/api/v1.0/predictions" + "responseRaw = !curl -s -H \"Content-Type: application/json\" -d '{\"data\": {\"ndarray\":[[1.0, 2.0, 5.0]]}}' http://localhost:8003/seldon/seldon/seldon-model/api/v1.0/predictions" ] }, { @@ -207,7 +207,7 @@ "metadata": {}, "outputs": [], "source": [ - "responseRaw =! bash get-metrics.sh\n", + "responseRaw = ! bash get-metrics.sh\n", "assert len(responseRaw) == 3" ] }, @@ -255,7 +255,7 @@ "metadata": {}, "outputs": [], "source": [ - "responseRaw =! bash get-metrics.sh\n", + "responseRaw = ! bash get-metrics.sh\n", "assert len(responseRaw) == 6" ] }, diff --git a/examples/models/custom_metrics/tfservingMetrics.ipynb b/examples/models/custom_metrics/tfservingMetrics.ipynb index ffd570de7a..90987c6075 100644 --- a/examples/models/custom_metrics/tfservingMetrics.ipynb +++ b/examples/models/custom_metrics/tfservingMetrics.ipynb @@ -170,7 +170,7 @@ "metadata": {}, "outputs": [], "source": [ - "responseRaw=!kubectl run --quiet=true -it --rm curl --image=radial/busyboxplus:curl --restart=Never -- curl -s seldon-core-analytics-prometheus-seldon.seldon-system/api/v1/query?query=:tensorflow:core:graph_runs" + "responseRaw = !kubectl run --quiet=true -it --rm curl --image=radial/busyboxplus:curl --restart=Never -- curl -s seldon-core-analytics-prometheus-seldon.seldon-system/api/v1/query?query=:tensorflow:core:graph_runs" ] }, { diff --git a/examples/models/disruption_budgets/pdbs_example.ipynb b/examples/models/disruption_budgets/pdbs_example.ipynb index 0ba6fa3a42..f47b65c692 100644 --- a/examples/models/disruption_budgets/pdbs_example.ipynb +++ b/examples/models/disruption_budgets/pdbs_example.ipynb @@ -100,11 +100,13 @@ "source": [ "import json\n", "\n", + "\n", "def getPdbConfig():\n", - " dp=!kubectl get pdb seldon-model-example-0-classifier -o json\n", - " dp=json.loads(\"\".join(dp))\n", + " dp = !kubectl get pdb seldon-model-example-0-classifier -o json\n", + " dp = json.loads(\"\".join(dp))\n", " return dp[\"spec\"][\"maxUnavailable\"]\n", - " \n", + "\n", + "\n", "assert getPdbConfig() == 2" ] }, diff --git a/examples/models/lightgbm_custom_server/iris.ipynb b/examples/models/lightgbm_custom_server/iris.ipynb index aaf2f6bedc..6de0ccf722 100644 --- a/examples/models/lightgbm_custom_server/iris.ipynb +++ b/examples/models/lightgbm_custom_server/iris.ipynb @@ -47,9 +47,10 @@ "source": [ "from IPython.core.magic import register_line_cell_magic\n", "\n", + "\n", "@register_line_cell_magic\n", "def writetemplate(line, cell):\n", - " with open(line, 'w') as f:\n", + " with open(line, \"w\") as f:\n", " f.write(cell.format(**globals()))" ] }, @@ -60,8 +61,8 @@ "metadata": {}, "outputs": [], "source": [ - "VERSION=!cat ../../../version.txt\n", - "VERSION=VERSION[0]\n", + "VERSION = !cat ../../../version.txt\n", + "VERSION = VERSION[0]\n", "VERSION" ] }, @@ -80,30 +81,26 @@ "metadata": {}, "outputs": [], "source": [ - "TRAIN_MODEL=False\n", + "TRAIN_MODEL = False\n", "if TRAIN_MODEL:\n", + " import os\n", + "\n", + " import joblib\n", " import lightgbm as lgb\n", + " from sklearn import datasets\n", " from sklearn.datasets import load_iris\n", " from sklearn.model_selection import train_test_split\n", - " import os\n", - " from sklearn import datasets\n", - " import lightgbm as lgb\n", - " import joblib\n", "\n", " model_dir = \"./artifacts\"\n", " BST_FILE = \"model.txt\"\n", "\n", " iris = load_iris()\n", - " y = iris['target']\n", - " X = iris['data']\n", + " y = iris[\"target\"]\n", + " X = iris[\"data\"]\n", " X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1)\n", " dtrain = lgb.Dataset(X_train, label=y_train)\n", "\n", - " params = {\n", - " 'objective':'multiclass', \n", - " 'metric':'softmax',\n", - " 'num_class': 3\n", - " }\n", + " params = {\"objective\": \"multiclass\", \"metric\": \"softmax\", \"num_class\": 3}\n", " lgb_model = lgb.train(params=params, train_set=dtrain)\n", " model_file = os.path.join(model_dir, BST_FILE)\n", " lgb_model.save_model(model_file)" @@ -223,6 +220,7 @@ "outputs": [], "source": [ "import time\n", + "\n", "time.sleep(60)" ] }, @@ -256,13 +254,13 @@ "outputs": [], "source": [ "for i in range(60):\n", - " state=!kubectl get sdep iris -n seldon -o jsonpath='{.status.state}'\n", - " state=state[0]\n", + " state = !kubectl get sdep iris -n seldon -o jsonpath='{.status.state}'\n", + " state = state[0]\n", " print(state)\n", - " if state==\"Available\":\n", + " if state == \"Available\":\n", " break\n", " time.sleep(1)\n", - "assert(state==\"Available\")" + "assert state == \"Available\"" ] }, { @@ -338,13 +336,13 @@ "outputs": [], "source": [ "for i in range(60):\n", - " state=!kubectl get sdep iris -n seldon -o jsonpath='{.status.state}'\n", - " state=state[0]\n", + " state = !kubectl get sdep iris -n seldon -o jsonpath='{.status.state}'\n", + " state = state[0]\n", " print(state)\n", - " if state==\"Available\":\n", + " if state == \"Available\":\n", " break\n", " time.sleep(1)\n", - "assert(state==\"Available\")" + "assert state == \"Available\"" ] }, { diff --git a/examples/models/metrics/general_metrics.ipynb b/examples/models/metrics/general_metrics.ipynb index dd73494678..cadea43d3a 100644 --- a/examples/models/metrics/general_metrics.ipynb +++ b/examples/models/metrics/general_metrics.ipynb @@ -155,25 +155,26 @@ "outputs": [], "source": [ "import time\n", + "\n", "for i in range(3):\n", - " metric=!curl -s http://localhost:8003/seldon/seldon/rest-seldon/prometheus | grep seldon_api_executor_server_requests_seconds_count\n", - " if metric and len(metric)>0: \n", + " metric = !curl -s http://localhost:8003/seldon/seldon/rest-seldon/prometheus | grep seldon_api_executor_server_requests_seconds_count\n", + " if metric and len(metric) > 0:\n", " print(metric[0])\n", - " assert(not metric[0] == \"\")\n", + " assert not metric[0] == \"\"\n", " break\n", " else:\n", " print(\"Failed to get metrics for rest-seldon\")\n", " time.sleep(2)\n", "\n", - "for i in range(3): \n", - " metric=!curl -s http://localhost:8003/seldon/seldon/rest-seldon/prometheus | grep seldon_api_executor_server_requests_seconds_summary_count\n", - " if metric and len(metric)>0: \n", + "for i in range(3):\n", + " metric = !curl -s http://localhost:8003/seldon/seldon/rest-seldon/prometheus | grep seldon_api_executor_server_requests_seconds_summary_count\n", + " if metric and len(metric) > 0:\n", " print(metric[0])\n", - " assert(not metric[0] == \"\")\n", + " assert not metric[0] == \"\"\n", " break\n", " else:\n", " print(\"Failed to get metrics for rest-seldon\")\n", - " time.sleep(2) " + " time.sleep(2)" ] }, { @@ -248,24 +249,24 @@ "outputs": [], "source": [ "for i in range(3):\n", - " metric=!curl -s http://localhost:8003/seldon/seldon/grpc-seldon/prometheus | grep seldon_api_executor_server_requests_seconds_count\n", - " if metric and len(metric)>0: \n", + " metric = !curl -s http://localhost:8003/seldon/seldon/grpc-seldon/prometheus | grep seldon_api_executor_server_requests_seconds_count\n", + " if metric and len(metric) > 0:\n", " print(metric[0])\n", - " assert(not metric[0] == \"\")\n", + " assert not metric[0] == \"\"\n", " break\n", " else:\n", " print(\"Failed to get metrics for grpc-seldon\")\n", " time.sleep(2)\n", - " \n", + "\n", "for i in range(3):\n", - " metric=!curl -s http://localhost:8003/seldon/seldon/grpc-seldon/prometheus | grep seldon_api_executor_server_requests_seconds_summary_count\n", - " if metric and len(metric)>0: \n", + " metric = !curl -s http://localhost:8003/seldon/seldon/grpc-seldon/prometheus | grep seldon_api_executor_server_requests_seconds_summary_count\n", + " if metric and len(metric) > 0:\n", " print(metric[0])\n", - " assert(not metric[0] == \"\")\n", + " assert not metric[0] == \"\"\n", " break\n", " else:\n", " print(\"Failed to get metrics for grpc-seldon\")\n", - " time.sleep(2) " + " time.sleep(2)" ] }, { @@ -332,24 +333,24 @@ "outputs": [], "source": [ "for i in range(3):\n", - " metric=!curl -s http://localhost:8003/seldon/seldon/rest-tfserving/prometheus | grep seldon_api_executor_server_requests_seconds_count\n", - " if metric and len(metric)>0: \n", + " metric = !curl -s http://localhost:8003/seldon/seldon/rest-tfserving/prometheus | grep seldon_api_executor_server_requests_seconds_count\n", + " if metric and len(metric) > 0:\n", " print(metric[0])\n", - " assert(not metric[0] == \"\")\n", + " assert not metric[0] == \"\"\n", " break\n", " else:\n", " print(\"Failed to get metrics for rest-tfserving\")\n", " time.sleep(2)\n", - " \n", + "\n", "for i in range(3):\n", - " metric=!curl -s http://localhost:8003/seldon/seldon/rest-tfserving/prometheus | grep seldon_api_executor_server_requests_seconds_summary_count\n", - " if metric and len(metric)>0: \n", + " metric = !curl -s http://localhost:8003/seldon/seldon/rest-tfserving/prometheus | grep seldon_api_executor_server_requests_seconds_summary_count\n", + " if metric and len(metric) > 0:\n", " print(metric[0])\n", - " assert(not metric[0] == \"\")\n", + " assert not metric[0] == \"\"\n", " break\n", " else:\n", " print(\"Failed to get metrics for rest-tfserving\")\n", - " time.sleep(2) " + " time.sleep(2)" ] }, { @@ -432,24 +433,24 @@ "outputs": [], "source": [ "for i in range(3):\n", - " metric=!curl -s http://localhost:8003/seldon/seldon/grpc-tfserving/prometheus | grep seldon_api_executor_server_requests_seconds_count\n", - " if metric and len(metric)>0: \n", + " metric = !curl -s http://localhost:8003/seldon/seldon/grpc-tfserving/prometheus | grep seldon_api_executor_server_requests_seconds_count\n", + " if metric and len(metric) > 0:\n", " print(metric[0])\n", - " assert(not metric[0] == \"\")\n", + " assert not metric[0] == \"\"\n", " break\n", " else:\n", " print(\"Failed to get metrics for grpc-tfserving\")\n", " time.sleep(2)\n", - " \n", + "\n", "for i in range(3):\n", - " metric=!curl -s http://localhost:8003/seldon/seldon/grpc-tfserving/prometheus | grep seldon_api_executor_server_requests_seconds_summary_count\n", - " if metric and len(metric)>0: \n", + " metric = !curl -s http://localhost:8003/seldon/seldon/grpc-tfserving/prometheus | grep seldon_api_executor_server_requests_seconds_summary_count\n", + " if metric and len(metric) > 0:\n", " print(metric[0])\n", - " assert(not metric[0] == \"\")\n", + " assert not metric[0] == \"\"\n", " break\n", " else:\n", " print(\"Failed to get metrics for grpc-tfserving\")\n", - " time.sleep(2) " + " time.sleep(2)" ] }, { diff --git a/examples/models/payload_logging/payload_logging.ipynb b/examples/models/payload_logging/payload_logging.ipynb index ac50864cae..e88d632a9b 100644 --- a/examples/models/payload_logging/payload_logging.ipynb +++ b/examples/models/payload_logging/payload_logging.ipynb @@ -100,8 +100,8 @@ } ], "source": [ - "VERSION=!cat ../../../version.txt\n", - "VERSION=VERSION[0]\n", + "VERSION = !cat ../../../version.txt\n", + "VERSION = VERSION[0]\n", "VERSION" ] }, @@ -442,9 +442,9 @@ } ], "source": [ - "modelids=!kubectl logs $(kubectl get pods -l run=logger -n seldon -o jsonpath='{.items[0].metadata.name}') logger | grep \"ce-modelid\"\n", + "modelids = !kubectl logs $(kubectl get pods -l run=logger -n seldon -o jsonpath='{.items[0].metadata.name}') logger | grep \"ce-modelid\"\n", "print(modelids)\n", - "assert(modelids[0].strip()==\"\\\"ce-modelid\\\": \\\"classifier\\\",\")" + "assert modelids[0].strip() == '\"ce-modelid\": \"classifier\",'" ] }, { diff --git a/examples/models/sklearn_iris/sklearn_iris.ipynb b/examples/models/sklearn_iris/sklearn_iris.ipynb index 604f203abe..2af08993e5 100644 --- a/examples/models/sklearn_iris/sklearn_iris.ipynb +++ b/examples/models/sklearn_iris/sklearn_iris.ipynb @@ -166,13 +166,13 @@ ], "source": [ "for i in range(60):\n", - " state=!kubectl get sdep seldon-deployment-example -o jsonpath='{.status.state}'\n", - " state=state[0]\n", + " state = !kubectl get sdep seldon-deployment-example -o jsonpath='{.status.state}'\n", + " state = state[0]\n", " print(state)\n", - " if state==\"Available\":\n", + " if state == \"Available\":\n", " break\n", " time.sleep(1)\n", - "assert(state==\"Available\")" + "assert state == \"Available\"" ] }, { @@ -181,7 +181,7 @@ "metadata": {}, "outputs": [], "source": [ - "res=!curl -s http://localhost:8003/seldon/seldon/seldon-deployment-example/api/v0.1/predictions -H \"Content-Type: application/json\" -d '{\"data\":{\"ndarray\":[[5.964,4.006,2.081,1.031]]}}'" + "res = !curl -s http://localhost:8003/seldon/seldon/seldon-deployment-example/api/v0.1/predictions -H \"Content-Type: application/json\" -d '{\"data\":{\"ndarray\":[[5.964,4.006,2.081,1.031]]}}'" ] }, { diff --git a/examples/triton_gpt2/AzureSetup.ipynb b/examples/triton_gpt2/AzureSetup.ipynb index f64493ef3e..d2b6c3f0ce 100644 --- a/examples/triton_gpt2/AzureSetup.ipynb +++ b/examples/triton_gpt2/AzureSetup.ipynb @@ -568,7 +568,7 @@ ], "source": [ "# Create secret to access storage account\n", - "!kubectl create secret generic azure-blobsecret --from-literal azurestorageaccountname={storage_account_name} --from-literal azurestorageaccountkey=\"{storage_account_key}\" --type=Opaque " + "!kubectl create secret generic azure-blobsecret --from-literal azurestorageaccountname={storage_account_name} --from-literal azurestorageaccountkey=\"{storage_account_key}\" --type=Opaque" ] }, { @@ -678,7 +678,7 @@ ], "source": [ "# Verify PVC is bound\n", - "!kubectl get pv,pvc " + "!kubectl get pv,pvc" ] }, { diff --git a/examples/triton_gpt2/GPT2-ONNX-Azure.ipynb b/examples/triton_gpt2/GPT2-ONNX-Azure.ipynb index afa0a0f2b9..c06f2fc85e 100644 --- a/examples/triton_gpt2/GPT2-ONNX-Azure.ipynb +++ b/examples/triton_gpt2/GPT2-ONNX-Azure.ipynb @@ -193,7 +193,7 @@ "outputs": [], "source": [ "key = !az storage account keys list --account-name {storage_account_name} -g {resource_group} --query '[0].value' -o tsv\n", - "storage_account_key = key[0] " + "storage_account_key = key[0]" ] }, { @@ -208,7 +208,7 @@ "outputs": [], "source": [ "# Create secret to access storage account\n", - "!kubectl create secret generic azure-blobsecret --from-literal azurestorageaccountname={storage_account_name} --from-literal azurestorageaccountkey=\"{storage_account_key}\" --type=Opaque " + "!kubectl create secret generic azure-blobsecret --from-literal azurestorageaccountname={storage_account_name} --from-literal azurestorageaccountkey=\"{storage_account_key}\" --type=Opaque" ] }, { @@ -290,7 +290,7 @@ ], "source": [ "# Verify PVC is bound\n", - "!kubectl get pv,pvc " + "!kubectl get pv,pvc" ] }, { @@ -447,7 +447,7 @@ } ], "source": [ - "ingress_ip=!(kubectl get svc --namespace istio-system istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')\n", + "ingress_ip = !(kubectl get svc --namespace istio-system istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')\n", "ingress_ip = ingress_ip[0]\n", "\n", "!curl -v http://{ingress_ip}:80/seldon/default/gpt2gpu/v2/models/gpt2" diff --git a/notebooks/backwards_compatability.ipynb b/notebooks/backwards_compatability.ipynb index fbc3f013b4..b7c2f0c24e 100644 --- a/notebooks/backwards_compatability.ipynb +++ b/notebooks/backwards_compatability.ipynb @@ -100,8 +100,8 @@ } ], "source": [ - "VERSION=!cat ../version.txt\n", - "VERSION=VERSION[0]\n", + "VERSION = !cat ../version.txt\n", + "VERSION = VERSION[0]\n", "VERSION" ] }, @@ -195,13 +195,13 @@ ], "source": [ "for i in range(60):\n", - " state=!kubectl get sdep example-seldon -o jsonpath='{.status.state}'\n", - " state=state[0]\n", + " state = !kubectl get sdep example-seldon -o jsonpath='{.status.state}'\n", + " state = state[0]\n", " print(state)\n", - " if state==\"Available\":\n", + " if state == \"Available\":\n", " break\n", " time.sleep(1)\n", - "assert(state==\"Available\")" + "assert state == \"Available\"" ] }, { @@ -303,13 +303,13 @@ ], "source": [ "for i in range(60):\n", - " state=!kubectl get sdep example-seldon -o jsonpath='{.status.state}'\n", - " state=state[0]\n", + " state = !kubectl get sdep example-seldon -o jsonpath='{.status.state}'\n", + " state = state[0]\n", " print(state)\n", - " if state==\"Available\":\n", + " if state == \"Available\":\n", " break\n", " time.sleep(1)\n", - "assert(state==\"Available\")" + "assert state == \"Available\"" ] }, { @@ -476,13 +476,13 @@ ], "source": [ "for i in range(60):\n", - " state=!kubectl get sdep grpc-seldon -o jsonpath='{.status.state}'\n", - " state=state[0]\n", + " state = !kubectl get sdep grpc-seldon -o jsonpath='{.status.state}'\n", + " state = state[0]\n", " print(state)\n", - " if state==\"Available\":\n", + " if state == \"Available\":\n", " break\n", " time.sleep(1)\n", - "assert(state==\"Available\")" + "assert state == \"Available\"" ] }, { @@ -721,13 +721,13 @@ ], "source": [ "for i in range(60):\n", - " state=!kubectl get sdep example-seldon -o jsonpath='{.status.state}'\n", - " state=state[0]\n", + " state = !kubectl get sdep example-seldon -o jsonpath='{.status.state}'\n", + " state = state[0]\n", " print(state)\n", - " if state==\"Available\":\n", + " if state == \"Available\":\n", " break\n", " time.sleep(1)\n", - "assert(state==\"Available\")" + "assert state == \"Available\"" ] }, { @@ -848,13 +848,13 @@ ], "source": [ "for i in range(60):\n", - " state=!kubectl get sdep example-seldon -o jsonpath='{.status.state}'\n", - " state=state[0]\n", + " state = !kubectl get sdep example-seldon -o jsonpath='{.status.state}'\n", + " state = state[0]\n", " print(state)\n", - " if state==\"Available\":\n", + " if state == \"Available\":\n", " break\n", " time.sleep(1)\n", - "assert(state==\"Available\")" + "assert state == \"Available\"" ] }, { @@ -1013,13 +1013,13 @@ ], "source": [ "for i in range(60):\n", - " state=!kubectl get sdep example-seldon -o jsonpath='{.status.state}'\n", - " state=state[0]\n", + " state = !kubectl get sdep example-seldon -o jsonpath='{.status.state}'\n", + " state = state[0]\n", " print(state)\n", - " if state==\"Available\":\n", + " if state == \"Available\":\n", " break\n", " time.sleep(1)\n", - "assert(state==\"Available\")" + "assert state == \"Available\"" ] }, { diff --git a/notebooks/istio_example.ipynb b/notebooks/istio_example.ipynb index 4f97c43867..994ce8b3fd 100644 --- a/notebooks/istio_example.ipynb +++ b/notebooks/istio_example.ipynb @@ -149,9 +149,9 @@ } ], "source": [ - "ISTIO_GATEWAY=\"localhost:8004\"\n", - "VERSION=!cat ../version.txt\n", - "VERSION=VERSION[0]\n", + "ISTIO_GATEWAY = \"localhost:8004\"\n", + "VERSION = !cat ../version.txt\n", + "VERSION = VERSION[0]\n", "VERSION" ] }, @@ -492,13 +492,13 @@ ], "source": [ "for i in range(60):\n", - " state=!kubectl get sdep example-seldon -o jsonpath='{.status.state}'\n", - " state=state[0]\n", + " state = !kubectl get sdep example-seldon -o jsonpath='{.status.state}'\n", + " state = state[0]\n", " print(state)\n", - " if state==\"Available\":\n", + " if state == \"Available\":\n", " break\n", " time.sleep(1)\n", - "assert(state==\"Available\")" + "assert state == \"Available\"" ] }, { diff --git a/notebooks/max_grpc_msg_size.ipynb b/notebooks/max_grpc_msg_size.ipynb index 954f80189b..16386fe6a6 100644 --- a/notebooks/max_grpc_msg_size.ipynb +++ b/notebooks/max_grpc_msg_size.ipynb @@ -95,8 +95,8 @@ } ], "source": [ - "VERSION=!cat ../version.txt\n", - "VERSION=VERSION[0]\n", + "VERSION = !cat ../version.txt\n", + "VERSION = VERSION[0]\n", "VERSION" ] }, diff --git a/notebooks/multiple_operators.ipynb b/notebooks/multiple_operators.ipynb index 21390c12ae..01e3350bb8 100644 --- a/notebooks/multiple_operators.ipynb +++ b/notebooks/multiple_operators.ipynb @@ -104,8 +104,8 @@ "metadata": {}, "outputs": [], "source": [ - "NAME=!kubectl get sdep -n seldon-ns1 -o jsonpath='{.items[0].metadata.name}'\n", - "assert(NAME[0] == \"seldon-model\")" + "NAME = !kubectl get sdep -n seldon-ns1 -o jsonpath='{.items[0].metadata.name}'\n", + "assert NAME[0] == \"seldon-model\"" ] }, { @@ -221,8 +221,8 @@ "metadata": {}, "outputs": [], "source": [ - "NAME=!kubectl get sdep -n default -o jsonpath='{.items[0].metadata.name}'\n", - "assert(NAME[0] == \"test-c1\")" + "NAME = !kubectl get sdep -n default -o jsonpath='{.items[0].metadata.name}'\n", + "assert NAME[0] == \"test-c1\"" ] }, { diff --git a/notebooks/operator_upgrade.ipynb b/notebooks/operator_upgrade.ipynb index 86f8edb196..c50b716791 100644 --- a/notebooks/operator_upgrade.ipynb +++ b/notebooks/operator_upgrade.ipynb @@ -208,13 +208,13 @@ " for i in range(360):\n", " allAvailable = True\n", " failedGet = False\n", - " state=!kubectl get sdep -o json\n", - " state=json.loads(\"\".join(state))\n", + " state = !kubectl get sdep -o json\n", + " state = json.loads(\"\".join(state))\n", " for model in state[\"items\"]:\n", " if \"status\" in model:\n", - " print(\"model\",model[\"metadata\"][\"name\"],model[\"status\"][\"state\"])\n", - " if model[\"status\"][\"state\"]!=\"Available\":\n", - " allAvailable=False\n", + " print(\"model\", model[\"metadata\"][\"name\"], model[\"status\"][\"state\"])\n", + " if model[\"status\"][\"state\"] != \"Available\":\n", + " allAvailable = False\n", " break\n", " else:\n", " failedGet = True\n", @@ -222,8 +222,10 @@ " break\n", " time.sleep(1)\n", " return allAvailable\n", + "\n", + "\n", "actual = waitStatus(True)\n", - "assert(actual==True)" + "assert actual == True" ] }, { @@ -242,38 +244,43 @@ "def getOwned(raw):\n", " count = 0\n", " for res in raw[\"items\"]:\n", - " if \"ownerReferences\" in res[\"metadata\"] and res[\"metadata\"][\"ownerReferences\"][0][\"kind\"]==\"SeldonDeployment\":\n", + " if (\n", + " \"ownerReferences\" in res[\"metadata\"]\n", + " and res[\"metadata\"][\"ownerReferences\"][0][\"kind\"] == \"SeldonDeployment\"\n", + " ):\n", " count += 1\n", " return count\n", "\n", + "\n", "def getResourceStats():\n", - " #Get number of deployments\n", - " dps=!kubectl get deployment -o json\n", - " dps=json.loads(\"\".join(dps))\n", + " # Get number of deployments\n", + " dps = !kubectl get deployment -o json\n", + " dps = json.loads(\"\".join(dps))\n", " numDps = getOwned(dps)\n", - " print(\"Number of deployments owned\",numDps)\n", + " print(\"Number of deployments owned\", numDps)\n", "\n", - " #Get number of services\n", - " svcs=!kubectl get svc -o json\n", - " svcs=json.loads(\"\".join(svcs))\n", + " # Get number of services\n", + " svcs = !kubectl get svc -o json\n", + " svcs = json.loads(\"\".join(svcs))\n", " numSvcs = getOwned(svcs)\n", - " print(\"Number of services owned\",numSvcs)\n", + " print(\"Number of services owned\", numSvcs)\n", "\n", - " #Get number of virtual services\n", - " vss=!kubectl get vs -o json\n", - " vss=json.loads(\"\".join(vss))\n", + " # Get number of virtual services\n", + " vss = !kubectl get vs -o json\n", + " vss = json.loads(\"\".join(vss))\n", " numVs = getOwned(vss)\n", - " print(\"Number of virtual services owned\",numVs)\n", + " print(\"Number of virtual services owned\", numVs)\n", "\n", - " #Get number of hpas\n", - " hpas=!kubectl get hpa -o json\n", - " hpas=json.loads(\"\".join(hpas))\n", + " # Get number of hpas\n", + " hpas = !kubectl get hpa -o json\n", + " hpas = json.loads(\"\".join(hpas))\n", " numHpas = getOwned(hpas)\n", - " print(\"Number of hpas owned\",numHpas)\n", - " \n", + " print(\"Number of hpas owned\", numHpas)\n", + "\n", " return (numDps, numSvcs, numVs, numHpas)\n", - " \n", - "(dp1,svc1,vs1,hpa1) = getResourceStats()" + "\n", + "\n", + "(dp1, svc1, vs1, hpa1) = getResourceStats()" ] }, { diff --git a/notebooks/rolling_updates.ipynb b/notebooks/rolling_updates.ipynb index 9f9437e47c..81deb67290 100644 --- a/notebooks/rolling_updates.ipynb +++ b/notebooks/rolling_updates.ipynb @@ -128,13 +128,13 @@ "outputs": [], "source": [ "for i in range(60):\n", - " state=!kubectl get sdep fixed -o jsonpath='{.status.state}'\n", - " state=state[0]\n", + " state = !kubectl get sdep fixed -o jsonpath='{.status.state}'\n", + " state = state[0]\n", " print(state)\n", - " if state==\"Available\":\n", + " if state == \"Available\":\n", " break\n", " time.sleep(1)\n", - "assert(state==\"Available\")" + "assert state == \"Available\"" ] }, { @@ -205,17 +205,17 @@ "metadata": {}, "outputs": [], "source": [ - "time.sleep(5) # To allow operator to start the update\n", + "time.sleep(5) # To allow operator to start the update\n", "for i in range(120):\n", - " responseRaw=!curl -s -d '{\"data\": {\"ndarray\":[[1.0, 2.0, 5.0]]}}' -X POST http://localhost:8003/seldon/seldon/fixed/api/v1.0/predictions -H \"Content-Type: application/json\"\n", + " responseRaw = !curl -s -d '{\"data\": {\"ndarray\":[[1.0, 2.0, 5.0]]}}' -X POST http://localhost:8003/seldon/seldon/fixed/api/v1.0/predictions -H \"Content-Type: application/json\"\n", " try:\n", " response = json.loads(responseRaw[0])\n", " except:\n", - " print(\"Failed to parse json\",responseRaw)\n", + " print(\"Failed to parse json\", responseRaw)\n", " continue\n", - " assert(response['data']['ndarray'][0]==1 or response['data']['ndarray'][0]==5)\n", - " jsonRaw=!kubectl get deploy -l seldon-deployment-id=fixed -o json\n", - " data=\"\".join(jsonRaw)\n", + " assert response[\"data\"][\"ndarray\"][0] == 1 or response[\"data\"][\"ndarray\"][0] == 5\n", + " jsonRaw = !kubectl get deploy -l seldon-deployment-id=fixed -o json\n", + " data = \"\".join(jsonRaw)\n", " resources = json.loads(data)\n", " numReplicas = int(resources[\"items\"][0][\"status\"][\"replicas\"])\n", " if numReplicas == 3:\n", @@ -317,13 +317,13 @@ "outputs": [], "source": [ "for i in range(60):\n", - " state=!kubectl get sdep fixed -o jsonpath='{.status.state}'\n", - " state=state[0]\n", + " state = !kubectl get sdep fixed -o jsonpath='{.status.state}'\n", + " state = state[0]\n", " print(state)\n", - " if state==\"Available\":\n", + " if state == \"Available\":\n", " break\n", " time.sleep(1)\n", - "assert(state==\"Available\")" + "assert state == \"Available\"" ] }, { @@ -394,17 +394,17 @@ "metadata": {}, "outputs": [], "source": [ - "time.sleep(5) # To allow operator to start the update\n", + "time.sleep(5) # To allow operator to start the update\n", "for i in range(120):\n", - " responseRaw=!curl -s -d '{\"data\": {\"ndarray\":[[1.0, 2.0, 5.0]]}}' -X POST http://localhost:8003/seldon/seldon/fixed/api/v1.0/predictions -H \"Content-Type: application/json\"\n", + " responseRaw = !curl -s -d '{\"data\": {\"ndarray\":[[1.0, 2.0, 5.0]]}}' -X POST http://localhost:8003/seldon/seldon/fixed/api/v1.0/predictions -H \"Content-Type: application/json\"\n", " try:\n", " response = json.loads(responseRaw[0])\n", " except:\n", - " print(\"Failed to parse json\",responseRaw)\n", + " print(\"Failed to parse json\", responseRaw)\n", " continue\n", - " assert(response['data']['ndarray'][0]==1 or response['data']['ndarray'][0]==5)\n", - " jsonRaw=!kubectl get deploy -l seldon-deployment-id=fixed -o json\n", - " data=\"\".join(jsonRaw)\n", + " assert response[\"data\"][\"ndarray\"][0] == 1 or response[\"data\"][\"ndarray\"][0] == 5\n", + " jsonRaw = !kubectl get deploy -l seldon-deployment-id=fixed -o json\n", + " data = \"\".join(jsonRaw)\n", " resources = json.loads(data)\n", " numReplicas = int(resources[\"items\"][0][\"status\"][\"replicas\"])\n", " if numReplicas == 4:\n", @@ -435,17 +435,17 @@ "metadata": {}, "outputs": [], "source": [ - "time.sleep(5) # To allow operator to start the update\n", + "time.sleep(5) # To allow operator to start the update\n", "for i in range(120):\n", - " responseRaw=!curl -s -d '{\"data\": {\"ndarray\":[[1.0, 2.0, 5.0]]}}' -X POST http://localhost:8003/seldon/seldon/fixed/api/v1.0/predictions -H \"Content-Type: application/json\"\n", + " responseRaw = !curl -s -d '{\"data\": {\"ndarray\":[[1.0, 2.0, 5.0]]}}' -X POST http://localhost:8003/seldon/seldon/fixed/api/v1.0/predictions -H \"Content-Type: application/json\"\n", " try:\n", " response = json.loads(responseRaw[0])\n", " except:\n", - " print(\"Failed to parse json\",responseRaw)\n", + " print(\"Failed to parse json\", responseRaw)\n", " continue\n", - " assert(response['data']['ndarray'][0]==1 or response['data']['ndarray'][0]==5)\n", - " jsonRaw=!kubectl get deploy -l seldon-deployment-id=fixed -o json\n", - " data=\"\".join(jsonRaw)\n", + " assert response[\"data\"][\"ndarray\"][0] == 1 or response[\"data\"][\"ndarray\"][0] == 5\n", + " jsonRaw = !kubectl get deploy -l seldon-deployment-id=fixed -o json\n", + " data = \"\".join(jsonRaw)\n", " resources = json.loads(data)\n", " numReplicas = int(resources[\"items\"][0][\"status\"][\"replicas\"])\n", " if numReplicas == 2:\n", @@ -535,13 +535,13 @@ "outputs": [], "source": [ "for i in range(60):\n", - " state=!kubectl get sdep fixed -o jsonpath='{.status.state}'\n", - " state=state[0]\n", + " state = !kubectl get sdep fixed -o jsonpath='{.status.state}'\n", + " state = state[0]\n", " print(state)\n", - " if state==\"Available\":\n", + " if state == \"Available\":\n", " break\n", " time.sleep(1)\n", - "assert(state==\"Available\")" + "assert state == \"Available\"" ] }, { @@ -614,17 +614,17 @@ "metadata": {}, "outputs": [], "source": [ - "time.sleep(5) # To allow operator to start the update\n", + "time.sleep(5) # To allow operator to start the update\n", "for i in range(120):\n", - " responseRaw=!curl -s -d '{\"data\": {\"ndarray\":[[1.0, 2.0, 5.0]]}}' -X POST http://localhost:8003/seldon/seldon/fixed/api/v1.0/predictions -H \"Content-Type: application/json\"\n", + " responseRaw = !curl -s -d '{\"data\": {\"ndarray\":[[1.0, 2.0, 5.0]]}}' -X POST http://localhost:8003/seldon/seldon/fixed/api/v1.0/predictions -H \"Content-Type: application/json\"\n", " try:\n", " response = json.loads(responseRaw[0])\n", " except:\n", - " print(\"Failed to parse json\",responseRaw)\n", - " continue \n", - " assert(response['data']['ndarray'][0]==1 or response['data']['ndarray'][0]==5)\n", - " jsonRaw=!kubectl get deploy -l seldon-deployment-id=fixed -o json\n", - " data=\"\".join(jsonRaw)\n", + " print(\"Failed to parse json\", responseRaw)\n", + " continue\n", + " assert response[\"data\"][\"ndarray\"][0] == 1 or response[\"data\"][\"ndarray\"][0] == 5\n", + " jsonRaw = !kubectl get deploy -l seldon-deployment-id=fixed -o json\n", + " data = \"\".join(jsonRaw)\n", " resources = json.loads(data)\n", " numReplicas = int(resources[\"items\"][0][\"status\"][\"replicas\"])\n", " if numReplicas == 1:\n", @@ -724,13 +724,13 @@ "outputs": [], "source": [ "for i in range(60):\n", - " state=!kubectl get sdep fixed -o jsonpath='{.status.state}'\n", - " state=state[0]\n", + " state = !kubectl get sdep fixed -o jsonpath='{.status.state}'\n", + " state = state[0]\n", " print(state)\n", - " if state==\"Available\":\n", + " if state == \"Available\":\n", " break\n", " time.sleep(1)\n", - "assert(state==\"Available\")" + "assert state == \"Available\"" ] }, { @@ -808,17 +808,17 @@ "metadata": {}, "outputs": [], "source": [ - "time.sleep(5) # To allow operator to start the update\n", + "time.sleep(5) # To allow operator to start the update\n", "for i in range(120):\n", - " responseRaw=!curl -s -d '{\"data\": {\"ndarray\":[[1.0, 2.0, 5.0]]}}' -X POST http://localhost:8003/seldon/seldon/fixed/api/v1.0/predictions -H \"Content-Type: application/json\"\n", + " responseRaw = !curl -s -d '{\"data\": {\"ndarray\":[[1.0, 2.0, 5.0]]}}' -X POST http://localhost:8003/seldon/seldon/fixed/api/v1.0/predictions -H \"Content-Type: application/json\"\n", " try:\n", " response = json.loads(responseRaw[0])\n", " except:\n", - " print(\"Failed to parse json\",responseRaw)\n", + " print(\"Failed to parse json\", responseRaw)\n", " continue\n", - " assert(response['data']['ndarray'][0]==1 or response['data']['ndarray'][0]==5)\n", - " jsonRaw=!kubectl get deploy -l seldon-deployment-id=fixed -o json\n", - " data=\"\".join(jsonRaw)\n", + " assert response[\"data\"][\"ndarray\"][0] == 1 or response[\"data\"][\"ndarray\"][0] == 5\n", + " jsonRaw = !kubectl get deploy -l seldon-deployment-id=fixed -o json\n", + " data = \"\".join(jsonRaw)\n", " resources = json.loads(data)\n", " numReplicas = int(resources[\"items\"][0][\"status\"][\"replicas\"])\n", " if numReplicas == 1:\n", @@ -911,13 +911,13 @@ "outputs": [], "source": [ "for i in range(60):\n", - " state=!kubectl get sdep fixed -o jsonpath='{.status.state}'\n", - " state=state[0]\n", + " state = !kubectl get sdep fixed -o jsonpath='{.status.state}'\n", + " state = state[0]\n", " print(state)\n", - " if state==\"Available\":\n", + " if state == \"Available\":\n", " break\n", " time.sleep(1)\n", - "assert(state==\"Available\")" + "assert state == \"Available\"" ] }, { @@ -993,17 +993,17 @@ "metadata": {}, "outputs": [], "source": [ - "time.sleep(5) # To allow operator to start the update\n", + "time.sleep(5) # To allow operator to start the update\n", "for i in range(120):\n", - " responseRaw=!curl -s -d '{\"data\": {\"ndarray\":[[1.0, 2.0, 5.0]]}}' -X POST http://localhost:8003/seldon/seldon/fixed/api/v1.0/predictions -H \"Content-Type: application/json\"\n", + " responseRaw = !curl -s -d '{\"data\": {\"ndarray\":[[1.0, 2.0, 5.0]]}}' -X POST http://localhost:8003/seldon/seldon/fixed/api/v1.0/predictions -H \"Content-Type: application/json\"\n", " try:\n", " response = json.loads(responseRaw[0])\n", " except:\n", - " print(\"Failed to parse json\",responseRaw)\n", + " print(\"Failed to parse json\", responseRaw)\n", " continue\n", - " assert(response['data']['ndarray'][0]==1 or response['data']['ndarray'][0]==5)\n", - " jsonRaw=!kubectl get deploy -l seldon-deployment-id=fixed -o json\n", - " data=\"\".join(jsonRaw)\n", + " assert response[\"data\"][\"ndarray\"][0] == 1 or response[\"data\"][\"ndarray\"][0] == 5\n", + " jsonRaw = !kubectl get deploy -l seldon-deployment-id=fixed -o json\n", + " data = \"\".join(jsonRaw)\n", " resources = json.loads(data)\n", " numReplicas = int(resources[\"items\"][0][\"status\"][\"replicas\"])\n", " if numReplicas == 3:\n", @@ -1113,13 +1113,13 @@ "outputs": [], "source": [ "for i in range(60):\n", - " state=!kubectl get sdep fixed -o jsonpath='{.status.state}'\n", - " state=state[0]\n", + " state = !kubectl get sdep fixed -o jsonpath='{.status.state}'\n", + " state = state[0]\n", " print(state)\n", - " if state==\"Available\":\n", + " if state == \"Available\":\n", " break\n", " time.sleep(1)\n", - "assert(state==\"Available\")" + "assert state == \"Available\"" ] }, { @@ -1212,17 +1212,17 @@ "metadata": {}, "outputs": [], "source": [ - "time.sleep(5) # To allow operator to start the update\n", + "time.sleep(5) # To allow operator to start the update\n", "for i in range(120):\n", - " responseRaw=!curl -s -d '{\"data\": {\"ndarray\":[[1.0, 2.0, 5.0]]}}' -X POST http://localhost:8003/seldon/seldon/fixed/api/v1.0/predictions -H \"Content-Type: application/json\"\n", + " responseRaw = !curl -s -d '{\"data\": {\"ndarray\":[[1.0, 2.0, 5.0]]}}' -X POST http://localhost:8003/seldon/seldon/fixed/api/v1.0/predictions -H \"Content-Type: application/json\"\n", " try:\n", " response = json.loads(responseRaw[0])\n", " except:\n", - " print(\"Failed to parse json\",responseRaw)\n", + " print(\"Failed to parse json\", responseRaw)\n", " continue\n", - " assert(response['data']['ndarray'][0]==1 or response['data']['ndarray'][0]==5)\n", - " jsonRaw=!kubectl get deploy -l seldon-deployment-id=fixed -o json\n", - " data=\"\".join(jsonRaw)\n", + " assert response[\"data\"][\"ndarray\"][0] == 1 or response[\"data\"][\"ndarray\"][0] == 5\n", + " jsonRaw = !kubectl get deploy -l seldon-deployment-id=fixed -o json\n", + " data = \"\".join(jsonRaw)\n", " resources = json.loads(data)\n", " numReplicas = int(resources[\"items\"][0][\"status\"][\"replicas\"])\n", " if numReplicas == 3:\n", @@ -1310,13 +1310,13 @@ "outputs": [], "source": [ "for i in range(60):\n", - " state=!kubectl get sdep fixed -o jsonpath='{.status.state}'\n", - " state=state[0]\n", + " state = !kubectl get sdep fixed -o jsonpath='{.status.state}'\n", + " state = state[0]\n", " print(state)\n", - " if state==\"Available\":\n", + " if state == \"Available\":\n", " break\n", " time.sleep(1)\n", - "assert(state==\"Available\")" + "assert state == \"Available\"" ] }, { @@ -1382,15 +1382,15 @@ "source": [ "time.sleep(5)\n", "for i in range(120):\n", - " responseRaw=!curl -s -d '{\"data\": {\"ndarray\":[[1.0, 2.0, 5.0]]}}' -X POST http://localhost:8003/seldon/seldon/fixed/api/v1.0/predictions -H \"Content-Type: application/json\"\n", + " responseRaw = !curl -s -d '{\"data\": {\"ndarray\":[[1.0, 2.0, 5.0]]}}' -X POST http://localhost:8003/seldon/seldon/fixed/api/v1.0/predictions -H \"Content-Type: application/json\"\n", " try:\n", " response = json.loads(responseRaw[0])\n", " except:\n", - " print(\"Failed to parse json\",responseRaw)\n", + " print(\"Failed to parse json\", responseRaw)\n", " continue\n", - " assert(response['data']['ndarray'][0]==1 or response['data']['ndarray'][0]==5)\n", - " jsonRaw=!kubectl get deploy -l seldon-deployment-id=fixed -o json\n", - " data=\"\".join(jsonRaw)\n", + " assert response[\"data\"][\"ndarray\"][0] == 1 or response[\"data\"][\"ndarray\"][0] == 5\n", + " jsonRaw = !kubectl get deploy -l seldon-deployment-id=fixed -o json\n", + " data = \"\".join(jsonRaw)\n", " resources = json.loads(data)\n", " numItems = len(resources[\"items\"])\n", " if numItems == 1:\n", diff --git a/notebooks/scale.ipynb b/notebooks/scale.ipynb index 8838ad04c6..e5c69819e7 100644 --- a/notebooks/scale.ipynb +++ b/notebooks/scale.ipynb @@ -162,9 +162,9 @@ "metadata": {}, "outputs": [], "source": [ - "classifierReplicas=!kubectl get deploy test-replicas-example-0-classifier -o jsonpath='{.status.replicas}'\n", + "classifierReplicas = !kubectl get deploy test-replicas-example-0-classifier -o jsonpath='{.status.replicas}'\n", "classifierReplicas = int(classifierReplicas[0])\n", - "assert(classifierReplicas==2)" + "assert classifierReplicas == 2" ] }, { @@ -173,9 +173,9 @@ "metadata": {}, "outputs": [], "source": [ - "classifier2Replicas=!kubectl get deploy test-replicas-example-1-classifier2 -o jsonpath='{.status.replicas}'\n", + "classifier2Replicas = !kubectl get deploy test-replicas-example-1-classifier2 -o jsonpath='{.status.replicas}'\n", "classifier2Replicas = int(classifier2Replicas[0])\n", - "assert(classifier2Replicas==3)" + "assert classifier2Replicas == 3" ] }, { @@ -184,9 +184,9 @@ "metadata": {}, "outputs": [], "source": [ - "classifier3Replicas=!kubectl get deploy test-replicas-example2-0-classifier3 -o jsonpath='{.status.replicas}'\n", + "classifier3Replicas = !kubectl get deploy test-replicas-example2-0-classifier3 -o jsonpath='{.status.replicas}'\n", "classifier3Replicas = int(classifier3Replicas[0])\n", - "assert(classifier3Replicas==1)" + "assert classifier3Replicas == 1" ] }, { @@ -299,9 +299,9 @@ "metadata": {}, "outputs": [], "source": [ - "replicas=!kubectl get deploy seldon-scale-example-0-classifier -o jsonpath='{.status.replicas}'\n", + "replicas = !kubectl get deploy seldon-scale-example-0-classifier -o jsonpath='{.status.replicas}'\n", "replicas = int(replicas[0])\n", - "assert(replicas==1)" + "assert replicas == 1" ] }, { @@ -342,9 +342,9 @@ "metadata": {}, "outputs": [], "source": [ - "replicas=!kubectl get deploy seldon-scale-example-0-classifier -o jsonpath='{.status.replicas}'\n", + "replicas = !kubectl get deploy seldon-scale-example-0-classifier -o jsonpath='{.status.replicas}'\n", "replicas = int(replicas[0])\n", - "assert(replicas==2)" + "assert replicas == 2" ] }, { diff --git a/notebooks/seldon_client.ipynb b/notebooks/seldon_client.ipynb index 203634f7e2..0db0119ea8 100644 --- a/notebooks/seldon_client.ipynb +++ b/notebooks/seldon_client.ipynb @@ -24,8 +24,8 @@ "metadata": {}, "outputs": [], "source": [ - "INGRESS_HOST=!kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}'\n", - "ISTIO_GATEWAY=INGRESS_HOST[0]" + "INGRESS_HOST = !kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}'\n", + "ISTIO_GATEWAY = INGRESS_HOST[0]" ] }, { diff --git a/notebooks/server_examples.ipynb b/notebooks/server_examples.ipynb index 0d9d917329..3c60cc1198 100644 --- a/notebooks/server_examples.ipynb +++ b/notebooks/server_examples.ipynb @@ -1049,110 +1049,86 @@ "import requests\n", "\n", "inference_request = {\n", - " \"parameters\": {\n", - " \"content_type\": \"pd\"\n", - " },\n", + " \"parameters\": {\"content_type\": \"pd\"},\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", + " \"name\": \"fixed acidity\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [7.4],\n", + " \"parameters\": {\"content_type\": \"np\"},\n", " },\n", " {\n", - " \"name\": \"volatile acidity\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [0.7000],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", + " \"name\": \"volatile acidity\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [0.7000],\n", + " \"parameters\": {\"content_type\": \"np\"},\n", " },\n", " {\n", - " \"name\": \"citric acidity\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [0],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", + " \"name\": \"citric acidity\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [0],\n", + " \"parameters\": {\"content_type\": \"np\"},\n", " },\n", " {\n", - " \"name\": \"residual sugar\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [1.9],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", + " \"name\": \"residual sugar\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [1.9],\n", + " \"parameters\": {\"content_type\": \"np\"},\n", " },\n", " {\n", - " \"name\": \"chlorides\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [0.076],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", + " \"name\": \"chlorides\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [0.076],\n", + " \"parameters\": {\"content_type\": \"np\"},\n", " },\n", " {\n", - " \"name\": \"free sulfur dioxide\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [11],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", + " \"name\": \"free sulfur dioxide\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [11],\n", + " \"parameters\": {\"content_type\": \"np\"},\n", " },\n", " {\n", - " \"name\": \"total sulfur dioxide\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [34],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", + " \"name\": \"total sulfur dioxide\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [34],\n", + " \"parameters\": {\"content_type\": \"np\"},\n", " },\n", " {\n", - " \"name\": \"density\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [0.9978],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", + " \"name\": \"density\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [0.9978],\n", + " \"parameters\": {\"content_type\": \"np\"},\n", " },\n", " {\n", - " \"name\": \"pH\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [3.51],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", + " \"name\": \"pH\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [3.51],\n", + " \"parameters\": {\"content_type\": \"np\"},\n", " },\n", " {\n", - " \"name\": \"sulphates\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [0.56],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", + " \"name\": \"sulphates\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [0.56],\n", + " \"parameters\": {\"content_type\": \"np\"},\n", " },\n", " {\n", - " \"name\": \"alcohol\",\n", - " \"shape\": [1],\n", - " \"datatype\": \"FP32\",\n", - " \"data\": [9.4],\n", - " \"parameters\": {\n", - " \"content_type\": \"np\"\n", - " }\n", + " \"name\": \"alcohol\",\n", + " \"shape\": [1],\n", + " \"datatype\": \"FP32\",\n", + " \"data\": [9.4],\n", + " \"parameters\": {\"content_type\": \"np\"},\n", " },\n", - " ]\n", + " ],\n", "}\n", "\n", "endpoint = \"http://localhost:8003/seldon/seldon/mlflow/v2/models/infer\"\n", diff --git a/notebooks/timeouts.ipynb b/notebooks/timeouts.ipynb index a5efee02f4..5c51c71945 100644 --- a/notebooks/timeouts.ipynb +++ b/notebooks/timeouts.ipynb @@ -92,8 +92,8 @@ } ], "source": [ - "VERSION=!cat ../version.txt\n", - "VERSION=VERSION[0]\n", + "VERSION = !cat ../version.txt\n", + "VERSION = VERSION[0]\n", "VERSION" ] }, diff --git a/python/Makefile b/python/Makefile index 016a6c0664..89cf4ab11a 100644 --- a/python/Makefile +++ b/python/Makefile @@ -104,12 +104,10 @@ fmt: isort \ ./ ../testing/scripts ../operator/helm ../operator/hack \ --skip proto --skip seldon_core/proto --skip .eggs --skip .tox - nbqa black \ - ../ --nbqa-skip-bad-cells --nbqa-mutate \ - --nbqa-exclude "(proto|seldon_core/proto/|.eggs|.tox|_README\.ipynb)" - nbqa isort \ - ../ --profile black --nbqa-skip-bad-cells --nbqa-mutate \ + nbqa black ../ \ --nbqa-exclude "(proto|seldon_core/proto/|.eggs|.tox|_README\.ipynb)" + nbqa isort ../ \ + --profile black --nbqa-exclude "(proto|seldon_core/proto/|.eggs|.tox|_README\.ipynb)" lint: licenses black \ diff --git a/python/requirements-dev.txt b/python/requirements-dev.txt index ef3749a658..551aa22762 100644 --- a/python/requirements-dev.txt +++ b/python/requirements-dev.txt @@ -1,5 +1,5 @@ # Test and linters -black==20.8b1 +black==21.7b0 coverage==5.4 # 2nd lvl dep on cov required to avoid sqllite dep flake8==3.9.0 grpcio-tools==1.37.1 @@ -13,5 +13,5 @@ pytest-cov==2.10.1 pytest==6.2.2 pytest-mock==3.6.1 tenacity==6.3.1 # tenacity - used for smart retrying -nbqa==0.13.1 +nbqa==1.1.0 tox<4.0.0 diff --git a/testing/benchmarking/python/python_kmp_affinity.ipynb b/testing/benchmarking/python/python_kmp_affinity.ipynb index 325944df8b..67201424cf 100644 --- a/testing/benchmarking/python/python_kmp_affinity.ipynb +++ b/testing/benchmarking/python/python_kmp_affinity.ipynb @@ -92,8 +92,8 @@ "metadata": {}, "outputs": [], "source": [ - "KMP_AFFINITY=\"verbose,disabled\"\n", - "OMP_NUM_THREADS=1" + "KMP_AFFINITY = \"verbose,disabled\"\n", + "OMP_NUM_THREADS = 1" ] }, { @@ -260,8 +260,8 @@ "metadata": {}, "outputs": [], "source": [ - "workers=10\n", - "duration=\"60s\"" + "workers = 10\n", + "duration = \"60s\"" ] }, { diff --git a/testing/benchmarking/python/python_serialization.ipynb b/testing/benchmarking/python/python_serialization.ipynb index 735032f777..0895fe466b 100644 --- a/testing/benchmarking/python/python_serialization.ipynb +++ b/testing/benchmarking/python/python_serialization.ipynb @@ -91,8 +91,8 @@ } ], "source": [ - "VERSION=!cat ../../../version.txt\n", - "VERSION=VERSION[0]\n", + "VERSION = !cat ../../../version.txt\n", + "VERSION = VERSION[0]\n", "VERSION" ] }, diff --git a/testing/benchmarking/svcOrch/svcOrch.ipynb b/testing/benchmarking/svcOrch/svcOrch.ipynb index c619a9920c..bdc6277118 100644 --- a/testing/benchmarking/svcOrch/svcOrch.ipynb +++ b/testing/benchmarking/svcOrch/svcOrch.ipynb @@ -69,15 +69,15 @@ } ], "source": [ - "raw=!kubectl get nodes -o jsonpath='{.items[0].metadata.name}'\n", + "raw = !kubectl get nodes -o jsonpath='{.items[0].metadata.name}'\n", "firstNode = raw[0]\n", - "raw=!kubectl get nodes -o jsonpath='{.items[1].metadata.name}'\n", + "raw = !kubectl get nodes -o jsonpath='{.items[1].metadata.name}'\n", "secondNode = raw[0]\n", - "raw=!kubectl get nodes -o jsonpath='{.items[2].metadata.name}'\n", + "raw = !kubectl get nodes -o jsonpath='{.items[2].metadata.name}'\n", "thirdNode = raw[0]\n", "!kubectl taint nodes '{firstNode}' loadtester=active:NoSchedule\n", - "!kubectl taint nodes '{secondNode}' model=active:NoSchedule \n", - "!kubectl taint nodes '{thirdNode}' model=active:NoSchedule " + "!kubectl taint nodes '{secondNode}' model=active:NoSchedule\n", + "!kubectl taint nodes '{thirdNode}' model=active:NoSchedule" ] }, { diff --git a/testing/benchmarking/tensorflow/tensorflow.ipynb b/testing/benchmarking/tensorflow/tensorflow.ipynb index 95abd21ad3..afb70ec435 100644 --- a/testing/benchmarking/tensorflow/tensorflow.ipynb +++ b/testing/benchmarking/tensorflow/tensorflow.ipynb @@ -91,15 +91,15 @@ } ], "source": [ - "raw=!kubectl get nodes -o jsonpath='{.items[0].metadata.name}'\n", + "raw = !kubectl get nodes -o jsonpath='{.items[0].metadata.name}'\n", "firstNode = raw[0]\n", - "raw=!kubectl get nodes -o jsonpath='{.items[1].metadata.name}'\n", + "raw = !kubectl get nodes -o jsonpath='{.items[1].metadata.name}'\n", "secondNode = raw[0]\n", - "raw=!kubectl get nodes -o jsonpath='{.items[2].metadata.name}'\n", + "raw = !kubectl get nodes -o jsonpath='{.items[2].metadata.name}'\n", "thirdNode = raw[0]\n", "!kubectl taint nodes '{firstNode}' loadtester=active:NoSchedule\n", - "!kubectl taint nodes '{secondNode}' model=active:NoSchedule \n", - "!kubectl taint nodes '{thirdNode}' model=active:NoSchedule " + "!kubectl taint nodes '{secondNode}' model=active:NoSchedule\n", + "!kubectl taint nodes '{thirdNode}' model=active:NoSchedule" ] }, {