Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Commit

Permalink
feat(samples): add remaining featurestore api samples (#338)
Browse files Browse the repository at this point in the history
* added create-featurestore-sample.js and create-featurestore-sample.test.js

* feat(samples): added createFeaturestore sample (#313)

* feat(samples): added remaining featurestore samples (#313)

* removed the extraneous files

* feat(samples): add remaining featurestore api samples (#313)

* feat(samples): add remaining featurestore apis samples (#313)

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* feat(samples): changed timeout of featurestore apis samples (#313)

* feat(samples): update featurestore-samples.test.js (#313)

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: junkourata <[email protected]>
  • Loading branch information
3 people authored Aug 2, 2022
1 parent 81f7ef2 commit f136458
Show file tree
Hide file tree
Showing 10 changed files with 860 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,15 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-ai-platform
| Delete-dataset | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/delete-dataset.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/delete-dataset.js,samples/README.md) |
| Delete-endpoint | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/delete-endpoint.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/delete-endpoint.js,samples/README.md) |
| Delete-export-model | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/delete-export-model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/delete-export-model.js,samples/README.md) |
| Delete-featurestore-sample | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/delete-featurestore-sample.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/delete-featurestore-sample.js,samples/README.md) |
| Delete-model | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/delete-model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/delete-model.js,samples/README.md) |
| Deploy-model-custom-trained-model | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/deploy-model-custom-trained-model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/deploy-model-custom-trained-model.js,samples/README.md) |
| Deploy-model | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/deploy-model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/deploy-model.js,samples/README.md) |
| Export-model-tabular-classification | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/export-model-tabular-classification.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/export-model-tabular-classification.js,samples/README.md) |
| Export-model | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/export-model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/export-model.js,samples/README.md) |
| Get-batch-prediction-job | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/get-batch-prediction-job.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/get-batch-prediction-job.js,samples/README.md) |
| Get-custom-job | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/get-custom-job.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/get-custom-job.js,samples/README.md) |
| Get-featurestore-sample | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/get-featurestore-sample.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/get-featurestore-sample.js,samples/README.md) |
| Get-hyperparameter-tuning-job | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/get-hyperparameter-tuning-job.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/get-hyperparameter-tuning-job.js,samples/README.md) |
| Get-model-evaluation-image-classification | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/get-model-evaluation-image-classification.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/get-model-evaluation-image-classification.js,samples/README.md) |
| Get-model-evaluation-image-object-detection | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/get-model-evaluation-image-object-detection.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/get-model-evaluation-image-object-detection.js,samples/README.md) |
Expand All @@ -143,6 +145,9 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-ai-platform
| Import-data-video-object-tracking | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/import-data-video-object-tracking.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/import-data-video-object-tracking.js,samples/README.md) |
| Import-data | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/import-data.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/import-data.js,samples/README.md) |
| List-endpoints | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/list-endpoints.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/list-endpoints.js,samples/README.md) |
| List-featurestores-async-sample | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/list-featurestores-async-sample.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/list-featurestores-async-sample.js,samples/README.md) |
| List-featurestores-sample | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/list-featurestores-sample.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/list-featurestores-sample.js,samples/README.md) |
| List-featurestores-stream-sample | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/list-featurestores-stream-sample.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/list-featurestores-stream-sample.js,samples/README.md) |
| List-model-evaluation-slices | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/list-model-evaluation-slices.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/list-model-evaluation-slices.js,samples/README.md) |
| Predict-custom-trained-model | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/predict-custom-trained-model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/predict-custom-trained-model.js,samples/README.md) |
| Predict-image-classification | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/predict-image-classification.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/predict-image-classification.js,samples/README.md) |
Expand All @@ -154,6 +159,8 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-ai-platform
| Predict-text-sentiment-analysis | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/predict-text-sentiment-analysis.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/predict-text-sentiment-analysis.js,samples/README.md) |
| Quickstart | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) |
| Undeploy-model | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/undeploy-model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/undeploy-model.js,samples/README.md) |
| Update-featurestore-fixed-nodes-sample | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/update-featurestore-fixed-nodes-sample.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/update-featurestore-fixed-nodes-sample.js,samples/README.md) |
| Update-featurestore-sample | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/update-featurestore-sample.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/update-featurestore-sample.js,samples/README.md) |
| Upload-model | [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/upload-model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/upload-model.js,samples/README.md) |


