use of com.google.cloud.aiplatform.v1.ModelEvaluationSlice in project java-aiplatform by googleapis.
the class ListModelEvaluationSliceSample method listModelEvaluationSliceSample.
static void listModelEvaluationSliceSample(String project, String modelId, String evaluationId) throws IOException {
ModelServiceSettings modelServiceSettings = ModelServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
// the "close" method on the client to safely clean up any remaining background resources.
try (ModelServiceClient modelServiceClient = ModelServiceClient.create(modelServiceSettings)) {
String location = "us-central1";
ModelEvaluationName modelEvaluationName = ModelEvaluationName.of(project, location, modelId, evaluationId);
for (ModelEvaluationSlice modelEvaluationSlice : modelServiceClient.listModelEvaluationSlices(modelEvaluationName).iterateAll()) {
System.out.format("Model Evaluation Slice Name: %s\n", modelEvaluationSlice.getName());
System.out.format("Metrics Schema Uri: %s\n", modelEvaluationSlice.getMetricsSchemaUri());
System.out.format("Metrics: %s\n", modelEvaluationSlice.getMetrics());
System.out.format("Create Time: %s\n", modelEvaluationSlice.getCreateTime());
Slice slice = modelEvaluationSlice.getSlice();
System.out.format("Slice Dimensions: %s\n", slice.getDimension());
System.out.format("Slice Value: %s\n\n", slice.getValue());
}
}
}
use of com.google.cloud.aiplatform.v1.ModelEvaluationSlice in project java-aiplatform by googleapis.
the class ModelServiceClientTest method listModelEvaluationSlicesTest2.
@Test
public void listModelEvaluationSlicesTest2() throws Exception {
ModelEvaluationSlice responsesElement = ModelEvaluationSlice.newBuilder().build();
ListModelEvaluationSlicesResponse expectedResponse = ListModelEvaluationSlicesResponse.newBuilder().setNextPageToken("").addAllModelEvaluationSlices(Arrays.asList(responsesElement)).build();
mockModelService.addResponse(expectedResponse);
String parent = "parent-995424086";
ListModelEvaluationSlicesPagedResponse pagedListResponse = client.listModelEvaluationSlices(parent);
List<ModelEvaluationSlice> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getModelEvaluationSlicesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockModelService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListModelEvaluationSlicesRequest actualRequest = ((ListModelEvaluationSlicesRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.aiplatform.v1.ModelEvaluationSlice in project java-aiplatform by googleapis.
the class ModelServiceClientTest method listModelEvaluationSlicesTest.
@Test
public void listModelEvaluationSlicesTest() throws Exception {
ModelEvaluationSlice responsesElement = ModelEvaluationSlice.newBuilder().build();
ListModelEvaluationSlicesResponse expectedResponse = ListModelEvaluationSlicesResponse.newBuilder().setNextPageToken("").addAllModelEvaluationSlices(Arrays.asList(responsesElement)).build();
mockModelService.addResponse(expectedResponse);
ModelEvaluationName parent = ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[EVALUATION]");
ListModelEvaluationSlicesPagedResponse pagedListResponse = client.listModelEvaluationSlices(parent);
List<ModelEvaluationSlice> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getModelEvaluationSlicesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockModelService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListModelEvaluationSlicesRequest actualRequest = ((ListModelEvaluationSlicesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.aiplatform.v1.ModelEvaluationSlice in project java-aiplatform by googleapis.
the class GetModelEvaluationSliceSample method getModelEvaluationSliceSample.
static void getModelEvaluationSliceSample(String project, String modelId, String evaluationId, String sliceId) throws IOException {
ModelServiceSettings modelServiceSettings = ModelServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
// the "close" method on the client to safely clean up any remaining background resources.
try (ModelServiceClient modelServiceClient = ModelServiceClient.create(modelServiceSettings)) {
String location = "us-central1";
ModelEvaluationSliceName modelEvaluationSliceName = ModelEvaluationSliceName.of(project, location, modelId, evaluationId, sliceId);
ModelEvaluationSlice modelEvaluationSlice = modelServiceClient.getModelEvaluationSlice(modelEvaluationSliceName);
System.out.println("Get Model Evaluation Slice Response");
System.out.format("Model Evaluation Slice Name: %s\n", modelEvaluationSlice.getName());
System.out.format("Metrics Schema Uri: %s\n", modelEvaluationSlice.getMetricsSchemaUri());
System.out.format("Metrics: %s\n", modelEvaluationSlice.getMetrics());
System.out.format("Create Time: %s\n", modelEvaluationSlice.getCreateTime());
Slice slice = modelEvaluationSlice.getSlice();
System.out.format("Slice Dimensions: %s\n", slice.getDimension());
System.out.format("Slice Value: %s\n", slice.getValue());
}
}
Aggregations