( projectId = 'YOUR_PROJECT_ID', location = 'us-central1', datasetId = 'YOUR_DISPLAY_ID', path = 'gs://BUCKET_ID/path_to_training_data.csv' )
| 15 | 'use strict'; |
| 16 | |
| 17 | function 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_beta] |
| 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').v1beta1; |
| 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_beta] |
| 60 | } |
| 61 | |
| 62 | process.on('unhandledRejection', err => { |
| 63 | console.error(err.message); |
no test coverage detected