Skip to content

Commit

Permalink
parameterize scripts for autopilot
Browse files Browse the repository at this point in the history
  • Loading branch information
hsachdevah committed Mar 7, 2024
1 parent 2d46b30 commit b124de8
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 117 deletions.
25 changes: 13 additions & 12 deletions cloudbuild-ap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ steps:
# Get kube config
gcloud container clusters get-credentials \
github-ci-autopilot \
$_CLUSTER_NAME \
--location us-central1 \
--project $PROJECT_ID
cd /workspace/applications/ray/
terraform apply \
-var-file=workloads.tfvars \
-var=project_id=$PROJECT_ID \
-var=cluster_name=github-ci-autopilot \
-var=cluster_name=$_CLUSTER_NAME \
-var=cluster_location=$_REGION \
-var=ray_namespace=ml-$SHORT_SHA-ap \
-var=gcp_service_account=ray-sa-$SHORT_SHA-ap \
Expand Down Expand Up @@ -95,7 +95,7 @@ steps:
terraform destroy \
-var-file=workloads.tfvars \
-var=project_id=$PROJECT_ID \
-var=cluster_name=github-ci-autopilot \
-var=cluster_name=$_CLUSTER_NAME \
-var=cluster_location=$_REGION \
-var=ray_namespace=ml-$SHORT_SHA-ap \
-var=gcp_service_account=ray-sa-$SHORT_SHA-ap \
Expand All @@ -114,13 +114,13 @@ steps:
set -e
cd /workspace/modules/jupyter/tests
python3 change_jupyter_config_autopilot.py
python3 change_jupyter_config.py autopilot
cd /workspace/applications/jupyter
terraform apply \
-var-file=workloads-without-iap.example.tfvars \
-var=project_id=$PROJECT_ID \
-var=cluster_name=github-ci-autopilot \
-var=cluster_name=$_CLUSTER_NAME \
-var=namespace=ml-$SHORT_SHA-ap \
-var=workload_identity_service_account=jupyter-sa-$SHORT_SHA-ap \
-var=gcs_bucket=gke-aieco-jupyter-$SHORT_SHA-ap \
Expand All @@ -133,7 +133,7 @@ steps:
echo "HOST URL is " $(cat /workspace/jupyterhub_host_url.txt)
cd /workspace/modules/jupyter/tests
python3 test_hub_autopilot.py $(cat /workspace/jupyterhub_host_url.txt)
python3 test_hub.py $(cat /workspace/jupyterhub_host_url.txt) autopilot
echo "pass" > /workspace/jupyterhub_test_result.txt
allowFailure: true

Expand All @@ -149,7 +149,7 @@ steps:
terraform destroy \
-var-file=workloads-without-iap.example.tfvars \
-var=project_id=$PROJECT_ID \
-var=cluster_name=github-ci-autopilot \
-var=cluster_name=$_CLUSTER_NAME \
-var=namespace=ml-$SHORT_SHA-ap \
-var=workload_identity_service_account=jupyter-sa-$SHORT_SHA-ap \
-var=gcs_bucket=gke-aieco-jupyter-$SHORT_SHA-ap \
Expand All @@ -168,20 +168,20 @@ steps:
# Get kube config
gcloud container clusters get-credentials \
github-ci-autopilot \
$_CLUSTER_NAME \
--location us-central1 \
--project $PROJECT_ID
cd /workspace/modules/jupyter/tests
python3 change_jupyter_config_autopilot.py
python3 change_jupyter_config.py autopilot
cd /workspace/applications/rag/
terraform apply \
-var-file=workloads.tfvars \
-var=jupyter_add_auth=false \
-var=frontend_add_auth=false \
-var=project_id=$PROJECT_ID \
-var=cluster_name=github-ci-autopilot \
-var=cluster_name=$_CLUSTER_NAME \
-var=kubernetes_namespace=rag-$SHORT_SHA-ap \
-var=gcs_bucket=gke-aieco-rag-$SHORT_SHA-ap \
-var=ray_service_account=ray-sa-$SHORT_SHA-ap \
Expand Down Expand Up @@ -209,7 +209,7 @@ steps:
# Validate Jupyterhub: Test Hub
cd /workspace/modules/jupyter/tests
python3 test_hub_autopilot.py $(cat /workspace/rag_jupyterhub_host_url.txt)
python3 test_hub.py $(cat /workspace/rag_jupyterhub_host_url.txt) autopilot
echo "pass" > /workspace/rag_jupyterhub_test_result.txt
# Validate RAG: Test rag frontend
Expand All @@ -235,7 +235,7 @@ steps:
terraform destroy \
-var-file=workloads.tfvars \
-var=project_id=$PROJECT_ID \
-var=cluster_name=github-ci-autopilot \
-var=cluster_name=$_CLUSTER_NAME \
-var=kubernetes_namespace=rag-$SHORT_SHA-ap \
-var=gcs_bucket=gke-aieco-rag-$SHORT_SHA-ap \
-var=ray_service_account=ray-sa-$SHORT_SHA-ap \
Expand Down Expand Up @@ -298,6 +298,7 @@ steps:
substitutions:
_REGION: us-central1
_USER_NAME: github
_CLUSTER_NAME: github-ci-autopilot
options:
substitutionOption: 'ALLOW_LOOSE'

