From a97d6c67a1f21669cfdd249f8d0ad33cb827bdf4 Mon Sep 17 00:00:00 2001 From: kaihsun Date: Tue, 20 Jun 2023 19:00:16 +0000 Subject: [PATCH 01/10] mobilenet --- docs/guidance/mobilenet-rayservice.md | 42 +++++++++++ .../config/samples/ray-service.mobilenet.yaml | 72 +++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 docs/guidance/mobilenet-rayservice.md create mode 100644 ray-operator/config/samples/ray-service.mobilenet.yaml diff --git a/docs/guidance/mobilenet-rayservice.md b/docs/guidance/mobilenet-rayservice.md new file mode 100644 index 0000000000..723fd566e0 --- /dev/null +++ b/docs/guidance/mobilenet-rayservice.md @@ -0,0 +1,42 @@ +# RayService: MobileNet example + +Both Python scripts for Ray Serve and sending requests are in the repository [kevin85421/ray-serve-examples](https://github.com/kevin85421/ray-serve-examples). + +## Step 1: Create a Kubernetes cluster with Kind. + +```sh +kind create cluster --image=kindest/node:v1.23.0 +``` + +## Step 2: Install KubeRay operator + +Follow this [document](../../helm-chart/kuberay-operator/README.md) to install the latest stable KubeRay operator via Helm repository. + +## Step 3: Install a RayService + +```sh +# path: ray-operator/config/samples/ +kubectl apply -f ray-service.mobilenet.yaml +``` + +* The [mobilenet.py](https://github.com/kevin85421/ray-serve-examples/blob/main/mobilenet.py) requires `tensorflow` as a dependency. Hence, the YAML file uses `rayproject/ray-ml:2.5.0` instead of `rayproject/ray:2.5.0`. +* `python-multipart` is required for the request parsing function `starlette.requests.form()`, so the YAML file includes `python-multipart` in the runtime environment. + +## Step 4: Forward the port of Serve + +```sh +kubectl port-forward svc/rayservice-mobilenet-serve-svc 8000 +``` + +Note that the Serve service will be created after the Serve applications are ready and running. This process may take some time. + +## Step 5: Send a request to the ImageClassifier + +* Step 5.1: Prepare an image file (e.g. golden.png) +* Step 5.2: Update `image_path` in [mobilenet_req.py](https://github.com/kevin85421/ray-serve-examples/blob/main/mobilenet_req.py +) +* Step 5.3: Send a request to the ImageClassifier. + ```sh + python3 mobilenet_req.py + # sample output: {"prediction":["n02099601","golden_retriever",0.17944198846817017]} + ``` \ No newline at end of file diff --git a/ray-operator/config/samples/ray-service.mobilenet.yaml b/ray-operator/config/samples/ray-service.mobilenet.yaml new file mode 100644 index 0000000000..48d8c9d0de --- /dev/null +++ b/ray-operator/config/samples/ray-service.mobilenet.yaml @@ -0,0 +1,72 @@ +apiVersion: ray.io/v1alpha1 +kind: RayService +metadata: + name: rayservice-mobilenet +spec: + serviceUnhealthySecondThreshold: 300 # Config for the health check threshold for service. Default value is 60. + deploymentUnhealthySecondThreshold: 300 # Config for the health check threshold for deployments. Default value is 60. + serveConfig: + importPath: mobilenet.graph + runtimeEnv: | + working_dir: "https://github.com/kevin85421/ray-serve-examples/archive/main.zip" + pip: ["python-multipart"] + rayClusterConfig: + rayVersion: '2.5.0' # should match the Ray version in the image of the containers + ######################headGroupSpecs################################# + # Ray head pod template. + headGroupSpec: + # The `rayStartParams` are used to configure the `ray start` command. + # See https://github.com/ray-project/kuberay/blob/master/docs/guidance/rayStartParams.md for the default settings of `rayStartParams` in KubeRay. + # See https://docs.ray.io/en/latest/cluster/cli.html#ray-start for all available options in `rayStartParams`. + rayStartParams: + dashboard-host: '0.0.0.0' + #pod template + template: + spec: + containers: + - name: ray-head + image: rayproject/ray-ml:2.5.0 + resources: + limits: + cpu: 2 + memory: 8Gi + requests: + cpu: 2 + memory: 8Gi + ports: + - containerPort: 6379 + name: gcs-server + - containerPort: 8265 # Ray dashboard + name: dashboard + - containerPort: 10001 + name: client + - containerPort: 8000 + name: serve + workerGroupSpecs: + # the pod replicas in this group typed worker + - replicas: 1 + minReplicas: 1 + maxReplicas: 5 + # logical group name, for this called small-group, also can be functional + groupName: worker + # The `rayStartParams` are used to configure the `ray start` command. + # See https://github.com/ray-project/kuberay/blob/master/docs/guidance/rayStartParams.md for the default settings of `rayStartParams` in KubeRay. + # See https://docs.ray.io/en/latest/cluster/cli.html#ray-start for all available options in `rayStartParams`. + rayStartParams: {} + #pod template + template: + spec: + containers: + - name: ray-worker # must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc' + image: rayproject/ray-ml:2.5.0 + lifecycle: + preStop: + exec: + command: ["/bin/sh","-c","ray stop"] + resources: + limits: + cpu: "2" + memory: "8Gi" + requests: + cpu: "2" + memory: "8Gi" From 264ec5725c795db18b53b2c6a6339cceccd931c5 Mon Sep 17 00:00:00 2001 From: kaihsun Date: Wed, 21 Jun 2023 00:58:04 +0000 Subject: [PATCH 02/10] update --- docs/guidance/mobilenet-rayservice.md | 7 +++---- ray-operator/config/samples/ray-service.mobilenet.yaml | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/guidance/mobilenet-rayservice.md b/docs/guidance/mobilenet-rayservice.md index 723fd566e0..8abb948f6a 100644 --- a/docs/guidance/mobilenet-rayservice.md +++ b/docs/guidance/mobilenet-rayservice.md @@ -1,6 +1,6 @@ # RayService: MobileNet example -Both Python scripts for Ray Serve and sending requests are in the repository [kevin85421/ray-serve-examples](https://github.com/kevin85421/ray-serve-examples). +Both Python scripts for Ray Serve and sending requests are in the repository [ray-project/serve_config_examples](https://github.com/ray-project/serve_config_examples). ## Step 1: Create a Kubernetes cluster with Kind. @@ -33,10 +33,9 @@ Note that the Serve service will be created after the Serve applications are rea ## Step 5: Send a request to the ImageClassifier * Step 5.1: Prepare an image file (e.g. golden.png) -* Step 5.2: Update `image_path` in [mobilenet_req.py](https://github.com/kevin85421/ray-serve-examples/blob/main/mobilenet_req.py -) +* Step 5.2: Update `image_path` in [mobilenet_req.py](https://github.com/ray-project/serve_config_examples/blob/master/mobilenet/mobilenet_req.py) * Step 5.3: Send a request to the ImageClassifier. ```sh python3 mobilenet_req.py # sample output: {"prediction":["n02099601","golden_retriever",0.17944198846817017]} - ``` \ No newline at end of file + ``` diff --git a/ray-operator/config/samples/ray-service.mobilenet.yaml b/ray-operator/config/samples/ray-service.mobilenet.yaml index 48d8c9d0de..3ddded5ca5 100644 --- a/ray-operator/config/samples/ray-service.mobilenet.yaml +++ b/ray-operator/config/samples/ray-service.mobilenet.yaml @@ -6,9 +6,9 @@ spec: serviceUnhealthySecondThreshold: 300 # Config for the health check threshold for service. Default value is 60. deploymentUnhealthySecondThreshold: 300 # Config for the health check threshold for deployments. Default value is 60. serveConfig: - importPath: mobilenet.graph + importPath: mobilenet.mobilenet:app runtimeEnv: | - working_dir: "https://github.com/kevin85421/ray-serve-examples/archive/main.zip" + working_dir: "https://github.com/ray-project/serve_config_examples/archive/master.zip" pip: ["python-multipart"] rayClusterConfig: rayVersion: '2.5.0' # should match the Ray version in the image of the containers From 57339ac049fb55236a45436d03fb6fa74dd25040 Mon Sep 17 00:00:00 2001 From: Kai-Hsun Chen Date: Tue, 20 Jun 2023 17:58:28 -0700 Subject: [PATCH 03/10] Update docs/guidance/mobilenet-rayservice.md Co-authored-by: shrekris-anyscale <92341594+shrekris-anyscale@users.noreply.github.com> Signed-off-by: Kai-Hsun Chen --- docs/guidance/mobilenet-rayservice.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guidance/mobilenet-rayservice.md b/docs/guidance/mobilenet-rayservice.md index 8abb948f6a..635506c776 100644 --- a/docs/guidance/mobilenet-rayservice.md +++ b/docs/guidance/mobilenet-rayservice.md @@ -10,7 +10,7 @@ kind create cluster --image=kindest/node:v1.23.0 ## Step 2: Install KubeRay operator -Follow this [document](../../helm-chart/kuberay-operator/README.md) to install the latest stable KubeRay operator via Helm repository. +Follow [this document](../../helm-chart/kuberay-operator/README.md) to install the latest stable KubeRay operator via Helm repository. ## Step 3: Install a RayService From 1c00be7f7cce0e2d268101d30fd0be2c660ccfa8 Mon Sep 17 00:00:00 2001 From: Kai-Hsun Chen Date: Tue, 20 Jun 2023 21:18:23 -0700 Subject: [PATCH 04/10] Update docs/guidance/mobilenet-rayservice.md Co-authored-by: shrekris-anyscale <92341594+shrekris-anyscale@users.noreply.github.com> Signed-off-by: Kai-Hsun Chen --- docs/guidance/mobilenet-rayservice.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guidance/mobilenet-rayservice.md b/docs/guidance/mobilenet-rayservice.md index 635506c776..fb07cf8087 100644 --- a/docs/guidance/mobilenet-rayservice.md +++ b/docs/guidance/mobilenet-rayservice.md @@ -34,7 +34,7 @@ Note that the Serve service will be created after the Serve applications are rea * Step 5.1: Prepare an image file (e.g. golden.png) * Step 5.2: Update `image_path` in [mobilenet_req.py](https://github.com/ray-project/serve_config_examples/blob/master/mobilenet/mobilenet_req.py) -* Step 5.3: Send a request to the ImageClassifier. +* Step 5.3: Send a request to the `ImageClassifier`. ```sh python3 mobilenet_req.py # sample output: {"prediction":["n02099601","golden_retriever",0.17944198846817017]} From c9431d28fd2dd135fd1c497afc4c2a3e6ddfe4e2 Mon Sep 17 00:00:00 2001 From: kaihsun Date: Wed, 21 Jun 2023 04:19:58 +0000 Subject: [PATCH 05/10] address comments --- docs/guidance/mobilenet-rayservice.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guidance/mobilenet-rayservice.md b/docs/guidance/mobilenet-rayservice.md index fb07cf8087..2a8c762d38 100644 --- a/docs/guidance/mobilenet-rayservice.md +++ b/docs/guidance/mobilenet-rayservice.md @@ -19,7 +19,7 @@ Follow [this document](../../helm-chart/kuberay-operator/README.md) to install t kubectl apply -f ray-service.mobilenet.yaml ``` -* The [mobilenet.py](https://github.com/kevin85421/ray-serve-examples/blob/main/mobilenet.py) requires `tensorflow` as a dependency. Hence, the YAML file uses `rayproject/ray-ml:2.5.0` instead of `rayproject/ray:2.5.0`. +* The [mobilenet.py](https://github.com/ray-project/serve_config_examples/blob/master/mobilenet/mobilenet.py) file requires `tensorflow` as a dependency. Hence, the YAML file uses `rayproject/ray-ml:2.5.0` instead of `rayproject/ray:2.5.0`. * `python-multipart` is required for the request parsing function `starlette.requests.form()`, so the YAML file includes `python-multipart` in the runtime environment. ## Step 4: Forward the port of Serve @@ -36,6 +36,6 @@ Note that the Serve service will be created after the Serve applications are rea * Step 5.2: Update `image_path` in [mobilenet_req.py](https://github.com/ray-project/serve_config_examples/blob/master/mobilenet/mobilenet_req.py) * Step 5.3: Send a request to the `ImageClassifier`. ```sh - python3 mobilenet_req.py + python mobilenet_req.py # sample output: {"prediction":["n02099601","golden_retriever",0.17944198846817017]} ``` From 4bba967fcf2e7a145a4b404d8e91fa3ff6bc6641 Mon Sep 17 00:00:00 2001 From: kaihsun Date: Wed, 21 Jun 2023 04:44:08 +0000 Subject: [PATCH 06/10] address comments --- docs/guidance/mobilenet-rayservice.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guidance/mobilenet-rayservice.md b/docs/guidance/mobilenet-rayservice.md index 2a8c762d38..e2fd490253 100644 --- a/docs/guidance/mobilenet-rayservice.md +++ b/docs/guidance/mobilenet-rayservice.md @@ -1,6 +1,6 @@ # RayService: MobileNet example -Both Python scripts for Ray Serve and sending requests are in the repository [ray-project/serve_config_examples](https://github.com/ray-project/serve_config_examples). +> **Note:** The Python files for the Ray Serve application and its client are in the repository [ray-project/serve_config_examples](https://github.com/ray-project/serve_config_examples). ## Step 1: Create a Kubernetes cluster with Kind. From feafb3b99cf929477d2124d456dadfd36cc62def Mon Sep 17 00:00:00 2001 From: kaihsun Date: Wed, 21 Jun 2023 05:01:30 +0000 Subject: [PATCH 07/10] address comments --- ray-operator/config/samples/ray-service.mobilenet.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ray-operator/config/samples/ray-service.mobilenet.yaml b/ray-operator/config/samples/ray-service.mobilenet.yaml index 3ddded5ca5..111983acec 100644 --- a/ray-operator/config/samples/ray-service.mobilenet.yaml +++ b/ray-operator/config/samples/ray-service.mobilenet.yaml @@ -9,7 +9,7 @@ spec: importPath: mobilenet.mobilenet:app runtimeEnv: | working_dir: "https://github.com/ray-project/serve_config_examples/archive/master.zip" - pip: ["python-multipart"] + pip: ["python-multipart==0.0.6"] rayClusterConfig: rayVersion: '2.5.0' # should match the Ray version in the image of the containers ######################headGroupSpecs################################# From 317004637c879781737b62fe9cd8455c2bd1c195 Mon Sep 17 00:00:00 2001 From: kaihsun Date: Wed, 21 Jun 2023 05:11:59 +0000 Subject: [PATCH 08/10] update --- docs/guidance/mobilenet-rayservice.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guidance/mobilenet-rayservice.md b/docs/guidance/mobilenet-rayservice.md index e2fd490253..f299189892 100644 --- a/docs/guidance/mobilenet-rayservice.md +++ b/docs/guidance/mobilenet-rayservice.md @@ -28,7 +28,7 @@ kubectl apply -f ray-service.mobilenet.yaml kubectl port-forward svc/rayservice-mobilenet-serve-svc 8000 ``` -Note that the Serve service will be created after the Serve applications are ready and running. This process may take some time. +Note that the Serve service will be created after the Serve applications are ready and running. This process may take approximately 1 minute after all Pods in the RayCluster are running. ## Step 5: Send a request to the ImageClassifier From 13699cd0f6be83f751e848194102d632ce5110cf Mon Sep 17 00:00:00 2001 From: Kai-Hsun Chen Date: Wed, 21 Jun 2023 11:43:24 -0700 Subject: [PATCH 09/10] Update docs/guidance/mobilenet-rayservice.md Co-authored-by: shrekris-anyscale <92341594+shrekris-anyscale@users.noreply.github.com> Signed-off-by: Kai-Hsun Chen --- docs/guidance/mobilenet-rayservice.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guidance/mobilenet-rayservice.md b/docs/guidance/mobilenet-rayservice.md index f299189892..b062424a6a 100644 --- a/docs/guidance/mobilenet-rayservice.md +++ b/docs/guidance/mobilenet-rayservice.md @@ -32,7 +32,7 @@ Note that the Serve service will be created after the Serve applications are rea ## Step 5: Send a request to the ImageClassifier -* Step 5.1: Prepare an image file (e.g. golden.png) +* Step 5.1: Prepare an image file. * Step 5.2: Update `image_path` in [mobilenet_req.py](https://github.com/ray-project/serve_config_examples/blob/master/mobilenet/mobilenet_req.py) * Step 5.3: Send a request to the `ImageClassifier`. ```sh From ced592acd4367cd68b4b5b3953d23016d0a9ab73 Mon Sep 17 00:00:00 2001 From: kaihsun Date: Wed, 21 Jun 2023 18:55:32 +0000 Subject: [PATCH 10/10] update working_dir --- ray-operator/config/samples/ray-service.mobilenet.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ray-operator/config/samples/ray-service.mobilenet.yaml b/ray-operator/config/samples/ray-service.mobilenet.yaml index 111983acec..0df0ffb0d8 100644 --- a/ray-operator/config/samples/ray-service.mobilenet.yaml +++ b/ray-operator/config/samples/ray-service.mobilenet.yaml @@ -8,7 +8,7 @@ spec: serveConfig: importPath: mobilenet.mobilenet:app runtimeEnv: | - working_dir: "https://github.com/ray-project/serve_config_examples/archive/master.zip" + working_dir: "https://github.com/ray-project/serve_config_examples/archive/b393e77bbd6aba0881e3d94c05f968f05a387b96.zip" pip: ["python-multipart==0.0.6"] rayClusterConfig: rayVersion: '2.5.0' # should match the Ray version in the image of the containers