diff --git a/ai-platform/snippets/create-batch-prediction-job-text-classification.js b/ai-platform/snippets/create-batch-prediction-job-text-classification.js deleted file mode 100644 index f9cc5f3504..0000000000 --- a/ai-platform/snippets/create-batch-prediction-job-text-classification.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -async function main( - batchPredictionDisplayName, - modelId, - gcsSourceUri, - gcsDestinationOutputUriPrefix, - project, - location = 'us-central1' -) { - // [START aiplatform_create_batch_prediction_job_text_classification_sample] - /** - * TODO(developer): Uncomment these variables before running the sample.\ - * (Not necessary if passing values as arguments) - */ - - // const batchPredictionDisplayName = 'YOUR_BATCH_PREDICTION_DISPLAY_NAME'; - // const modelId = 'YOUR_MODEL_ID'; - // const gcsSourceUri = 'YOUR_GCS_SOURCE_URI'; - // const gcsDestinationOutputUriPrefix = 'YOUR_GCS_DEST_OUTPUT_URI_PREFIX'; - // eg. "gs:///destination_path" - // const project = 'YOUR_PROJECT_ID'; - // const location = 'YOUR_PROJECT_LOCATION'; - - // Imports the Google Cloud Job Service Client library - const {JobServiceClient} = require('@google-cloud/aiplatform').v1; - - // Specifies the location of the api endpoint - const clientOptions = { - apiEndpoint: 'us-central1-aiplatform.googleapis.com', - }; - - // Instantiates a client - const jobServiceClient = new JobServiceClient(clientOptions); - - async function createBatchPredictionJobTextClassification() { - // Configure the parent resource - const parent = `projects/${project}/locations/${location}`; - const modelName = `projects/${project}/locations/${location}/models/${modelId}`; - - const inputConfig = { - instancesFormat: 'jsonl', - gcsSource: {uris: [gcsSourceUri]}, - }; - const outputConfig = { - predictionsFormat: 'jsonl', - gcsDestination: {outputUriPrefix: gcsDestinationOutputUriPrefix}, - }; - const batchPredictionJob = { - displayName: batchPredictionDisplayName, - model: modelName, - inputConfig, - outputConfig, - }; - const request = { - parent, - batchPredictionJob, - }; - - // Create batch prediction job request - const [response] = await jobServiceClient.createBatchPredictionJob(request); - - console.log('Create batch prediction job text classification response'); - console.log(`Name : ${response.name}`); - console.log('Raw response:'); - console.log(JSON.stringify(response, null, 2)); - } - createBatchPredictionJobTextClassification(); - // [END aiplatform_create_batch_prediction_job_text_classification_sample] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); - -main(...process.argv.slice(2)); diff --git a/ai-platform/snippets/create-batch-prediction-job-text-entity-extraction.js b/ai-platform/snippets/create-batch-prediction-job-text-entity-extraction.js deleted file mode 100644 index 4497c777a9..0000000000 --- a/ai-platform/snippets/create-batch-prediction-job-text-entity-extraction.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -async function main( - batchPredictionDisplayName, - modelId, - gcsSourceUri, - gcsDestinationOutputUriPrefix, - project, - location = 'us-central1' -) { - // [START aiplatform_create_batch_prediction_job_text_entity_extraction_sample] - /** - * TODO(developer): Uncomment these variables before running the sample.\ - * (Not necessary if passing values as arguments) - */ - - // const batchPredictionDisplayName = 'YOUR_BATCH_PREDICTION_DISPLAY_NAME'; - // const modelId = 'YOUR_MODEL_ID'; - // const gcsSourceUri = 'YOUR_GCS_SOURCE_URI'; - // const gcsDestinationOutputUriPrefix = 'YOUR_GCS_DEST_OUTPUT_URI_PREFIX'; - // eg. "gs:///destination_path" - // const project = 'YOUR_PROJECT_ID'; - // const location = 'YOUR_PROJECT_LOCATION'; - - // Imports the Google Cloud Job Service Client library - const {JobServiceClient} = require('@google-cloud/aiplatform').v1; - - // Specifies the location of the api endpoint - const clientOptions = { - apiEndpoint: 'us-central1-aiplatform.googleapis.com', - }; - - // Instantiates a client - const jobServiceClient = new JobServiceClient(clientOptions); - - async function createBatchPredictionJobTextEntityExtraction() { - // Configure the parent resource - const parent = `projects/${project}/locations/${location}`; - const modelName = `projects/${project}/locations/${location}/models/${modelId}`; - - const inputConfig = { - instancesFormat: 'jsonl', - gcsSource: {uris: [gcsSourceUri]}, - }; - const outputConfig = { - predictionsFormat: 'jsonl', - gcsDestination: {outputUriPrefix: gcsDestinationOutputUriPrefix}, - }; - const batchPredictionJob = { - displayName: batchPredictionDisplayName, - model: modelName, - inputConfig, - outputConfig, - }; - const request = { - parent, - batchPredictionJob, - }; - - // Create batch prediction job request - const [response] = await jobServiceClient.createBatchPredictionJob(request); - - console.log('Create batch prediction job text entity extraction response'); - console.log(`Name : ${response.name}`); - console.log('Raw response:'); - console.log(JSON.stringify(response, null, 2)); - } - createBatchPredictionJobTextEntityExtraction(); - // [END aiplatform_create_batch_prediction_job_text_entity_extraction_sample] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); - -main(...process.argv.slice(2)); diff --git a/ai-platform/snippets/get-entity-type-sample.js b/ai-platform/snippets/get-entity-type-sample.js deleted file mode 100644 index 7123bb34e5..0000000000 --- a/ai-platform/snippets/get-entity-type-sample.js +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Gets details of a single EntityType. - * See https://cloud.google.com/vertex-ai/docs/featurestore/setup before running - * the code snippet - */ - -'use strict'; - -async function main( - project, - featurestoreId, - entityTypeId, - location = 'us-central1', - apiEndpoint = 'us-central1-aiplatform.googleapis.com', - timeout = 5000 -) { - // [START aiplatform_get_entity_type_sample] - /** - * TODO(developer): Uncomment these variables before running the sample.\ - * (Not necessary if passing values as arguments) - */ - - // const project = 'YOUR_PROJECT_ID'; - // const featurestoreId = 'YOUR_FEATURESTORE_ID'; - // const entityTypeId = 'YOUR_ENTITY_TYPE_ID'; - // const location = 'YOUR_PROJECT_LOCATION'; - // const apiEndpoint = 'YOUR_API_ENDPOINT'; - // const timeout = ; - - // Imports the Google Cloud Featurestore Service Client library - const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1; - - // Specifies the location of the api endpoint - const clientOptions = { - apiEndpoint: apiEndpoint, - }; - - // Instantiates a client - const featurestoreServiceClient = new FeaturestoreServiceClient( - clientOptions - ); - - async function getEntityType() { - // Configure the name resource - const name = `projects/${project}/locations/${location}/featurestores/${featurestoreId}/entityTypes/${entityTypeId}`; - - const request = { - name: name, - }; - - // Get EntityType request - const [response] = await featurestoreServiceClient.getEntityType(request, { - timeout: Number(timeout), - }); - - console.log('Get entity type response'); - console.log(`Name : ${response.name}`); - console.log('Raw response:'); - console.log(JSON.stringify(response, null, 2)); - } - getEntityType(); - // [END aiplatform_get_entity_type_sample] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); - -main(...process.argv.slice(2)); diff --git a/ai-platform/snippets/get-model-evaluation-video-action-recognition.js b/ai-platform/snippets/get-model-evaluation-video-action-recognition.js deleted file mode 100644 index 8b67cc9fed..0000000000 --- a/ai-platform/snippets/get-model-evaluation-video-action-recognition.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -async function main(modelId, evaluationId, project, location = 'us-central1') { - // [START aiplatform_get_model_evaluation_video_action_recognition_sample] - /** - * TODO(developer): Uncomment these variables before running the sample - * (not necessary if passing values as arguments). To obtain evaluationId, - * instantiate the client and run the following the commands. - */ - // const parentName = `projects/${project}/locations/${location}/models/${modelId}`; - // const evalRequest = { - // parent: parentName - // }; - // const [evalResponse] = await modelServiceClient.listModelEvaluations(evalRequest); - // console.log(evalResponse); - - // const modelId = 'YOUR_MODEL_ID'; - // const evaluationId = 'YOUR_EVALUATION_ID'; - // const project = 'YOUR_PROJECT_ID'; - // const location = 'YOUR_PROJECT_LOCATION'; - - // Imports the Google Cloud Model Service Client library - const {ModelServiceClient} = require('@google-cloud/aiplatform'); - - // Specifies the location of the api endpoint - const clientOptions = { - apiEndpoint: 'us-central1-aiplatform.googleapis.com', - }; - - // Instantiates a client - const modelServiceClient = new ModelServiceClient(clientOptions); - - async function getModelEvaluationVideoActionRecognition() { - // Configure the parent resources - const name = modelServiceClient.modelEvaluationPath( - project, - location, - modelId, - evaluationId - ); - const request = { - name, - }; - - // Create get model evaluation request - const [response] = await modelServiceClient.getModelEvaluation(request); - - console.log('Get model evaluation video action recognition response'); - console.log(`\tName : ${response.name}`); - console.log(`\tMetrics schema uri : ${response.metricsSchemaUri}`); - console.log(`\tMetrics : ${JSON.stringify(response.metrics)}`); - console.log(`\tCreate time : ${JSON.stringify(response.createTime)}`); - console.log(`\tSlice dimensions : ${response.sliceDimensions}`); - } - getModelEvaluationVideoActionRecognition(); - // [END aiplatform_get_model_evaluation_video_action_recognition_sample] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); - -main(...process.argv.slice(2)); diff --git a/ai-platform/snippets/import-data-video-object-tracking.js b/ai-platform/snippets/import-data-video-object-tracking.js deleted file mode 100644 index b447fa2988..0000000000 --- a/ai-platform/snippets/import-data-video-object-tracking.js +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -async function main( - datasetId, - gcsSourceUri, - project, - location = 'us-central1' -) { - // [START aiplatform_import_data_video_object_tracking_sample] - /** - * TODO(developer): Uncomment these variables before running the sample.\ - */ - - // const datasetId = 'YOUR_DATASET_ID'; - // const gcsSourceUri = 'YOUR_GCS_SOURCE_URI'; - // eg. 'gs:////[file.csv/file.jsonl]' - // const project = 'YOUR_PROJECT_ID'; - // const location = 'YOUR_PROJECT_LOCATION'; - - // Imports the Google Cloud Dataset Service Client library - const {DatasetServiceClient} = require('@google-cloud/aiplatform'); - - // Specifies the location of the api endpoint - const clientOptions = { - apiEndpoint: 'us-central1-aiplatform.googleapis.com', - }; - const datasetServiceClient = new DatasetServiceClient(clientOptions); - - async function importDataVideoObjectTracking() { - const name = datasetServiceClient.datasetPath(project, location, datasetId); - // Here we use only one import config with one source - const importConfigs = [ - { - gcsSource: {uris: [gcsSourceUri]}, - importSchemaUri: - 'gs://google-cloud-aiplatform/schema/dataset/ioformat/video_object_tracking_io_format_1.0.0.yaml', - }, - ]; - const request = { - name, - importConfigs, - }; - - // Create Import Data Request - const [response] = await datasetServiceClient.importData(request); - console.log(`Long running operation: ${JSON.stringify(response.name)}`); - - // Wait for operation to complete - const [importDataResponse] = await response.promise(); - - console.log( - `Import data video object tracking response : \ - ${JSON.stringify(importDataResponse)}` - ); - } - importDataVideoObjectTracking(); - // [END aiplatform_import_data_video_object_tracking_sample] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); - -main(...process.argv.slice(2)); diff --git a/ai-platform/snippets/list-endpoints.js b/ai-platform/snippets/list-endpoints.js deleted file mode 100644 index 01e425910c..0000000000 --- a/ai-platform/snippets/list-endpoints.js +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright 2020, Google, LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -async function main(projectId, location = 'us-central1') { - // [START aiplatform_list_endpoints_sample] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'YOUR_PROJECT_ID'; - // const location = 'YOUR_PROJECT_LOCATION'; - - const {EndpointServiceClient} = require('@google-cloud/aiplatform'); - - // Specifies the location of the api endpoint - const clientOptions = { - apiEndpoint: 'us-central1-aiplatform.googleapis.com', - }; - const client = new EndpointServiceClient(clientOptions); - - async function listEndpoints() { - // Configure the parent resource - const parent = `projects/${projectId}/locations/${location}`; - const request = { - parent, - }; - - // Get and print out a list of all the endpoints for this resource - const [result] = await client.listEndpoints(request); - for (const endpoint of result) { - console.log(`\nEndpoint name: ${endpoint.name}`); - console.log(`Display name: ${endpoint.displayName}`); - if (endpoint.deployedModels[0]) { - console.log( - `First deployed model: ${endpoint.deployedModels[0].model}` - ); - } - } - } - listEndpoints(); - // [END aiplatform_list_endpoints_sample] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); - -main(...process.argv.slice(2)); diff --git a/ai-platform/snippets/list-entity-types-async-sample.js b/ai-platform/snippets/list-entity-types-async-sample.js deleted file mode 100644 index c6b1c7401e..0000000000 --- a/ai-platform/snippets/list-entity-types-async-sample.js +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Lists EntityTypes Asynchronously in a given Featurestore. - * See https://cloud.google.com/vertex-ai/docs/featurestore/setup before running - * the code snippet - */ - -'use strict'; - -async function main( - project, - featurestoreId, - location = 'us-central1', - apiEndpoint = 'us-central1-aiplatform.googleapis.com', - timeout = 5000 -) { - // [START aiplatform_list_entity_types_async_sample] - /** - * TODO(developer): Uncomment these variables before running the sample.\ - * (Not necessary if passing values as arguments) - */ - - // const project = 'YOUR_PROJECT_ID'; - // const featurestoreId = 'YOUR_FEATURESTORE_ID'; - // const location = 'YOUR_PROJECT_LOCATION'; - // const apiEndpoint = 'YOUR_API_ENDPOINT'; - // const timeout = ; - - // Imports the Google Cloud Featurestore Service Client library - const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1; - - // Specifies the location of the api endpoint - const clientOptions = { - apiEndpoint: apiEndpoint, - }; - - // Instantiates a client - const featurestoreServiceClient = new FeaturestoreServiceClient( - clientOptions - ); - - async function listEntityTypesAsync() { - // Configure the parent resource - const parent = `projects/${project}/locations/${location}/featurestores/${featurestoreId}`; - - const request = { - parent: parent, - }; - - // List EntityTypes Async request - const iterable = await featurestoreServiceClient.listEntityTypesAsync( - request, - {timeout: Number(timeout)} - ); - - console.log('List entity types async response'); - console.log('Raw response:'); - for await (const response of iterable) { - console.log(JSON.stringify(response, null, 2)); - } - } - listEntityTypesAsync(); - // [END aiplatform_list_entity_types_async_sample] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); - -main(...process.argv.slice(2)); diff --git a/ai-platform/snippets/list-entity-types-stream-sample.js b/ai-platform/snippets/list-entity-types-stream-sample.js deleted file mode 100644 index 5197d79fc0..0000000000 --- a/ai-platform/snippets/list-entity-types-stream-sample.js +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Lists EntityTypes using streaming in a given Featurestore. - * See https://cloud.google.com/vertex-ai/docs/featurestore/setup before running - * the code snippet - */ - -'use strict'; - -async function main( - project, - featurestoreId, - location = 'us-central1', - apiEndpoint = 'us-central1-aiplatform.googleapis.com', - timeout = 5000 -) { - // [START aiplatform_list_entity_types_stream_sample] - /** - * TODO(developer): Uncomment these variables before running the sample.\ - * (Not necessary if passing values as arguments) - */ - - // const project = 'YOUR_PROJECT_ID'; - // const featurestoreId = 'YOUR_FEATURESTORE_ID'; - // const location = 'YOUR_PROJECT_LOCATION'; - // const apiEndpoint = 'YOUR_API_ENDPOINT'; - // const timeout = ; - - // Imports the Google Cloud Featurestore Service Client library - const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1; - - // Specifies the location of the api endpoint - const clientOptions = { - apiEndpoint: apiEndpoint, - }; - - // Instantiates a client - const featurestoreServiceClient = new FeaturestoreServiceClient( - clientOptions - ); - - async function listEntityTypesStream() { - // Configure the parent resource - const parent = `projects/${project}/locations/${location}/featurestores/${featurestoreId}`; - - const request = { - parent: parent, - }; - - // List EntityTypes stream request - const streamObject = await featurestoreServiceClient.listEntityTypesStream( - request, - {timeout: Number(timeout)} - ); - - console.log('List entity types stream response'); - console.log('Raw response:'); - streamObject.on('data', response => { - console.log(JSON.stringify(response, null, 2)); - }); - - streamObject.on('end', () => { - console.log('No more data to read'); - }); - - streamObject.on('close', () => { - console.log('Stream object listEntityTypesStream is closed'); - }); - } - listEntityTypesStream(); - // [END aiplatform_list_entity_types_stream_sample] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); - -main(...process.argv.slice(2)); diff --git a/ai-platform/snippets/list-features-async-sample.js b/ai-platform/snippets/list-features-async-sample.js deleted file mode 100644 index 5df6446fc2..0000000000 --- a/ai-platform/snippets/list-features-async-sample.js +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Lists Features Asynchronously in a given EntityType. - * See https://cloud.google.com/vertex-ai/docs/featurestore/setup before running - * the code snippet - */ - -'use strict'; - -async function main( - project, - featurestoreId, - entityTypeId, - location = 'us-central1', - apiEndpoint = 'us-central1-aiplatform.googleapis.com', - timeout = 300000 -) { - // [START aiplatform_list_features_async_sample] - /** - * TODO(developer): Uncomment these variables before running the sample.\ - * (Not necessary if passing values as arguments) - */ - - // const project = 'YOUR_PROJECT_ID'; - // const featurestoreId = 'YOUR_FEATURESTORE_ID'; - // const entityTypeId = 'YOUR_ENTITY_TYPE_ID'; - // const location = 'YOUR_PROJECT_LOCATION'; - // const apiEndpoint = 'YOUR_API_ENDPOINT'; - // const timeout = ; - - // Imports the Google Cloud Featurestore Service Client library - const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1; - - // Specifies the location of the api endpoint - const clientOptions = { - apiEndpoint: apiEndpoint, - }; - - // Instantiates a client - const featurestoreServiceClient = new FeaturestoreServiceClient( - clientOptions - ); - - async function listFeaturesAsync() { - // Configure the parent resource - const parent = `projects/${project}/locations/${location}/featurestores/${featurestoreId}/entityTypes/${entityTypeId}`; - - const request = { - parent: parent, - }; - - // List Features async request - const iterable = await featurestoreServiceClient.listFeaturesAsync( - request, - { - timeout: Number(timeout), - } - ); - - console.log('List features async response'); - console.log('Raw response:'); - for await (const response of iterable) { - console.log(JSON.stringify(response, null, 2)); - } - } - listFeaturesAsync(); - // [END aiplatform_list_features_async_sample] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); - -main(...process.argv.slice(2)); diff --git a/ai-platform/snippets/list-features-stream-sample.js b/ai-platform/snippets/list-features-stream-sample.js deleted file mode 100644 index c85e3f5462..0000000000 --- a/ai-platform/snippets/list-features-stream-sample.js +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Lists Features using streaming in a given EntityType. - * See https://cloud.google.com/vertex-ai/docs/featurestore/setup before running - * the code snippet - */ - -'use strict'; - -async function main( - project, - featurestoreId, - entityTypeId, - location = 'us-central1', - apiEndpoint = 'us-central1-aiplatform.googleapis.com', - timeout = 300000 -) { - // [START aiplatform_list_features_stream_sample] - /** - * TODO(developer): Uncomment these variables before running the sample.\ - * (Not necessary if passing values as arguments) - */ - - // const project = 'YOUR_PROJECT_ID'; - // const featurestoreId = 'YOUR_FEATURESTORE_ID'; - // const entityTypeId = 'YOUR_ENTITY_TYPE_ID'; - // const location = 'YOUR_PROJECT_LOCATION'; - // const apiEndpoint = 'YOUR_API_ENDPOINT'; - // const timeout = ; - - // Imports the Google Cloud Featurestore Service Client library - const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1; - - // Specifies the location of the api endpoint - const clientOptions = { - apiEndpoint: apiEndpoint, - }; - - // Instantiates a client - const featurestoreServiceClient = new FeaturestoreServiceClient( - clientOptions - ); - - async function listFeaturesStream() { - // Configure the parent resource - const parent = `projects/${project}/locations/${location}/featurestores/${featurestoreId}/entityTypes/${entityTypeId}`; - - const request = { - parent: parent, - }; - - // List Features stream request - const streamObject = await featurestoreServiceClient.listFeaturesStream( - request, - { - timeout: Number(timeout), - } - ); - - console.log('List features stream response'); - console.log('Raw response:'); - streamObject.on('data', response => { - console.log(JSON.stringify(response, null, 2)); - }); - - streamObject.on('end', () => { - console.log('No more data to read'); - }); - - streamObject.on('close', () => { - console.log('Stream object listFeaturesStream is closed'); - }); - } - listFeaturesStream(); - // [END aiplatform_list_features_stream_sample] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); - -main(...process.argv.slice(2)); diff --git a/ai-platform/snippets/test/create-batch-prediction-job-text-classification.test.js b/ai-platform/snippets/test/create-batch-prediction-job-text-classification.test.js deleted file mode 100644 index ac285ad4c4..0000000000 --- a/ai-platform/snippets/test/create-batch-prediction-job-text-classification.test.js +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const {assert} = require('chai'); -const {after, describe, it} = require('mocha'); -const uuid = require('uuid').v4; -const cp = require('child_process'); -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const aiplatform = require('@google-cloud/aiplatform'); -const clientOptions = { - apiEndpoint: 'us-central1-aiplatform.googleapis.com', -}; - -const jobServiceClient = new aiplatform.v1.JobServiceClient(clientOptions); - -const batchPredictionDisplayName = `temp_create_batch_prediction_text_classification_test${uuid()}`; -const modelId = '7827432074230366208'; -const gcsSourceUri = - 'gs://ucaip-samples-test-output/inputs/batch_predict_TCN/tcn_inputs.jsonl'; -const gcsDestinationOutputUriPrefix = 'gs://ucaip-samples-test-output/'; -const location = 'us-central1'; -const project = process.env.CAIP_PROJECT_ID; - -let batchPredictionJobId; - -describe('AI platform create batch prediction job text classification', () => { - it('should create a text classification batch prediction job', async () => { - const stdout = execSync( - `node ./create-batch-prediction-job-text-classification.js ${batchPredictionDisplayName} ${modelId} ${gcsSourceUri} ${gcsDestinationOutputUriPrefix} ${project} ${location}` - ); - assert.match( - stdout, - /Create batch prediction job text classification response/ - ); - batchPredictionJobId = stdout - .split('/locations/us-central1/batchPredictionJobs/')[1] - .split('\n')[0]; - }); - after('should cancel delete the batch prediction job', async () => { - const name = jobServiceClient.batchPredictionJobPath( - project, - location, - batchPredictionJobId - ); - - const cancelRequest = { - name, - }; - - jobServiceClient.cancelBatchPredictionJob(cancelRequest).then(() => { - const deleteRequest = { - name, - }; - - return jobServiceClient.deleteBatchPredictionJob(deleteRequest); - }); - }); -}); diff --git a/ai-platform/snippets/test/create-batch-prediction-job-text-entity-extraction.test.js b/ai-platform/snippets/test/create-batch-prediction-job-text-entity-extraction.test.js deleted file mode 100644 index bb630905bd..0000000000 --- a/ai-platform/snippets/test/create-batch-prediction-job-text-entity-extraction.test.js +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const {assert} = require('chai'); -const {after, describe, it} = require('mocha'); -const uuid = require('uuid').v4; -const cp = require('child_process'); -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const aiplatform = require('@google-cloud/aiplatform'); -const clientOptions = { - apiEndpoint: 'us-central1-aiplatform.googleapis.com', -}; - -const jobServiceClient = new aiplatform.v1.JobServiceClient(clientOptions); - -const batchPredictionDisplayName = `temp_create_batch_prediction_text_entity_extraction_test${uuid()}`; -const modelId = '6305215400179138560'; -const gcsSourceUri = - 'gs://ucaip-samples-test-output/inputs/batch_predict_TEN/ten_inputs.jsonl'; -const gcsDestinationOutputUriPrefix = 'gs://ucaip-samples-test-output/'; -const location = 'us-central1'; -const project = process.env.CAIP_PROJECT_ID; - -let batchPredictionJobId; - -describe('AI platform create batch prediction job text entity extraction', () => { - it('should create a text entity extraction batch prediction job', async () => { - const stdout = execSync( - `node ./create-batch-prediction-job-text-entity-extraction.js ${batchPredictionDisplayName} ${modelId} ${gcsSourceUri} ${gcsDestinationOutputUriPrefix} ${project} ${location}` - ); - assert.match( - stdout, - /Create batch prediction job text entity extraction response/ - ); - batchPredictionJobId = stdout - .split('/locations/us-central1/batchPredictionJobs/')[1] - .split('\n')[0]; - }); - after('should cancel delete the batch prediction job', async () => { - const name = jobServiceClient.batchPredictionJobPath( - project, - location, - batchPredictionJobId - ); - - const cancelRequest = { - name, - }; - - jobServiceClient.cancelBatchPredictionJob(cancelRequest).then(() => { - const deleteRequest = { - name, - }; - - return jobServiceClient.deleteBatchPredictionJob(deleteRequest); - }); - }); -}); diff --git a/ai-platform/snippets/test/get-model-evaluation-video-action-recognition.test.js b/ai-platform/snippets/test/get-model-evaluation-video-action-recognition.test.js deleted file mode 100644 index a52568aae4..0000000000 --- a/ai-platform/snippets/test/get-model-evaluation-video-action-recognition.test.js +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); - -const cp = require('child_process'); -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const modelId = '3530998029718913024'; -const evaluationId = '305008923591573504'; -const project = process.env.CAIP_PROJECT_ID; -const location = 'us-central1'; - -describe('AI platform get video action recognition model evaluation', () => { - it('should get the evaluation from the specified model', async () => { - const stdout = execSync( - `node ./get-model-evaluation-video-action-recognition.js ${modelId} \ - ${evaluationId} \ - ${project} \ - ${location}` - ); - assert.match( - stdout, - /Get model evaluation video action recognition response/ - ); - }); -}); diff --git a/ai-platform/snippets/test/list-endpoints.test.js b/ai-platform/snippets/test/list-endpoints.test.js deleted file mode 100644 index 7274916692..0000000000 --- a/ai-platform/snippets/test/list-endpoints.test.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright 2020, Google, LLC. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const path = require('path'); -const {assert} = require('chai'); -const {describe, it} = require('mocha'); - -const cp = require('child_process'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const cwd = path.join(__dirname, '..'); -const LOCATION = 'us-central1'; -const project = process.env.CAIP_PROJECT_ID; - -describe('AI platform list endpoints', () => { - it('should list all endpoints in a parent resource', async () => { - const stdout = execSync(`node ./list-endpoints.js ${project} ${LOCATION}`, { - cwd, - }); - assert.match(stdout, /Endpoint/); - }); -});