Skip to content
This repository was archived by the owner on Sep 9, 2023. It is now read-only.

Commit 872efb4

Browse files
sai-chaithugcf-owl-bot[bot]alicejli
authored
feat(samples): add remaining featurestore api samples (#974)
* Added Featurestore Samples * feat(samples): add remaining featurestore api samples (googleapis#945) * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat(samples): update all featurestore samples * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Alice <[email protected]>
1 parent bcbc2b0 commit 872efb4

8 files changed

+645
-1
lines changed

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ If you are using Maven without BOM, add this to your dependencies:
3838
If you are using Gradle 5.x or later, add this to your dependencies:
3939

4040
```Groovy
41-
implementation platform('com.google.cloud:libraries-bom:25.4.0')
41+
implementation platform('com.google.cloud:libraries-bom:26.0.0')
4242
4343
implementation 'com.google.cloud:google-cloud-aiplatform'
4444
```
@@ -120,6 +120,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-aiplatform/tr
120120
| Create Endpoint Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/CreateEndpointSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/CreateEndpointSample.java) |
121121
| Create Entity Type Monitoring Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/CreateEntityTypeMonitoringSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/CreateEntityTypeMonitoringSample.java) |
122122
| Create Entity Type Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/CreateEntityTypeSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/CreateEntityTypeSample.java) |
123+
| Create Featurestore Fixed Nodes Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/CreateFeaturestoreFixedNodesSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/CreateFeaturestoreFixedNodesSample.java) |
123124
| Create Featurestore Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/CreateFeaturestoreSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/CreateFeaturestoreSample.java) |
124125
| Create Hyperparameter Tuning Job Python Package Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/CreateHyperparameterTuningJobPythonPackageSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/CreateHyperparameterTuningJobPythonPackageSample.java) |
125126
| Create Hyperparameter Tuning Job Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/CreateHyperparameterTuningJobSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/CreateHyperparameterTuningJobSample.java) |
@@ -152,6 +153,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-aiplatform/tr
152153
| Export Model Video Action Recognition Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/ExportModelVideoActionRecognitionSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/ExportModelVideoActionRecognitionSample.java) |
153154
| Get Batch Prediction Job Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/GetBatchPredictionJobSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/GetBatchPredictionJobSample.java) |
154155
| Get Entity Type Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/GetEntityTypeSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/GetEntityTypeSample.java) |
156+
| Get Featurestore Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/GetFeaturestoreSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/GetFeaturestoreSample.java) |
155157
| Get Hyperparameter Tuning Job Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/GetHyperparameterTuningJobSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/GetHyperparameterTuningJobSample.java) |
156158
| Get Model Evaluation Image Classification Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/GetModelEvaluationImageClassificationSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/GetModelEvaluationImageClassificationSample.java) |
157159
| Get Model Evaluation Image Object Detection Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/GetModelEvaluationImageObjectDetectionSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/GetModelEvaluationImageObjectDetectionSample.java) |
@@ -177,6 +179,8 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-aiplatform/tr
177179
| Import Data Video Object Tracking Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/ImportDataVideoObjectTrackingSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/ImportDataVideoObjectTrackingSample.java) |
178180
| List Entity Types Async Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/ListEntityTypesAsyncSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/ListEntityTypesAsyncSample.java) |
179181
| List Entity Types Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/ListEntityTypesSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/ListEntityTypesSample.java) |
182+
| List Featurestores Async Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/ListFeaturestoresAsyncSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/ListFeaturestoresAsyncSample.java) |
183+
| List Featurestores Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/ListFeaturestoresSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/ListFeaturestoresSample.java) |
180184
| List Model Evaluation Slice Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/ListModelEvaluationSliceSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/ListModelEvaluationSliceSample.java) |
181185
| Predict Custom Trained Model Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/PredictCustomTrainedModelSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/PredictCustomTrainedModelSample.java) |
182186
| Predict Image Classification Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/PredictImageClassificationSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/PredictImageClassificationSample.java) |
@@ -189,6 +193,8 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-aiplatform/tr
189193
| Undeploy Model Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/UndeployModelSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/UndeployModelSample.java) |
190194
| Update Entity Type Monitoring Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/UpdateEntityTypeMonitoringSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/UpdateEntityTypeMonitoringSample.java) |
191195
| Update Entity Type Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/UpdateEntityTypeSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/UpdateEntityTypeSample.java) |
196+
| Update Featurestore Fixed Nodes Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/UpdateFeaturestoreFixedNodesSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/UpdateFeaturestoreFixedNodesSample.java) |
197+
| Update Featurestore Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/UpdateFeaturestoreSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/UpdateFeaturestoreSample.java) |
192198
| Upload Model Sample | [source code](https://github.com/googleapis/java-aiplatform/blob/main/samples/snippets/src/main/java/aiplatform/UploadModelSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-aiplatform&page=editor&open_in_editor=samples/snippets/src/main/java/aiplatform/UploadModelSample.java) |
193199

194200

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*
17+
* Create a featurestore resource to contain entity types and features. See
18+
* https://cloud.google.com/vertex-ai/docs/featurestore/setup before running
19+
* the code snippet
20+
*/
21+
22+
package aiplatform;
23+
24+
// [START aiplatform_create_featurestore_fixed_nodes_sample]
25+
26+
import com.google.api.gax.longrunning.OperationFuture;
27+
import com.google.cloud.aiplatform.v1beta1.CreateFeaturestoreOperationMetadata;
28+
import com.google.cloud.aiplatform.v1beta1.CreateFeaturestoreRequest;
29+
import com.google.cloud.aiplatform.v1beta1.Featurestore;
30+
import com.google.cloud.aiplatform.v1beta1.Featurestore.OnlineServingConfig;
31+
import com.google.cloud.aiplatform.v1beta1.FeaturestoreServiceClient;
32+
import com.google.cloud.aiplatform.v1beta1.FeaturestoreServiceSettings;
33+
import com.google.cloud.aiplatform.v1beta1.LocationName;
34+
import java.io.IOException;
35+
import java.util.concurrent.ExecutionException;
36+
import java.util.concurrent.TimeUnit;
37+
import java.util.concurrent.TimeoutException;
38+
39+
public class CreateFeaturestoreFixedNodesSample {
40+
41+
public static void main(String[] args)
42+
throws IOException, InterruptedException, ExecutionException, TimeoutException {
43+
// TODO(developer): Replace these variables before running the sample.
44+
String project = "YOUR_PROJECT_ID";
45+
String featurestoreId = "YOUR_FEATURESTORE_ID";
46+
int fixedNodeCount = 1;
47+
String location = "us-central1";
48+
String endpoint = "us-central1-aiplatform.googleapis.com:443";
49+
int timeout = 900;
50+
createFeaturestoreFixedNodesSample(
51+
project, featurestoreId, fixedNodeCount, location, endpoint, timeout);
52+
}
53+
54+
static void createFeaturestoreFixedNodesSample(
55+
String project,
56+
String featurestoreId,
57+
int fixedNodeCount,
58+
String location,
59+
String endpoint,
60+
int timeout)
61+
throws IOException, InterruptedException, ExecutionException, TimeoutException {
62+
63+
FeaturestoreServiceSettings featurestoreServiceSettings =
64+
FeaturestoreServiceSettings.newBuilder().setEndpoint(endpoint).build();
65+
66+
// Initialize client that will be used to send requests. This client only needs to be created
67+
// once, and can be reused for multiple requests. After completing all of your requests, call
68+
// the "close" method on the client to safely clean up any remaining background resources.
69+
try (FeaturestoreServiceClient featurestoreServiceClient =
70+
FeaturestoreServiceClient.create(featurestoreServiceSettings)) {
71+
72+
OnlineServingConfig.Builder builderValue =
73+
OnlineServingConfig.newBuilder().setFixedNodeCount(fixedNodeCount);
74+
Featurestore featurestore =
75+
Featurestore.newBuilder().setOnlineServingConfig(builderValue).build();
76+
77+
CreateFeaturestoreRequest createFeaturestoreRequest =
78+
CreateFeaturestoreRequest.newBuilder()
79+
.setParent(LocationName.of(project, location).toString())
80+
.setFeaturestore(featurestore)
81+
.setFeaturestoreId(featurestoreId)
82+
.build();
83+
84+
OperationFuture<Featurestore, CreateFeaturestoreOperationMetadata> featurestoreFuture =
85+
featurestoreServiceClient.createFeaturestoreAsync(createFeaturestoreRequest);
86+
System.out.format(
87+
"Operation name: %s%n", featurestoreFuture.getInitialFuture().get().getName());
88+
System.out.println("Waiting for operation to finish...");
89+
Featurestore featurestoreResponse = featurestoreFuture.get(timeout, TimeUnit.SECONDS);
90+
System.out.println("Create Featurestore Response");
91+
System.out.format("Name: %s%n", featurestoreResponse.getName());
92+
}
93+
}
94+
}
95+
// [END aiplatform_create_featurestore_fixed_nodes_sample]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*
17+
* Gets details of a single featurestore. See
18+
* https://cloud.google.com/vertex-ai/docs/featurestore/setup before running
19+
* the code snippet
20+
*/
21+
22+
package aiplatform;
23+
24+
// [START aiplatform_get_featurestore_sample]
25+
26+
import com.google.cloud.aiplatform.v1beta1.Featurestore;
27+
import com.google.cloud.aiplatform.v1beta1.FeaturestoreName;
28+
import com.google.cloud.aiplatform.v1beta1.FeaturestoreServiceClient;
29+
import com.google.cloud.aiplatform.v1beta1.FeaturestoreServiceSettings;
30+
import com.google.cloud.aiplatform.v1beta1.GetFeaturestoreRequest;
31+
import java.io.IOException;
32+
33+
public class GetFeaturestoreSample {
34+
35+
public static void main(String[] args) throws IOException {
36+
// TODO(developer): Replace these variables before running the sample.
37+
String project = "YOUR_PROJECT_ID";
38+
String featurestoreId = "YOUR_FEATURESTORE_ID";
39+
String location = "us-central1";
40+
String endpoint = "us-central1-aiplatform.googleapis.com:443";
41+
getFeaturestoreSample(project, featurestoreId, location, endpoint);
42+
}
43+
44+
static void getFeaturestoreSample(
45+
String project, String featurestoreId, String location, String endpoint) throws IOException {
46+
47+
FeaturestoreServiceSettings featurestoreServiceSettings =
48+
FeaturestoreServiceSettings.newBuilder().setEndpoint(endpoint).build();
49+
50+
// Initialize client that will be used to send requests. This client only needs to be created
51+
// once, and can be reused for multiple requests. After completing all of your requests, call
52+
// the "close" method on the client to safely clean up any remaining background resources.
53+
try (FeaturestoreServiceClient featurestoreServiceClient =
54+
FeaturestoreServiceClient.create(featurestoreServiceSettings)) {
55+
56+
GetFeaturestoreRequest getFeaturestoreRequest =
57+
GetFeaturestoreRequest.newBuilder()
58+
.setName(FeaturestoreName.of(project, location, featurestoreId).toString())
59+
.build();
60+
61+
Featurestore featurestore = featurestoreServiceClient.getFeaturestore(getFeaturestoreRequest);
62+
System.out.println("Get Featurestore Response");
63+
System.out.println(featurestore);
64+
}
65+
}
66+
}
67+
// [END aiplatform_get_featurestore_sample]

0 commit comments

Comments
 (0)