21 changes: 0 additions & 21 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -252,27 +252,6 @@ steps:
- |
set -e
cd /workspace/applications/jupyter/
terraform destroy \
-var-file=workloads-without-iap.example.tfvars \
-var=project_id=$PROJECT_ID \
-var=cluster_name=ml-$SHORT_SHA-$_PR_NUMBER-cluster \
-var=namespace=ml-$SHORT_SHA \
-var=workload_identity_service_account=jupyter-sa-$SHORT_SHA \
-var=gcs_bucket=gke-aieco-jupyter-$SHORT_SHA \
-auto-approve -no-color
cd /workspace/applications/ray/
terraform destroy \
-var-file=workloads.tfvars \
-var=project_id=$PROJECT_ID \
-var=cluster_name=ml-$SHORT_SHA-$_PR_NUMBER-cluster \
-var=cluster_location=$_REGION \
-var=ray_namespace=ml-$SHORT_SHA \
-var=gcp_service_account=ray-sa-$SHORT_SHA \
-var=gcs_bucket=gke-aieco-ray-$SHORT_SHA \
-auto-approve -no-color
cd /workspace/applications/rag/
terraform destroy \
-var-file=workloads.tfvars \
Expand Down
14 changes: 11 additions & 3 deletions modules/jupyter/tests/change_jupyter_config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import yaml
import sys

with open("../jupyter_config/config-selfauth.yaml", "r") as yaml_file:
config_file = "../jupyter_config/config-selfauth.yaml"
if len(sys.argv) == 2:
autopilot = (sys.argv[1] == "autopilot")
if autopilot:
config_file = "../jupyter_config/config-selfauth-autopilot.yaml"


with open(config_file, "r") as yaml_file:
data = yaml.safe_load(yaml_file)

data["hub"]["config"]["DummyAuthenticator"]["password"] = "dummy"

with open("../jupyter_config/config-selfauth.yaml", 'w') as yaml_file:
yaml.dump(data, yaml_file)
with open(config_file, 'w') as yaml_file:
yaml.dump(data, yaml_file)
9 changes: 0 additions & 9 deletions modules/jupyter/tests/change_jupyter_config_autopilot.py

This file was deleted.

8 changes: 7 additions & 1 deletion modules/jupyter/tests/test_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

from packaging.version import Version as V

config_file = "../jupyter_config/config-selfauth.yaml"
if len(sys.argv) == 3:
autopilot = (sys.argv[2] == "autopilot")
if autopilot:
config_file = "../jupyter_config/config-selfauth-autopilot.yaml"


def test_hub_up(hub_url):
r = requests.get(hub_url)
Expand Down Expand Up @@ -32,7 +38,7 @@ def test_hub_login(hub_url):
from /jupyter_config/config.yaml. After successfully login, user will be
redirected to /hub/spawn.
"""
with open("../jupyter_config/config-selfauth.yaml", "r") as yaml_file:
with open(config_file, "r") as yaml_file:
data = yaml.safe_load(yaml_file)

username = data["hub"]["config"]["Authenticator"]["admin_users"][0]
Expand Down
71 changes: 0 additions & 71 deletions modules/jupyter/tests/test_hub_autopilot.py

This file was deleted.

0 comments on commit b124de8

Please sign in to comment.