Skip to content

Commit 456846c

Browse files
authored
Merge branch 'main' into nodejs-asset-migration
2 parents b71143b + 27460d3 commit 456846c

File tree

165 files changed

+9971
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+9971
-0
lines changed

.github/workflows/automl.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: automl
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- 'automl/**'
8+
pull_request:
9+
paths:
10+
- 'automl/**'
11+
pull_request_target:
12+
types: [labeled]
13+
schedule:
14+
- cron: '0 0 * * 0'
15+
jobs:
16+
test:
17+
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }}
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 60
20+
permissions:
21+
contents: 'write'
22+
pull-requests: 'write'
23+
id-token: 'write'
24+
steps:
25+
- uses: actions/checkout@v3
26+
with:
27+
ref: ${{github.event.pull_request.head.ref}}
28+
repository: ${{github.event.pull_request.head.repo.full_name}}
29+
- uses: google-github-actions/auth@v1.0.0
30+
with:
31+
workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider'
32+
service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com'
33+
create_credentials_file: 'true'
34+
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}'
35+
access_token_lifetime: 600s
36+
- id: secrets
37+
uses: 'google-github-actions/get-secretmanager-secrets@v0'
38+
with:
39+
secrets: |-
40+
table_model_id:nodejs-docs-samples-tests/nodejs-docs-samples-table-model-id
41+
- uses: actions/setup-node@v3
42+
with:
43+
node-version: 14
44+
- run: npm install
45+
working-directory: automl
46+
- run: npm test
47+
working-directory: automl
48+
env:
49+
MOCHA_REPORTER_SUITENAME: automl
50+
MOCHA_REPORTER_OUTPUT: automl_sponge_log.xml
51+
MOCHA_REPORTER: xunit
52+
TABLE_MODEL_ID: ${{ steps.secrets.outputs.table_model_id }}
53+
- if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }}
54+
uses: actions/github-script@v6
55+
with:
56+
github-token: ${{ secrets.GITHUB_TOKEN }}
57+
script: |
58+
try {
59+
await github.rest.issues.removeLabel({
60+
name: 'actions:force-run',
61+
owner: 'GoogleCloudPlatform',
62+
repo: 'nodejs-docs-samples',
63+
issue_number: context.payload.pull_request.number
64+
});
65+
} catch (e) {
66+
if (!e.message.includes('Label does not exist')) {
67+
throw e;
68+
}
69+
}
70+
- if: ${{ github.event_name == 'schedule' && always() }}
71+
run: |
72+
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
73+
chmod +x ./flakybot
74+
./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: video-intelligence
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- 'video-intelligence/**'
8+
pull_request:
9+
paths:
10+
- 'video-intelligence/**'
11+
pull_request_target:
12+
types: [labeled]
13+
schedule:
14+
- cron: '0 0 * * 0'
15+
jobs:
16+
test:
17+
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }}
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 60
20+
permissions:
21+
contents: 'write'
22+
pull-requests: 'write'
23+
id-token: 'write'
24+
steps:
25+
- uses: actions/checkout@v3
26+
with:
27+
ref: ${{github.event.pull_request.head.ref}}
28+
repository: ${{github.event.pull_request.head.repo.full_name}}
29+
- uses: google-github-actions/auth@v1.0.0
30+
with:
31+
workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider'
32+
service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com'
33+
create_credentials_file: 'true'
34+
access_token_lifetime: 600s
35+
- uses: actions/setup-node@v3
36+
with:
37+
node-version: 14
38+
- run: npm install
39+
working-directory: video-intelligence
40+
- run: npm test
41+
working-directory: video-intelligence
42+
env:
43+
MOCHA_REPORTER_SUITENAME: video-intelligence
44+
MOCHA_REPORTER_OUTPUT: video_intelligence_sponge_log.xml
45+
MOCHA_REPORTER: xunit
46+
- if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }}
47+
uses: actions/github-script@v6
48+
with:
49+
github-token: ${{ secrets.GITHUB_TOKEN }}
50+
script: |
51+
try {
52+
await github.rest.issues.removeLabel({
53+
name: 'actions:force-run',
54+
owner: 'GoogleCloudPlatform',
55+
repo: 'nodejs-docs-samples',
56+
issue_number: context.payload.pull_request.number
57+
});
58+
} catch (e) {
59+
if (!e.message.includes('Label does not exist')) {
60+
throw e;
61+
}
62+
}
63+
- if: ${{ github.event_name == 'schedule' && always() }}
64+
run: |
65+
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
66+
chmod +x ./flakybot
67+
./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}

.github/workflows/workflows.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"appengine/storage/standard",
1616
"asset/snippets",
1717
"auth",
18+
"automl",
1819
"appengine/typescript",
1920
"appengine/websockets",
2021
"appengine/twilio",
@@ -57,6 +58,7 @@
5758
"datastore/functions",
5859
"scheduler",
5960
"talent",
61+
"video-intelligence",
6062
"contact-center-insights",
6163
"workflows"
6264
]

automl/.eslintrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
rules:
3+
no-console: off

