Skip to content

Commit 09c1540

Browse files
authored
ci: Updates to Cloud Build NB Testing Scripts (#2039)
1 parent a1c7150 commit 09c1540

File tree

13 files changed

+18
-209
lines changed

13 files changed

+18
-209
lines changed

.cloud-build/Notebooks.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,2 @@
11
generative-ai/gemini/getting-started/intro_gemini_2_0_flash.ipynb
22
generative-ai/gemini/getting-started/intro_gemini_2_0_flash_lite.ipynb
3-
generative-ai/gemini/getting-started/intro_gemini_2_0_image_gen.ipynb
4-
generative-ai/gemini/getting-started/intro_gemini_2_5_flash.ipynb
5-
generative-ai/gemini/getting-started/intro_gemini_2_5_pro.ipynb
6-
generative-ai/gemini/getting-started/intro_gemini_chat.ipynb
7-
generative-ai/gemini/getting-started/intro_gemini_curl.ipynb
8-
generative-ai/gemini/code-execution/intro_code_execution.ipynb
9-
generative-ai/gemini/context-caching/intro_context_caching.ipynb
10-
generative-ai/gemini/controlled-generation/intro_controlled_generation.ipynb
11-
generative-ai/gemini/long-context/intro_long_context.ipynb
12-
generative-ai/gemini/prompts/intro_prompt_design.ipynb
13-
generative-ai/gemini/orchestration/intro_langchain_gemini.ipynb
14-
generative-ai/gemini/orchestration/intro_langgraph_gemini.ipynb

.cloud-build/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The script performs the following actions:
1313
1. **Reads Output URI variable:**
1414
- It reads the destination GCS bucket URI from a variable named `OUTPUT_URI` injected from secret manager. This allows for easy configuration of the destination.
1515
2. **Iterates Through Notebooks:**
16-
- It loops through all `.ipynb` files located in the `/workspace/generative-ai/gemini/getting-started/` directory.
16+
- It loops through all `.ipynb` files located in the `Notebooks.txt` file.
1717
3. **Copies Notebooks to GCS:**
1818
- For each notebook file, it extracts the filename using `basename`.
1919
- It then uses the `gcloud storage cp` command to copy the notebook file to the specified GCS bucket, maintaining the directory structure.
@@ -40,7 +40,7 @@ Before running this script, ensure you have the following:
4040
4141
2. **Place Notebooks:**
4242
43-
- Ensure your `.ipynb` files are located in the `/workspace/generative-ai/gemini/getting-started/` directory.
43+
- Ensure the names of the `.ipynb` files are located in the `Notebooks.txt` file.
4444
4545
3. **Add the script as a step in your pipeline:**
4646
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
#!/bin/bash
22

3-
# Reads the destination GCS URI from the OUTPUT_URI file.
4-
OUTPUT_URI=$(cat OUTPUT_URI)
5-
63
# Clones the generative-ai repository from GitHub.
74
git clone --depth 1 -b main https://github.com/GoogleCloudPlatform/generative-ai.git
85

96
# Changes the current directory to the cloned repository.
107
cd generative-ai || exit 1
11-
12-
# Copies the specified directory to the destination GCS URI using gsutil.
13-
gsutil -m rsync -r . $OUTPUT_URI/generative-ai/

.cloud-build/cloudbuild.yaml

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,13 @@ steps:
88
args:
99
- "-c"
1010
- |
11-
gcloud secrets versions access latest --secret=GCS_BUCKET > OUTPUT_URI
1211
. .cloud-build/clone-repo/clone_repo.sh
1312
# [END copy-repo]
14-
# [START prepare-data]
15-
- name: google/cloud-sdk
16-
id: "prepare-data"
17-
entrypoint: bash
18-
args:
19-
- "-c"
20-
- |
21-
. .cloud-build/prepare-data/prepare_notebooks.sh
22-
# [END prepare-data]
23-
# [START push-to-gcs]
24-
- name: google/cloud-sdk
25-
id: "push-to-gcs"
26-
entrypoint: bash
27-
args:
28-
- "-c"
29-
- |
30-
gcloud secrets versions access latest --secret=GCS_BUCKET > OUTPUT_URI
31-
. .cloud-build/gcs/push_to_gcs.sh
32-
# [END push-to-gcs]
33-
# [START run-lint]
34-
- name: python:3.9
35-
id: "run-lint"
36-
entrypoint: python
37-
args:
38-
- .cloud-build/linting/lint.py
39-
# [END run-lint]
40-
4113
# [START execute-notebooks]
4214
- name: google/cloud-sdk
4315
id: "execute-notebooks"
4416
entrypoint: bash
45-
timeout: 7200s #Because this step takes the longest. Avg runtime is 1 hour and 20 minutes.
17+
timeout: 7200s # Because this step takes the longest. Avg runtime is 1 hour and 20 minutes.
4618
args:
4719
- "-c"
4820
- |

.cloud-build/executor/test_notebooks.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ successful_count=0
2323

2424
for x in $TARGET; do
2525
total_count=$((total_count + 1))
26-
DISPLAY_NAME="${x##*/}-$current_date-$current_time"
27-
echo "Starting execution for ${x##*/}"
26+
# Use the full path from the repository for display name
27+
DISPLAY_NAME="${x##generative-ai/}"
28+
DISPLAY_NAME="${DISPLAY_NAME%.ipynb}-$current_date-$current_time"
29+
echo "Starting execution for ${x}"
2830

2931
# Execute and get the operation ID
3032
OPERATION_ID=$(gcloud colab executions create \
3133
--display-name="$DISPLAY_NAME" \
3234
--notebook-runtime-template="$NOTEBOOK_RUNTIME_TEMPLATE" \
33-
--gcs-notebook-uri="$OUTPUT_URI/$x" \
35+
--direct-content="$x" \
3436
--gcs-output-uri="$OUTPUT_URI" \
3537
--project="$PROJECT_ID" \
3638
--region="$REGION" \
@@ -45,24 +47,24 @@ for x in $TARGET; do
4547
# check job status
4648
echo "Waiting for execution to complete..."
4749
if ! EXECUTION_DETAILS=$(gcloud colab executions describe "$TRUNCATED_OPERATION_ID" --region="$REGION"); then
48-
echo "Error describing execution for ${x##*/}. See logs for details."
50+
echo "Error describing execution for ${x}. See logs for details."
4951
failed_count=$((failed_count + 1))
50-
failed_notebooks+=("${x##*/}")
52+
failed_notebooks+=("${x}")
5153
continue
5254
else
53-
echo "Execution completed for ${x##*/}"
55+
echo "Execution completed for ${x}"
5456
fi
5557

5658
# Check the jobState
5759
JOB_STATE=$(echo "$EXECUTION_DETAILS" | grep "jobState:" | awk '{print $2}')
5860
if [[ "$JOB_STATE" == "JOB_STATE_SUCCEEDED" ]]; then
5961
echo "Notebook execution succeeded."
6062
successful_count=$((successful_count + 1))
61-
successful_notebooks+=("${x##*/}")
63+
successful_notebooks+=("${x}")
6264
else
63-
echo "Notebook execution failed. Job state: $JOB_STATE. Please use id $TRUNCATED_OPERATION_ID to troubleshoot notebook ${x##*/}. See log for details."
65+
echo "Notebook execution failed. Job state: $JOB_STATE. Please use id $TRUNCATED_OPERATION_ID to troubleshoot notebook ${x}. See log for details."
6466
failed_count=$((failed_count + 1))
65-
failed_notebooks+=("${x##*/}")
67+
failed_notebooks+=("${x}")
6668
continue
6769
fi
6870

.cloud-build/gcs/README.md

Lines changed: 0 additions & 59 deletions
This file was deleted.

.cloud-build/gcs/push_to_gcs.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

.cloud-build/github-issue/auto_issue_create.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
ISSUE_TITLE="Failed automated Notebook Testing"
44
ISSUE_LABELS="bug"
5-
ISSUE_ASSIGNEES="CadillacBurgess1"
6-
REPO_OWNER="CadillacBurgess1"
7-
REPO_NAME="example-notebook-testing-repo"
5+
# ISSUE_ASSIGNEES="CadillacBurgess1"
6+
REPO_OWNER="GoogleCloudPlatform"
7+
REPO_NAME="generative-ai"
88
FAILURE_FILE="/workspace/Failure.txt"
99

1010
if [ -f "$FAILURE_FILE" ]; then

.cloud-build/linting/README.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

.cloud-build/linting/lint.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)