Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: [aiplatform] Fix rpc tensorboard_service.proto definitions for BatchCreateTensorboardTimeSeries and BatchReadTensorboardTimeSeriesData #10221

Merged
merged 8 commits into from
Jan 19, 2024
2 changes: 1 addition & 1 deletion java-aiplatform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java11.html
[stability-image]: https://img.shields.io/badge/stability-stable-green
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-aiplatform.svg
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-aiplatform/3.33.0
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-aiplatform/3.34.0
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ public final OperationsClient getOperationsClient() {
* }</pre>
*
* @param parent Required. The resource name of the Location to create FeatureOnlineStores.
* Format: `projects/{project}/locations/{location}'`
* Format: `projects/{project}/locations/{location}`
* @param featureOnlineStore Required. The FeatureOnlineStore to create.
* @param featureOnlineStoreId Required. The ID to use for this FeatureOnlineStore, which will
* become the final component of the FeatureOnlineStore's resource name.
Expand Down Expand Up @@ -586,7 +586,7 @@ public final OperationsClient getOperationsClient() {
* }</pre>
*
* @param parent Required. The resource name of the Location to create FeatureOnlineStores.
* Format: `projects/{project}/locations/{location}'`
* Format: `projects/{project}/locations/{location}`
* @param featureOnlineStore Required. The FeatureOnlineStore to create.
* @param featureOnlineStoreId Required. The ID to use for this FeatureOnlineStore, which will
* become the final component of the FeatureOnlineStore's resource name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ public final OperationsClient getOperationsClient() {
* }</pre>
*
* @param parent Required. The resource name of the Location to create FeatureOnlineStores.
* Format: `projects/{project}/locations/{location}'`
* Format: `projects/{project}/locations/{location}`
* @param featureOnlineStore Required. The FeatureOnlineStore to create.
* @param featureOnlineStoreId Required. The ID to use for this FeatureOnlineStore, which will
* become the final component of the FeatureOnlineStore's resource name.
Expand Down Expand Up @@ -588,7 +588,7 @@ public final OperationsClient getOperationsClient() {
* }</pre>
*
* @param parent Required. The resource name of the Location to create FeatureOnlineStores.
* Format: `projects/{project}/locations/{location}'`
* Format: `projects/{project}/locations/{location}`
* @param featureOnlineStore Required. The FeatureOnlineStore to create.
* @param featureOnlineStoreId Required. The ID to use for this FeatureOnlineStore, which will
* become the final component of the FeatureOnlineStore's resource name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* EndpointName endpoint =
* EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]");
* List<Value> instances = new ArrayList<>();
* ComputeTokensResponse response = llmUtilityServiceClient.computeTokens(endpoint, instances);
* CountTokensResponse response = llmUtilityServiceClient.countTokens(endpoint, instances);
* }
* }</pre>
*
Expand All @@ -74,6 +74,25 @@
* <th>Description</th>
* <th>Method Variants</th>
* <tr>
* <td>CountTokens</td>
* <td><p> Perform a token counting.</td>
* <td>
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
* <ul>
* <li>countTokens(CountTokensRequest request)
* </ul>
* <p>"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.</p>
* <ul>
* <li>countTokens(EndpointName endpoint, List<Value> instances)
* <li>countTokens(String endpoint, List<Value> instances)
* </ul>
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
* <ul>
* <li>countTokensCallable()
* </ul>
* </td>
* </tr>
* <tr>
* <td>ComputeTokens</td>
* <td><p> Return a list of tokens based on the input text.</td>
* <td>
Expand Down Expand Up @@ -260,6 +279,142 @@ public LlmUtilityServiceStub getStub() {
return stub;
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Perform a token counting.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
* EndpointName endpoint =
* EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]");
* List<Value> instances = new ArrayList<>();
* CountTokensResponse response = llmUtilityServiceClient.countTokens(endpoint, instances);
* }
* }</pre>
*
* @param endpoint Required. The name of the Endpoint requested to perform token counting. Format:
* `projects/{project}/locations/{location}/endpoints/{endpoint}`
* @param instances Required. The instances that are the input to token counting call. Schema is
* identical to the prediction schema of the underlying model.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final CountTokensResponse countTokens(EndpointName endpoint, List<Value> instances) {
CountTokensRequest request =
CountTokensRequest.newBuilder()
.setEndpoint(endpoint == null ? null : endpoint.toString())
.addAllInstances(instances)
.build();
return countTokens(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Perform a token counting.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
* String endpoint =
* EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
* .toString();
* List<Value> instances = new ArrayList<>();
* CountTokensResponse response = llmUtilityServiceClient.countTokens(endpoint, instances);
* }
* }</pre>
*
* @param endpoint Required. The name of the Endpoint requested to perform token counting. Format:
* `projects/{project}/locations/{location}/endpoints/{endpoint}`
* @param instances Required. The instances that are the input to token counting call. Schema is
* identical to the prediction schema of the underlying model.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final CountTokensResponse countTokens(String endpoint, List<Value> instances) {
CountTokensRequest request =
CountTokensRequest.newBuilder().setEndpoint(endpoint).addAllInstances(instances).build();
return countTokens(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Perform a token counting.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
* CountTokensRequest request =
* CountTokensRequest.newBuilder()
* .setEndpoint(
* EndpointName.ofProjectLocationEndpointName(
* "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
* .toString())
* .setModel("model104069929")
* .addAllInstances(new ArrayList<Value>())
* .addAllContents(new ArrayList<Content>())
* .build();
* CountTokensResponse response = llmUtilityServiceClient.countTokens(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final CountTokensResponse countTokens(CountTokensRequest request) {
return countTokensCallable().call(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Perform a token counting.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
* CountTokensRequest request =
* CountTokensRequest.newBuilder()
* .setEndpoint(
* EndpointName.ofProjectLocationEndpointName(
* "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
* .toString())
* .setModel("model104069929")
* .addAllInstances(new ArrayList<Value>())
* .addAllContents(new ArrayList<Content>())
* .build();
* ApiFuture<CountTokensResponse> future =
* llmUtilityServiceClient.countTokensCallable().futureCall(request);
* // Do something.
* CountTokensResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<CountTokensRequest, CountTokensResponse> countTokensCallable() {
return stub.countTokensCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Return a list of tokens based on the input text.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
* build() is called, the tree of builders is called to create the complete settings object.
*
* <p>For example, to set the total timeout of computeTokens to 30 seconds:
* <p>For example, to set the total timeout of countTokens to 30 seconds:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
Expand All @@ -69,10 +69,10 @@
* LlmUtilityServiceSettings.Builder llmUtilityServiceSettingsBuilder =
* LlmUtilityServiceSettings.newBuilder();
* llmUtilityServiceSettingsBuilder
* .computeTokensSettings()
* .countTokensSettings()
* .setRetrySettings(
* llmUtilityServiceSettingsBuilder
* .computeTokensSettings()
* .countTokensSettings()
* .getRetrySettings()
* .toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
Expand All @@ -84,6 +84,11 @@
@Generated("by gapic-generator-java")
public class LlmUtilityServiceSettings extends ClientSettings<LlmUtilityServiceSettings> {

/** Returns the object with the settings used for calls to countTokens. */
public UnaryCallSettings<CountTokensRequest, CountTokensResponse> countTokensSettings() {
return ((LlmUtilityServiceStubSettings) getStubSettings()).countTokensSettings();
}

/** Returns the object with the settings used for calls to computeTokens. */
public UnaryCallSettings<ComputeTokensRequest, ComputeTokensResponse> computeTokensSettings() {
return ((LlmUtilityServiceStubSettings) getStubSettings()).computeTokensSettings();
Expand Down Expand Up @@ -213,6 +218,12 @@ public Builder applyToAllUnaryMethods(
return this;
}

/** Returns the builder for the settings used for calls to countTokens. */
public UnaryCallSettings.Builder<CountTokensRequest, CountTokensResponse>
countTokensSettings() {
return getStubSettingsBuilder().countTokensSettings();
}

/** Returns the builder for the settings used for calls to computeTokens. */
public UnaryCallSettings.Builder<ComputeTokensRequest, ComputeTokensResponse>
computeTokensSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,9 @@
"ComputeTokens": {
"methods": ["computeTokens", "computeTokens", "computeTokens", "computeTokensCallable"]
},
"CountTokens": {
"methods": ["countTokens", "countTokens", "countTokens", "countTokensCallable"]
},
"GetIamPolicy": {
"methods": ["getIamPolicy", "getIamPolicyCallable"]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
* EndpointName endpoint =
* EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]");
* List<Value> instances = new ArrayList<>();
* ComputeTokensResponse response = llmUtilityServiceClient.computeTokens(endpoint, instances);
* CountTokensResponse response = llmUtilityServiceClient.countTokens(endpoint, instances);
* }
* }</pre>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.aiplatform.v1beta1.ComputeTokensRequest;
import com.google.cloud.aiplatform.v1beta1.ComputeTokensResponse;
import com.google.cloud.aiplatform.v1beta1.CountTokensRequest;
import com.google.cloud.aiplatform.v1beta1.CountTokensResponse;
import com.google.cloud.location.GetLocationRequest;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
Expand All @@ -53,6 +55,16 @@
@BetaApi
@Generated("by gapic-generator-java")
public class GrpcLlmUtilityServiceStub extends LlmUtilityServiceStub {
private static final MethodDescriptor<CountTokensRequest, CountTokensResponse>
countTokensMethodDescriptor =
MethodDescriptor.<CountTokensRequest, CountTokensResponse>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.aiplatform.v1beta1.LlmUtilityService/CountTokens")
.setRequestMarshaller(ProtoUtils.marshaller(CountTokensRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(CountTokensResponse.getDefaultInstance()))
.build();

private static final MethodDescriptor<ComputeTokensRequest, ComputeTokensResponse>
computeTokensMethodDescriptor =
MethodDescriptor.<ComputeTokensRequest, ComputeTokensResponse>newBuilder()
Expand Down Expand Up @@ -110,6 +122,7 @@ public class GrpcLlmUtilityServiceStub extends LlmUtilityServiceStub {
ProtoUtils.marshaller(TestIamPermissionsResponse.getDefaultInstance()))
.build();

private final UnaryCallable<CountTokensRequest, CountTokensResponse> countTokensCallable;
private final UnaryCallable<ComputeTokensRequest, ComputeTokensResponse> computeTokensCallable;
private final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable;
private final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
Expand Down Expand Up @@ -164,6 +177,16 @@ protected GrpcLlmUtilityServiceStub(
this.callableFactory = callableFactory;
this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);

GrpcCallSettings<CountTokensRequest, CountTokensResponse> countTokensTransportSettings =
GrpcCallSettings.<CountTokensRequest, CountTokensResponse>newBuilder()
.setMethodDescriptor(countTokensMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("endpoint", String.valueOf(request.getEndpoint()));
return builder.build();
})
.build();
GrpcCallSettings<ComputeTokensRequest, ComputeTokensResponse> computeTokensTransportSettings =
GrpcCallSettings.<ComputeTokensRequest, ComputeTokensResponse>newBuilder()
.setMethodDescriptor(computeTokensMethodDescriptor)
Expand Down Expand Up @@ -226,6 +249,9 @@ protected GrpcLlmUtilityServiceStub(
})
.build();

this.countTokensCallable =
callableFactory.createUnaryCallable(
countTokensTransportSettings, settings.countTokensSettings(), clientContext);
this.computeTokensCallable =
callableFactory.createUnaryCallable(
computeTokensTransportSettings, settings.computeTokensSettings(), clientContext);
Expand Down Expand Up @@ -258,6 +284,11 @@ public GrpcOperationsStub getOperationsStub() {
return operationsStub;
}

@Override
public UnaryCallable<CountTokensRequest, CountTokensResponse> countTokensCallable() {
return countTokensCallable;
}

@Override
public UnaryCallable<ComputeTokensRequest, ComputeTokensResponse> computeTokensCallable() {
return computeTokensCallable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.aiplatform.v1beta1.ComputeTokensRequest;
import com.google.cloud.aiplatform.v1beta1.ComputeTokensResponse;
import com.google.cloud.aiplatform.v1beta1.CountTokensRequest;
import com.google.cloud.aiplatform.v1beta1.CountTokensResponse;
import com.google.cloud.location.GetLocationRequest;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
Expand All @@ -44,6 +46,10 @@
@Generated("by gapic-generator-java")
public abstract class LlmUtilityServiceStub implements BackgroundResource {

public UnaryCallable<CountTokensRequest, CountTokensResponse> countTokensCallable() {
throw new UnsupportedOperationException("Not implemented: countTokensCallable()");
}

public UnaryCallable<ComputeTokensRequest, ComputeTokensResponse> computeTokensCallable() {
throw new UnsupportedOperationException("Not implemented: computeTokensCallable()");
}
Expand Down