gapic-generator-python
gapic-generator-python copied to clipboard
Autogenerated snippets are incorrect when field type is a list
Example:
https://github.com/googleapis/python-aiplatform/blob/3d468ed10629e3d0f211f413af054e21620e5952/google/cloud/aiplatform_v1beta1/services/prediction_service/client.py#L1079
Proto:
message CountTokensRequest {
string endpoint = 1;
repeated google.protobuf.Value instances = 2;
}
Generated snippet and correction:
from google.cloud import aiplatform_v1beta1
def sample_count_tokens():
# Create a client
client = aiplatform_v1beta1.PredictionServiceClient()
# Initialize request argument(s)
- instances = aiplatform_v1beta1.Value()
- instances.null_value = "NULL_VALUE"
+ instances_0 = aiplatform_v1beta1.Value()
+ instances_0.null_value = "NULL_VALUE"
request = aiplatform_v1beta1.CountTokensRequest(
endpoint="endpoint_value",
- instances=instances,
+ instances=[instances_0],
)
# Make the request
response = client.count_tokens(request=request)
# Handle the response
print(response)