Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…s-docs-samples into imagen
  • Loading branch information
Nick Cook committed Sep 26, 2024
2 parents eaed3c6 + c34e3fe commit 1e34c2d
Show file tree
Hide file tree
Showing 13 changed files with 307 additions and 100 deletions.
2 changes: 0 additions & 2 deletions .github/blunderbuss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ assign_issues_by:
- "api: asset"
to:
- GoogleCloudPlatform/cloud-asset-analysis-team
- GoogleCloudPlatform/cloud-asset-platform-team
- labels:
- 'api: bigtable'
- 'api: datastore'
Expand Down Expand Up @@ -47,7 +46,6 @@ assign_prs_by:
- "api: asset"
to:
- GoogleCloudPlatform/cloud-asset-analysis-team
- GoogleCloudPlatform/cloud-asset-platform-team
- labels:
- 'api: bigtable'
- 'api: datastore'
Expand Down
25 changes: 2 additions & 23 deletions .github/workflows/flakybot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,5 @@ jobs:
contents: 'read'
id-token: 'write'
steps:
- name: authenticate
uses: 'google-github-actions/auth@62cf5bd3e4211a0a0b51f2c6d6a37129d828611d' # v2
with:
workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider'
service_account: '[email protected]'
create_credentials_file: 'true'
access_token_lifetime: 600s
- name: download test results
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: test-results
- name: download FlakyBot
run: |
curl -s -L https://github.com/googleapis/repo-automation-bots/archive/refs/tags/flakybot-v${{ env.FLAKYBOT_VERSION }}.tar.gz -o flakybot.tar.gz
tar xzf flakybot.tar.gz
cp -rT repo-automation-bots-flakybot-v${{ env.FLAKYBOT_VERSION}}/packages/flakybot/ .
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
with:
cache: true
cache-dependency-path: '${{ github.workspace }}/go.sum'
go-version-file: '${{ github.workspace }}/go.mod'
- name: run FlakyBot
run: go run flakybot.go --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
- name: DISABLED run FlakyBot
run: echo flakybot error reporting disabled
3 changes: 1 addition & 2 deletions .github/workflows/security-center-snippets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ on:
branches:
- main
paths:
- 'security-center/snippets/v1/**'
- 'security-center/snippets/package.json'
- 'security-center/snippets/**'
- '.github/workflows/security-center-snippets.yaml'
pull_request:
types:
Expand Down
13 changes: 0 additions & 13 deletions .kokoro/build-with-appengine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,6 @@ trap cleanup EXIT HUP
# Install dependencies and run tests
npm install

# If tests are running against main, configure FlakyBot
# to open issues on failures:
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"release"* ]]; then
export MOCHA_REPORTER_SUITENAME=${PROJECT}
notify_flakybot() {
# Call the original trap function.
cleanup
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot
}
trap notify_flakybot EXIT HUP
fi

npm test

exit $?
11 changes: 0 additions & 11 deletions .kokoro/build-with-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,6 @@ export SERVICE_NAME="${SAMPLE_NAME}-${SUFFIX}"
export NODE_ENV=development
npm install

# If tests are running against main, configure FlakyBot
# to open issues on failures:
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"release"* ]]; then
export MOCHA_REPORTER_SUITENAME=${PROJECT}
notify_flakybot() {
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot
}
trap notify_flakybot EXIT HUP
fi

# Configure Cloud SQL variables for deploying idp-sql sample
export DB_NAME="kokoro_ci"
export DB_USER="kokoro_ci"
Expand Down
16 changes: 0 additions & 16 deletions .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,6 @@ print_logfile() {
echo '----- End ${MOCHA_REPORTER_OUTPUT} -----'
}

# If tests are running against main, configure FlakyBot
# to open issues on failures:
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"release"* ]]; then
export MOCHA_REPORTER_SUITENAME=${PROJECT}
cleanup() {
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot

# We can only set one trap per signal, so run `print_logfile` here
print_logfile
}
trap cleanup EXIT HUP
else
trap print_logfile EXIT HUP
fi

npm test

exit $?
28 changes: 3 additions & 25 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ secret-manager @GoogleCloudPlatform/dee-infra @GoogleCloudPlatform/nodejs-sample
service-directory @GoogleCloudPlatform/dee-infra @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
webrisk @GoogleCloudPlatform/dee-infra @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers

# DEE Platform Ops (DEEPO)
container @GoogleCloudPlatform/dee-platform-ops @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
error-reporting @GoogleCloudPlatform/dee-platform-ops @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
game-servers @GoogleCloudPlatform/dee-platform-ops @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
monitoring @GoogleCloudPlatform/dee-platform-ops @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers

# SoDa teams
cloud-sql @GoogleCloudPlatform/infra-db-sdk @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
datastore @GoogleCloudPlatform/cloud-native-db-dpes @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
Expand All @@ -42,27 +36,11 @@ composer @GoogleCloudPlatform/cloud-dpes-composer @GoogleCloudPlatform/nodejs-sa
monitoring/opencensus @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers

