MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

automl/beta/batch_predict.js:17–68  ·  view source on GitHub ↗
(
  projectId = 'YOUR_PROJECT_ID',
  location = 'us-central1',
  modelId = 'YOUR_MODEL_ID',
  inputUri = 'gs://YOUR_BUCKET_ID/path_to_your_input_csv_or_jsonl',
  outputUri = 'gs://YOUR_BUCKET_ID/path_to_save_results/'
)

Source from the content-addressed store, hash-verified

15'use strict';
16
17function 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
70process.on('unhandledRejection', err => {
71 console.error(err.message);

Callers 1

batch_predict.jsFile · 0.70

Calls 1

batchPredictFunction · 0.70

Tested by

no test coverage detected