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

Function main

automl/import_dataset.js:17–60  ·  view source on GitHub ↗
(
  projectId = 'YOUR_PROJECT_ID',
  location = 'us-central1',
  datasetId = 'YOUR_DISPLAY_ID',
  path = 'gs://BUCKET_ID/path_to_training_data.csv'
)

Source from the content-addressed store, hash-verified

15'use strict';
16
17function main(
18 projectId = 'YOUR_PROJECT_ID',
19 location = 'us-central1',
20 datasetId = 'YOUR_DISPLAY_ID',
21 path = 'gs://BUCKET_ID/path_to_training_data.csv'
22) {
23 // [START automl_import_dataset]
24 /**
25 * TODO(developer): Uncomment these variables before running the sample.
26 */
27 // const projectId = 'YOUR_PROJECT_ID';
28 // const location = 'us-central1';
29 // const datasetId = 'YOUR_DISPLAY_ID';
30 // const path = 'gs://BUCKET_ID/path_to_training_data.csv';
31
32 // Imports the Google Cloud AutoML library
33 const {AutoMlClient} = require('@google-cloud/automl').v1;
34
35 // Instantiates a client
36 const client = new AutoMlClient();
37
38 async function importDataset() {
39 // Construct request
40 const request = {
41 name: client.datasetPath(projectId, location, datasetId),
42 inputConfig: {
43 gcsSource: {
44 inputUris: path.split(','),
45 },
46 },
47 };
48
49 // Import dataset
50 console.log('Proccessing import');
51 const [operation] = await client.importData(request);
52
53 // Wait for operation to complete.
54 const [response] = await operation.promise();
55 console.log(`Dataset imported: ${response}`);
56 }
57
58 importDataset();
59 // [END automl_import_dataset]
60}
61
62process.on('unhandledRejection', err => {
63 console.error(err.message);

Callers 1

import_dataset.jsFile · 0.70

Calls 1

importDatasetFunction · 0.70

Tested by

no test coverage detected