Expand Down
126 changes: 126 additions & 0 deletions samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ machine learning development lifecycle.
* [Delete-dataset](#delete-dataset)
* [Delete-endpoint](#delete-endpoint)
* [Delete-export-model](#delete-export-model)
* [Delete-featurestore-sample](#delete-featurestore-sample)
* [Delete-model](#delete-model)
* [Deploy-model-custom-trained-model](#deploy-model-custom-trained-model)
* [Deploy-model](#deploy-model)
* [Export-model-tabular-classification](#export-model-tabular-classification)
* [Export-model](#export-model)
* [Get-batch-prediction-job](#get-batch-prediction-job)
* [Get-custom-job](#get-custom-job)
* [Get-featurestore-sample](#get-featurestore-sample)
* [Get-hyperparameter-tuning-job](#get-hyperparameter-tuning-job)
* [Get-model-evaluation-image-classification](#get-model-evaluation-image-classification)
* [Get-model-evaluation-image-object-detection](#get-model-evaluation-image-object-detection)
Expand All @@ -81,6 +83,9 @@ machine learning development lifecycle.
* [Import-data-video-object-tracking](#import-data-video-object-tracking)
* [Import-data](#import-data)
* [List-endpoints](#list-endpoints)
* [List-featurestores-async-sample](#list-featurestores-async-sample)
* [List-featurestores-sample](#list-featurestores-sample)
* [List-featurestores-stream-sample](#list-featurestores-stream-sample)
* [List-model-evaluation-slices](#list-model-evaluation-slices)
* [Predict-custom-trained-model](#predict-custom-trained-model)
* [Predict-image-classification](#predict-image-classification)
Expand All @@ -92,6 +97,8 @@ machine learning development lifecycle.
* [Predict-text-sentiment-analysis](#predict-text-sentiment-analysis)
* [Quickstart](#quickstart)
* [Undeploy-model](#undeploy-model)
* [Update-featurestore-fixed-nodes-sample](#update-featurestore-fixed-nodes-sample)
* [Update-featurestore-sample](#update-featurestore-sample)
* [Upload-model](#upload-model)

## Before you begin
Expand Down Expand Up @@ -687,6 +694,23 @@ __Usage:__



### Delete-featurestore-sample

View the [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/delete-featurestore-sample.js).

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/delete-featurestore-sample.js,samples/README.md)

__Usage:__


`node samples/delete-featurestore-sample.js`


-----




### Delete-model

View the [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/delete-model.js).
Expand Down Expand Up @@ -806,6 +830,23 @@ __Usage:__



### Get-featurestore-sample

View the [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/get-featurestore-sample.js).

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/get-featurestore-sample.js,samples/README.md)

__Usage:__


`node samples/get-featurestore-sample.js`


-----




### Get-hyperparameter-tuning-job

View the [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/get-hyperparameter-tuning-job.js).
Expand Down Expand Up @@ -1231,6 +1272,57 @@ __Usage:__



### List-featurestores-async-sample

View the [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/list-featurestores-async-sample.js).

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/list-featurestores-async-sample.js,samples/README.md)

__Usage:__


`node samples/list-featurestores-async-sample.js`


-----




### List-featurestores-sample

View the [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/list-featurestores-sample.js).

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/list-featurestores-sample.js,samples/README.md)

__Usage:__


`node samples/list-featurestores-sample.js`


-----




### List-featurestores-stream-sample

View the [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/list-featurestores-stream-sample.js).

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/list-featurestores-stream-sample.js,samples/README.md)

__Usage:__


`node samples/list-featurestores-stream-sample.js`


-----




### List-model-evaluation-slices

View the [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/list-model-evaluation-slices.js).
Expand Down Expand Up @@ -1418,6 +1510,40 @@ __Usage:__



### Update-featurestore-fixed-nodes-sample

View the [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/update-featurestore-fixed-nodes-sample.js).

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/update-featurestore-fixed-nodes-sample.js,samples/README.md)

__Usage:__


`node samples/update-featurestore-fixed-nodes-sample.js`


-----




### Update-featurestore-sample

View the [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/update-featurestore-sample.js).

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-ai-platform&page=editor&open_in_editor=samples/update-featurestore-sample.js,samples/README.md)

__Usage:__


`node samples/update-featurestore-sample.js`


-----




### Upload-model

View the [source code](https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/upload-model.js).
Expand Down
88 changes: 88 additions & 0 deletions samples/delete-featurestore-sample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* 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.
*/

/*
* Deletes a single Featurestore.
* See https://cloud.google.com/vertex-ai/docs/featurestore/setup before running
* the code snippet
*/

'use strict';

async function main(
project,
featurestoreId,
force = false,
location = 'us-central1',
apiEndpoint = 'us-central1-aiplatform.googleapis.com',
timeout = 60000
) {
// [START aiplatform_delete_featurestore_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 force = <BOOLEAN>;
// const location = 'YOUR_PROJECT_LOCATION';
// const apiEndpoint = 'YOUR_API_ENDPOINT';
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;

// 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 deleteFeaturestore() {
// Configure the name resource
const name = `projects/${project}/locations/${location}/featurestores/${featurestoreId}`;

const request = {
name: name,
force: Boolean(force),
};

// Delete Featurestore request
const [operation] = await featurestoreServiceClient.deleteFeaturestore(
request,
{timeout: Number(timeout)}
);
const [response] = await operation.promise();

console.log('Delete featurestore response');
console.log('Raw response:');
console.log(JSON.stringify(response, null, 2));
}
deleteFeaturestore();
// [END aiplatform_delete_featurestore_sample]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});

main(...process.argv.slice(2));
Loading

0 comments on commit f136458

Please sign in to comment.