( datasetDisplayName, metadataSchemaUri, project, location = 'us-central1' )
| 17 | 'use strict'; |
| 18 | |
| 19 | async function main( |
| 20 | datasetDisplayName, |
| 21 | metadataSchemaUri, |
| 22 | project, |
| 23 | location = 'us-central1' |
| 24 | ) { |
| 25 | // [START aiplatform_create_dataset_sample] |
| 26 | /** |
| 27 | * TODO(developer): Uncomment these variables before running the sample.\ |
| 28 | * (Not necessary if passing values as arguments) |
| 29 | */ |
| 30 | |
| 31 | // const datasetDisplayName = 'YOUR_DATASET_DISPLAY_NAME'; |
| 32 | // const metadataSchemaUri = 'YOUR_METADATA_SCHEMA_URI'; |
| 33 | // const project = 'YOUR_PROJECT_ID'; |
| 34 | // const location = 'YOUR_PROJECT_LOCATION'; |
| 35 | |
| 36 | // Imports the Google Cloud Dataset Service Client library |
| 37 | const {DatasetServiceClient} = require('@google-cloud/aiplatform'); |
| 38 | |
| 39 | // Specifies the location of the api endpoint |
| 40 | const clientOptions = { |
| 41 | apiEndpoint: 'us-central1-aiplatform.googleapis.com', |
| 42 | }; |
| 43 | |
| 44 | // Instantiates a client |
| 45 | const datasetServiceClient = new DatasetServiceClient(clientOptions); |
| 46 | |
| 47 | async function createDataset() { |
| 48 | // Configure the parent resource |
| 49 | const parent = `projects/${project}/locations/${location}`; |
| 50 | // Configure the dataset resource |
| 51 | const dataset = { |
| 52 | displayName: datasetDisplayName, |
| 53 | metadataSchemaUri: metadataSchemaUri, |
| 54 | }; |
| 55 | const request = { |
| 56 | parent, |
| 57 | dataset, |
| 58 | }; |
| 59 | |
| 60 | // Create Dataset Request |
| 61 | const [response] = await datasetServiceClient.createDataset(request); |
| 62 | console.log(`Long running operation : ${response.name}`); |
| 63 | |
| 64 | // Wait for operation to complete |
| 65 | const [createDatasetResponse] = await response.promise(); |
| 66 | |
| 67 | console.log('Create dataset response'); |
| 68 | console.log(`\tName : ${createDatasetResponse.name}`); |
| 69 | console.log(`\tDisplay name : ${createDatasetResponse.displayName}`); |
| 70 | console.log( |
| 71 | `\tMetadata schema uri : ${createDatasetResponse.metadataSchemaUri}` |
| 72 | ); |
| 73 | console.log( |
| 74 | `\tMetadata : ${JSON.stringify(createDatasetResponse.metadata)}` |
| 75 | ); |
| 76 | console.log(`\tCreate time : ${createDatasetResponse.createTime}`); |
no test coverage detected