From 9cc6ab0ec8892d9828f2a73ab93ef4ca6217f312 Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Tue, 27 May 2025 12:48:39 +1000 Subject: [PATCH 1/7] chore(ci): migrate ai-platform/snippets --- .github/config/nodejs-dev.jsonc | 1 + .github/config/nodejs.jsonc | 1 - ai-platform/snippets/ci-setup.json | 5 +++++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 ai-platform/snippets/ci-setup.json diff --git a/.github/config/nodejs-dev.jsonc b/.github/config/nodejs-dev.jsonc index c8ca78b18b..6275022fd2 100644 --- a/.github/config/nodejs-dev.jsonc +++ b/.github/config/nodejs-dev.jsonc @@ -77,6 +77,7 @@ "recaptcha_enterprise/demosite/app", // no tests exist // These tests are already passing in prod, so skip them in dev. + "ai-platform/snippets", "appengine/building-an-app/build", "appengine/building-an-app/update", "appengine/datastore", diff --git a/.github/config/nodejs.jsonc b/.github/config/nodejs.jsonc index b8bc67ffcb..be4a9cde3b 100644 --- a/.github/config/nodejs.jsonc +++ b/.github/config/nodejs.jsonc @@ -75,7 +75,6 @@ "recaptcha_enterprise/demosite/app", // no tests exist // TODO: fix these - "ai-platform/snippets", // PERMISSION_DENIED: Permission denied: Consumer 'projects/undefined' has been suspended. "automl", // (untested) FAILED_PRECONDITION: Google Cloud AutoML Natural Language was retired on March 15, 2024. Please migrate to Vertex AI instead "cloud-sql/sqlserver/tedious", // (untested) TypeError: The "config.server" property is required and must be of type string. "compute", // GoogleError: The resource 'projects/long-door-651/zones/us-central1-a/disks/disk-from-pool-name' was not found diff --git a/ai-platform/snippets/ci-setup.json b/ai-platform/snippets/ci-setup.json new file mode 100644 index 0000000000..79ab08ce42 --- /dev/null +++ b/ai-platform/snippets/ci-setup.json @@ -0,0 +1,5 @@ +{ + "secrets": { + "CAIP_PROJECT_ID": "nodejs-docs-samples-tests/nodejs-docs-samples-ai-platform-caip-project-id" + } +} From d6c0efd8b495b225f32a7ee5ece0cd5b5b4abd39 Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Tue, 27 May 2025 13:06:30 +1000 Subject: [PATCH 2/7] try increase timeout --- ai-platform/snippets/ci-setup.json | 1 + 1 file changed, 1 insertion(+) diff --git a/ai-platform/snippets/ci-setup.json b/ai-platform/snippets/ci-setup.json index 79ab08ce42..b1a85518cc 100644 --- a/ai-platform/snippets/ci-setup.json +++ b/ai-platform/snippets/ci-setup.json @@ -1,4 +1,5 @@ { + "timeout-minutes": 20, "secrets": { "CAIP_PROJECT_ID": "nodejs-docs-samples-tests/nodejs-docs-samples-ai-platform-caip-project-id" } From 1236464dfa16f453e6cfa354e1f8d2c9c34366f8 Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Tue, 27 May 2025 14:08:27 +1000 Subject: [PATCH 3/7] attempt to debug test failures by using a more verbose reporter --- ai-platform/snippets/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ai-platform/snippets/package.json b/ai-platform/snippets/package.json index 4d7ad0964f..1079a71fd0 100644 --- a/ai-platform/snippets/package.json +++ b/ai-platform/snippets/package.json @@ -10,7 +10,7 @@ "*.js" ], "scripts": { - "test": "c8 mocha -p -j 2 --timeout 2400000 test/*.js" + "test": "c8 mocha -p -j 2 --timeout 2400000 test/*.js --reporter list" }, "dependencies": { "@google-cloud/aiplatform": "^3.0.0", From 4b44369185e3ac2723201f210b79170ae3101290 Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Tue, 27 May 2025 14:26:27 +1000 Subject: [PATCH 4/7] attempt deps bump --- ai-platform/snippets/package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ai-platform/snippets/package.json b/ai-platform/snippets/package.json index 1079a71fd0..3c8d2d47c0 100644 --- a/ai-platform/snippets/package.json +++ b/ai-platform/snippets/package.json @@ -13,16 +13,16 @@ "test": "c8 mocha -p -j 2 --timeout 2400000 test/*.js --reporter list" }, "dependencies": { - "@google-cloud/aiplatform": "^3.0.0", - "@google-cloud/bigquery": "^7.0.0", + "@google-cloud/aiplatform": "^4.0.0", + "@google-cloud/bigquery": "^8.0.0", "@google-cloud/storage": "^7.0.0" }, "devDependencies": { "c8": "^10.0.0", - "chai": "^4.5.0", - "mocha": "^10.0.0", - "uuid": "^10.0.0", - "sinon": "^18.0.0" + "chai": "^5.0.0", + "mocha": "^11.0.0", + "uuid": "^11.0.0", + "sinon": "^20.0.0" } } From 1b2a2b8b9d9a6e57c30cd8b87151261fb6600acc Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Tue, 27 May 2025 14:35:29 +1000 Subject: [PATCH 5/7] try import change --- .../snippets/test/batch-prediction-gemini.test.js | 10 +++++----- ...atch-prediction-job-text-classification.test.js | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ai-platform/snippets/test/batch-prediction-gemini.test.js b/ai-platform/snippets/test/batch-prediction-gemini.test.js index 87d58dd618..721c085da9 100644 --- a/ai-platform/snippets/test/batch-prediction-gemini.test.js +++ b/ai-platform/snippets/test/batch-prediction-gemini.test.js @@ -16,12 +16,12 @@ 'use strict'; -const {assert} = require('chai'); -const {after, describe, it} = require('mocha'); -const cp = require('child_process'); -const {JobServiceClient} = require('@google-cloud/aiplatform'); +import { assert } from 'chai'; +import { after, describe, it } from 'mocha'; +import { execSync as _execSync } from 'child_process'; +import { JobServiceClient } from '@google-cloud/aiplatform'; -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); +const execSync = cmd => _execSync(cmd, {encoding: 'utf-8'}); describe('Batch predict with Gemini', async () => { const projectId = process.env.CAIP_PROJECT_ID; diff --git a/ai-platform/snippets/test/create-batch-prediction-job-text-classification.test.js b/ai-platform/snippets/test/create-batch-prediction-job-text-classification.test.js index ac285ad4c4..91c9d1a3f6 100644 --- a/ai-platform/snippets/test/create-batch-prediction-job-text-classification.test.js +++ b/ai-platform/snippets/test/create-batch-prediction-job-text-classification.test.js @@ -16,18 +16,18 @@ 'use strict'; -const {assert} = require('chai'); -const {after, describe, it} = require('mocha'); -const uuid = require('uuid').v4; -const cp = require('child_process'); -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); +import { assert } from 'chai'; +import { after, describe, it } from 'mocha'; +import { v4 as uuid } from 'uuid'; +import { execSync as _execSync } from 'child_process'; +const execSync = cmd => _execSync(cmd, {encoding: 'utf-8'}); -const aiplatform = require('@google-cloud/aiplatform'); +import { v1 } from '@google-cloud/aiplatform'; const clientOptions = { apiEndpoint: 'us-central1-aiplatform.googleapis.com', }; -const jobServiceClient = new aiplatform.v1.JobServiceClient(clientOptions); +const jobServiceClient = new v1.JobServiceClient(clientOptions); const batchPredictionDisplayName = `temp_create_batch_prediction_text_classification_test${uuid()}`; const modelId = '7827432074230366208'; From e43369011a6a44abf619765c8606942aa98c44a3 Mon Sep 17 00:00:00 2001 From: David Cavazos Date: Fri, 30 May 2025 13:04:39 -0700 Subject: [PATCH 6/7] use node 16 --- ai-platform/snippets/ci-setup.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ai-platform/snippets/ci-setup.json b/ai-platform/snippets/ci-setup.json index b1a85518cc..d2912abeb6 100644 --- a/ai-platform/snippets/ci-setup.json +++ b/ai-platform/snippets/ci-setup.json @@ -2,5 +2,6 @@ "timeout-minutes": 20, "secrets": { "CAIP_PROJECT_ID": "nodejs-docs-samples-tests/nodejs-docs-samples-ai-platform-caip-project-id" - } + }, + "node-version": "16" } From 02eb8580f9859dc9bd4b4ffb28c77a169b6b2cf5 Mon Sep 17 00:00:00 2001 From: David Cavazos Date: Fri, 30 May 2025 13:14:15 -0700 Subject: [PATCH 7/7] change hardcoded node version --- .github/workflows/custard-ci.yaml | 2 +- .github/workflows/custard-run.yaml | 2 +- ai-platform/snippets/ci-setup.json | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/custard-ci.yaml b/.github/workflows/custard-ci.yaml index a63e570c33..4ff2a20886 100644 --- a/.github/workflows/custard-ci.yaml +++ b/.github/workflows/custard-ci.yaml @@ -145,7 +145,7 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: - node-version: ${{ fromJson(env.CI_SETUP).node-version }} + node-version: 16 - uses: google-github-actions/auth@6fc4af4b145ae7821d527454aa9bd537d1f2dc5f # v2 id: auth with: diff --git a/.github/workflows/custard-run.yaml b/.github/workflows/custard-run.yaml index c5fc5c94d2..90230e0198 100644 --- a/.github/workflows/custard-run.yaml +++ b/.github/workflows/custard-run.yaml @@ -82,7 +82,7 @@ jobs: - name: Setup Node uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: - node-version: 20 + node-version: 16 - run: npm install - name: npx gtx lint (${{ needs.affected.outputs.num-paths }} packages) uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/map-run@9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2 diff --git a/ai-platform/snippets/ci-setup.json b/ai-platform/snippets/ci-setup.json index d2912abeb6..b1a85518cc 100644 --- a/ai-platform/snippets/ci-setup.json +++ b/ai-platform/snippets/ci-setup.json @@ -2,6 +2,5 @@ "timeout-minutes": 20, "secrets": { "CAIP_PROJECT_ID": "nodejs-docs-samples-tests/nodejs-docs-samples-ai-platform-caip-project-id" - }, - "node-version": "16" + } }