# Data & AI
generative-ai @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
automl @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
cloud-language @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
contact-center-insights @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
datalabeling @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
dialogflow @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
dialogflow-cx @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
discoveryengine @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
document-ai @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/document-ai-samples-contributors @GoogleCloudPlatform/cloud-samples-reviewers
document-warehouse @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/document-ai-samples-contributors @GoogleCloudPlatform/cloud-samples-reviewers
mediatranslation @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
notebooks @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
speech @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
talent @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
texttospeech @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
translate @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
video-intelligence @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
vision @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
document-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/document-ai-samples-contributors @GoogleCloudPlatform/cloud-samples-reviewers
document-warehouse @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/document-ai-samples-contributors @GoogleCloudPlatform/cloud-samples-reviewers

# Self-service
ai-platform @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/text-embedding @GoogleCloudPlatform/cloud-samples-reviewers
ai-platform @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/text-embedding @GoogleCloudPlatform/cloud-samples-reviewers
asset @GoogleCloudPlatform/cloud-asset-analysis-team @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
dlp @GoogleCloudPlatform/googleapis-dlp @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
security-center @GoogleCloudPlatform/gcp-security-command-center @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
Expand Down
75 changes: 75 additions & 0 deletions ai-platform/snippets/gemma2PredictGpu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

async function gemma2PredictGpu(predictionServiceClient) {
// [START generativeaionvertexai_gemma2_predict_gpu]
// Imports the Google Cloud Prediction Service Client library
const {
// TODO(developer): Uncomment PredictionServiceClient before running the sample.
// PredictionServiceClient,
helpers,
} = require('@google-cloud/aiplatform');
/**
* TODO(developer): Update these variables before running the sample.
*/
const projectId = 'your-project-id';
const endpointRegion = 'your-vertex-endpoint-region';
const endpointId = 'your-vertex-endpoint-id';

// Default configuration
const config = {maxOutputTokens: 1024, temperature: 0.9, topP: 1.0, topK: 1};
// Prompt used in the prediction
const prompt = 'Why is the sky blue?';

// Encapsulate the prompt in a correct format for GPUs
// Example format: [{inputs: 'Why is the sky blue?', parameters: {temperature: 0.9}}]
const input = {
inputs: prompt,
parameters: config,
};

// Convert input message to a list of GAPIC instances for model input
const instances = [helpers.toValue(input)];

// TODO(developer): Uncomment apiEndpoint and predictionServiceClient before running the sample.
// const apiEndpoint = `${endpointRegion}-aiplatform.googleapis.com`;

// Create a client
// predictionServiceClient = new PredictionServiceClient({apiEndpoint});

// Call the Gemma2 endpoint
const gemma2Endpoint = `projects/${projectId}/locations/${endpointRegion}/endpoints/${endpointId}`;

const [response] = await predictionServiceClient.predict({
endpoint: gemma2Endpoint,
instances,
});

const predictions = response.predictions;
const text = predictions[0].stringValue;

console.log('Predictions:', text);
// [END generativeaionvertexai_gemma2_predict_gpu]
return text;
}

module.exports = gemma2PredictGpu;

// TODO(developer): Uncomment below lines before running the sample.
// gemma2PredictGpu(...process.argv.slice(2)).catch(err => {
// console.error(err.message);
// process.exitCode = 1;
// });
77 changes: 77 additions & 0 deletions ai-platform/snippets/gemma2PredictTpu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

async function gemma2PredictTpu(predictionServiceClient) {
// [START generativeaionvertexai_gemma2_predict_tpu]
// Imports the Google Cloud Prediction Service Client library
const {
// TODO(developer): Uncomment PredictionServiceClient before running the sample.
// PredictionServiceClient,
helpers,
} = require('@google-cloud/aiplatform');
/**
* TODO(developer): Update these variables before running the sample.
*/
const projectId = 'your-project-id';
const endpointRegion = 'your-vertex-endpoint-region';
const endpointId = 'your-vertex-endpoint-id';

// Prompt used in the prediction
const prompt = 'Why is the sky blue?';

// Encapsulate the prompt in a correct format for TPUs
// Example format: [{prompt: 'Why is the sky blue?', temperature: 0.9}]
const input = {
prompt,
// Parameters for default configuration
maxOutputTokens: 1024,
temperature: 0.9,
topP: 1.0,
topK: 1,
};

// Convert input message to a list of GAPIC instances for model input
const instances = [helpers.toValue(input)];

// TODO(developer): Uncomment apiEndpoint and predictionServiceClient before running the sample.
// const apiEndpoint = `${endpointRegion}-aiplatform.googleapis.com`;

// Create a client
// predictionServiceClient = new PredictionServiceClient({apiEndpoint});

// Call the Gemma2 endpoint
const gemma2Endpoint = `projects/${projectId}/locations/${endpointRegion}/endpoints/${endpointId}`;

const [response] = await predictionServiceClient.predict({
endpoint: gemma2Endpoint,
instances,
});

const predictions = response.predictions;
const text = predictions[0].stringValue;

console.log('Predictions:', text);
// [END generativeaionvertexai_gemma2_predict_tpu]
return text;
}

module.exports = gemma2PredictTpu;

// TODO(developer): Uncomment below lines before running the sample.
// gemma2PredictTpu(...process.argv.slice(2)).catch(err => {
// console.error(err.message);
// process.exitCode = 1;
// });
Loading

0 comments on commit 1e34c2d

Please sign in to comment.