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

Function main

ai-platform/snippets/create-dataset-text.js:19–72  ·  view source on GitHub ↗
(datasetDisplayName, project, location = 'us-central1')

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 1

createDatasetTextFunction · 0.85

Tested by

no test coverage detected