automl/batch_predict.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Copyright 2020 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(
18+
projectId = 'YOUR_PROJECT_ID',
19+
location = 'us-central1',
20+
modelId = 'YOUR_MODEL_ID',
21+
inputUri = 'gs://YOUR_BUCKET_ID/path_to_your_input_csv_or_jsonl',
22+
outputUri = 'gs://YOUR_BUCKET_ID/path_to_save_results/'
23+
) {
24+
// [START automl_batch_predict]
25+
/**
26+
* TODO(developer): Uncomment these variables before running the sample.
27+
*/
28+
// const projectId = 'YOUR_PROJECT_ID';
29+
// const location = 'us-central1';
30+
// const modelId = 'YOUR_MODEL_ID';
31+
// const inputUri = 'gs://YOUR_BUCKET_ID/path_to_your_input_csv_or_jsonl';
32+
// const outputUri = 'gs://YOUR_BUCKET_ID/path_to_save_results/';
33+
34+
// Imports the Google Cloud AutoML library
35+
const {PredictionServiceClient} = require('@google-cloud/automl').v1;
36+
37+
// Instantiates a client
38+
const client = new PredictionServiceClient();
39+
40+
async function batchPredict() {
41+
// Construct request
42+
const request = {
43+
name: client.modelPath(projectId, location, modelId),
44+
inputConfig: {
45+
gcsSource: {
46+
inputUris: [inputUri],
47+
},
48+
},
49+
outputConfig: {
50+
gcsDestination: {
51+
outputUriPrefix: outputUri,
52+
},
53+
},
54+
};
55+
56+
const [operation] = await client.batchPredict(request);
57+
58+
console.log('Waiting for operation to complete...');
59+
// Wait for operation to complete.
60+
const [response] = await operation.promise();
61+
console.log(
62+
`Batch Prediction results saved to Cloud Storage bucket. ${response}`
63+
);
64+
}
65+
66+
batchPredict();
67+
// [END automl_batch_predict]
68+
}
69+
70+
process.on('unhandledRejection', err => {
71+
console.error(err.message);
72+
process.exitCode = 1;
73+
});
74+
main(...process.argv.slice(2));

automl/beta/batch_predict.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Copyright 2020 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(
18+
projectId = 'YOUR_PROJECT_ID',
19+
location = 'us-central1',
20+
modelId = 'YOUR_MODEL_ID',
21+
inputUri = 'gs://YOUR_BUCKET_ID/path_to_your_input_csv_or_jsonl',
22+
outputUri = 'gs://YOUR_BUCKET_ID/path_to_save_results/'
23+
) {
24+
// [START automl_batch_predict_beta]
25+
/**
26+
* TODO(developer): Uncomment these variables before running the sample.
27+
*/
28+
// const projectId = 'YOUR_PROJECT_ID';
29+
// const location = 'us-central1';
30+
// const modelId = 'YOUR_MODEL_ID';
31+
// const inputUri = 'gs://YOUR_BUCKET_ID/path_to_your_input_csv_or_jsonl';
32+
// const outputUri = 'gs://YOUR_BUCKET_ID/path_to_save_results/';
33+
34+
// Imports the Google Cloud AutoML library
35+
const {PredictionServiceClient} = require('@google-cloud/automl').v1beta1;
36+
37+
// Instantiates a client
38+
const client = new PredictionServiceClient();
39+
40+
async function batchPredict() {
41+
// Construct request
42+
const request = {
43+
name: client.modelPath(projectId, location, modelId),
44+
inputConfig: {
45+
gcsSource: {
46+
inputUris: [inputUri],
47+
},
48+
},
49+
outputConfig: {
50+
gcsDestination: {
51+
outputUriPrefix: outputUri,
52+
},
53+
},
54+
};
55+
56+
const [operation] = await client.batchPredict(request);
57+
58+
console.log('Waiting for operation to complete...');
59+
// Wait for operation to complete.
60+
const [response] = await operation.promise();
61+
console.log(
62+
`Batch Prediction results saved to Cloud Storage bucket. ${response}`
63+
);
64+
}
65+
66+
batchPredict();
67+
// [END automl_batch_predict_beta]
68+
}
69+
70+
process.on('unhandledRejection', err => {
71+
console.error(err.message);
72+
process.exitCode = 1;
73+
});
74+
main(...process.argv.slice(2));

automl/beta/cancel_operation.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2020 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
async function main(operationFullId) {
18+
// [START automl_cancel_operation_beta]
19+
20+
/**
21+
* TODO(developer): Uncomment these variables before running the sample.
22+
*/
23+
// const operationFullId = 'projects/YOUR_PROJECT_ID/locations/YOUR_LOCATIOIN/operations/OPERATION_ID';
24+
25+
// Imports the Google Cloud AutoML library
26+
const {AutoMlClient} = require('@google-cloud/automl').v1beta1;
27+
28+
// Instantiates a client
29+
const client = new AutoMlClient();
30+
31+
async function cancelOperation() {
32+
client.operationsClient.cancelOperation({
33+
name: operationFullId,
34+
});
35+
36+
// Wait for operation to complete.
37+
console.log('Cancelled operation');
38+
}
39+
40+
cancelOperation();
41+
// [END automl_cancel_operation_beta]
42+
}
43+
44+
main(...process.argv.slice(2)).catch(err => {
45+
console.error(err.message);
46+
process.exitCode = 1;
47+
});
48+
process.on('unhandledRejection', err => {
49+
console.error(err.message);
50+
process.exitCode = 1;
51+
});

0 commit comments

Comments
 (0)