Skip to content

Commit

Permalink
[POC] Run arbitrary bash commands in doc as test
Browse files Browse the repository at this point in the history
Signed-off-by: Chi-Sheng Liu <[email protected]>
  • Loading branch information
MortalHappiness committed Feb 28, 2025
1 parent 02d4a3a commit 8e21aac
Show file tree
Hide file tree
Showing 4 changed files with 325 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/requirements-doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ myst-nb==1.0.0rc0 # Most recent version of myst-nb; pin when new release is made

# Jupyter conversion
jupytext==1.15.2
bash_kernel==0.10.0

# Pin urllib to avoid downstream ssl incompatibility issues
urllib3 < 1.27
Expand Down
1 change: 1 addition & 0 deletions doc/source/cluster/kubernetes/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ Unlike RayJob, which creates a new RayCluster every time a job is submitted, Ray
* [RayCluster Quick Start](kuberay-raycluster-quickstart)
* [RayJob Quick Start](kuberay-rayjob-quickstart)
* [RayService Quick Start](kuberay-rayservice-quickstart)
* [POC mobilenet doc](notebook)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[regex1]
regex: \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z
replace: DATETIME
320 changes: 320 additions & 0 deletions doc/source/cluster/kubernetes/getting-started/notebook.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,320 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "9efb4aca",
"metadata": {},
"source": [
"# Jupyter Notebook"
]
},
{
"cell_type": "markdown",
"id": "a3410414-a4f6-474f-a265-84aa08bce7b8",
"metadata": {},
"source": [
"## Step 1"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "dc64b552-2601-4bed-b7c6-eb9a600583ec",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"nbval-ignore-output",
"remove-output"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Creating cluster \"kind\" ...\n",
" \u001b[32m✓\u001b[0m Ensuring node image (kindest/node:v1.26.0) 🖼\n",
" \u001b[32m✓\u001b[0m Preparing nodes 📦 7l\n",
" \u001b[32m✓\u001b[0m Writing configuration 📜7l\n",
" \u001b[32m✓\u001b[0m Starting control-plane 🕹️7l\n",
" \u001b[32m✓\u001b[0m Installing CNI 🔌7l\n",
" \u001b[32m✓\u001b[0m Installing StorageClass 💾7l\n",
"Set kubectl context to \"kind-kind\"\n",
"You can now use your cluster with:\n",
"\n",
"kubectl cluster-info --context kind-kind\n",
"\n",
"Thanks for using kind! 😊\n"
]
}
],
"source": [
"kind create cluster --image=kindest/node:v1.26.0"
]
},
{
"cell_type": "markdown",
"id": "7fa05d63-cc4b-43d6-bc66-ef7c4d77d969",
"metadata": {},
"source": [
"## Step 2"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "799442de-7fac-42b2-8175-6578d3a537a6",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"nbval-ignore-output",
"remove-output"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"NAME: kuberay-operator\n",
"LAST DEPLOYED: Fri Feb 28 19:31:25 2025\n",
"NAMESPACE: default\n",
"STATUS: deployed\n",
"REVISION: 1\n",
"TEST SUITE: None\n"
]
}
],
"source": [
"helm install kuberay-operator kuberay/kuberay-operator --version 1.3.0"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "03446987-ec21-4f6d-98e9-774fe57cd473",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"nbval-ignore-output",
"remove-cell"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"deployment.apps/kuberay-operator condition met\n"
]
}
],
"source": [
"kubectl wait --for=condition=available deployment/kuberay-operator --timeout=120s"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "6999ac1e-bfa7-4e0c-bbb9-c79f7959346b",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"rayservice.ray.io/rayservice-mobilenet created\n"
]
}
],
"source": [
"kubectl apply -f https://raw.githubusercontent.com/ray-project/kuberay/v1.3.0/ray-operator/config/samples/ray-service.mobilenet.yaml"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "5375dd03-3beb-4c98-8c0e-c5618f2693d0",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"rayservice.ray.io/rayservice-mobilenet condition met\n"
]
}
],
"source": [
"kubectl wait --for=condition=ready rayservice/rayservice-mobilenet --timeout=500s"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "9c6cd34e-1d58-4079-aef1-8ca373f8af6d",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[\n",
" {\n",
" \"lastTransitionTime\": \"2025-02-28T11:35:55Z\",\n",
" \"message\": \"Number of serve endpoints is greater than 0\",\n",
" \"observedGeneration\": 1,\n",
" \"reason\": \"NonZeroServeEndpoints\",\n",
" \"status\": \"True\",\n",
" \"type\": \"Ready\"\n",
" }\n",
"]\n"
]
}
],
"source": [
"# Or use kubectl describe rayservice/rayservice-mobilenet\n",
"kubectl get rayservice/rayservice-mobilenet -o jsonpath-as-json='{.status.conditions[?(@.type==\"Ready\")]}'"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "931378a1-8bc8-45c2-8a2f-fd3c0c197190",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"nbval-ignore-output",
"remove-output"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1] 1596457\n"
]
}
],
"source": [
"kubectl port-forward svc/rayservice-mobilenet-serve-svc 8000 > /dev/null &"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "f9be8e69-9a27-4e8f-8736-c686ead7f649",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"nbval-ignore-output"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\"prediction\":[\"n02892201\",\"brass\",0.0880170688033104]}\n"
]
}
],
"source": [
"python mobilenet_req.py"
]
},
{
"cell_type": "markdown",
"id": "5d610ed8-6cdc-4326-b06f-5690d405f2c1",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"## Cleanup"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "2f2e77ec-6a3b-402b-98cd-0a53637deed1",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"nbval-ignore-output",
"remove-output"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Deleting cluster \"kind\" ...\n",
"Deleted nodes: [\"kind-control-plane\"]\n",
"[1]+ Terminated kubectl port-forward svc/rayservice-mobilenet-serve-svc 8000 > /dev/null\n"
]
}
],
"source": [
"killall kubectl\n",
"kind delete cluster"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Bash",
"language": "bash",
"name": "bash"
},
"language_info": {
"codemirror_mode": "shell",
"file_extension": ".sh",
"mimetype": "text/x-sh",
"name": "bash"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit 8e21aac

Please sign in to comment.