Search in sources :

Example 6 with Model

use of com.google.cloud.aiplatform.v1.Model in project modello by codehaus-plexus.

the class PackageVersionVerifier method testModelAddMailingList.

public void testModelAddMailingList() {
    Model model = new Model();
    model.addMailingList(createMailingList(0));
    model.addMailingList(createMailingList(1));
    model.addMailingList(createMailingList(2));
    List actual = model.getMailingLists();
    Assert.assertEquals("/model/mailinglists.size", 3, actual.size());
    for (int i = 0; i < 3; i++) {
        assertMailingList(createMailingList(i), (MailingList) actual.get(i));
    }
}
Also used : Model(org.apache.maven.model.v4_0_0.Model) List(java.util.List) MailingList(org.apache.maven.model.v4_0_0.MailingList) ArrayList(java.util.ArrayList)

Example 7 with Model

use of com.google.cloud.aiplatform.v1.Model in project java-aiplatform by googleapis.

the class ModelServiceClientTest method listModelsTest2.

@Test
public void listModelsTest2() throws Exception {
    Model responsesElement = Model.newBuilder().build();
    ListModelsResponse expectedResponse = ListModelsResponse.newBuilder().setNextPageToken("").addAllModels(Arrays.asList(responsesElement)).build();
    mockModelService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListModelsPagedResponse pagedListResponse = client.listModels(parent);
    List<Model> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getModelsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockModelService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListModelsRequest actualRequest = ((ListModelsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListModelsPagedResponse(com.google.cloud.aiplatform.v1.ModelServiceClient.ListModelsPagedResponse) Test(org.junit.Test)

Example 8 with Model

use of com.google.cloud.aiplatform.v1.Model in project java-aiplatform by googleapis.

the class ModelServiceClientTest method listModelEvaluationsTest.

@Test
public void listModelEvaluationsTest() throws Exception {
    ModelEvaluation responsesElement = ModelEvaluation.newBuilder().build();
    ListModelEvaluationsResponse expectedResponse = ListModelEvaluationsResponse.newBuilder().setNextPageToken("").addAllModelEvaluations(Arrays.asList(responsesElement)).build();
    mockModelService.addResponse(expectedResponse);
    ModelName parent = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]");
    ListModelEvaluationsPagedResponse pagedListResponse = client.listModelEvaluations(parent);
    List<ModelEvaluation> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getModelEvaluationsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockModelService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListModelEvaluationsRequest actualRequest = ((ListModelEvaluationsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListModelEvaluationsPagedResponse(com.google.cloud.aiplatform.v1.ModelServiceClient.ListModelEvaluationsPagedResponse) Test(org.junit.Test)

Example 9 with Model

use of com.google.cloud.aiplatform.v1.Model in project java-aiplatform by googleapis.

the class GetModelEvaluationTextEntityExtractionSample method getModelEvaluationTextEntityExtractionSample.

static void getModelEvaluationTextEntityExtractionSample(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);
        ModelEvaluation modelEvaluation = modelServiceClient.getModelEvaluation(modelEvaluationName);
        System.out.println("Get Model Evaluation Text Entity Extraction Response");
        System.out.format("\tModel Name: %s\n", modelEvaluation.getName());
        System.out.format("\tMetrics Schema Uri: %s\n", modelEvaluation.getMetricsSchemaUri());
        System.out.format("\tMetrics: %s\n", modelEvaluation.getMetrics());
        System.out.format("\tCreate Time: %s\n", modelEvaluation.getCreateTime());
        System.out.format("\tSlice Dimensions: %s\n", modelEvaluation.getSliceDimensionsList());
    }
}
Also used : ModelEvaluationName(com.google.cloud.aiplatform.v1.ModelEvaluationName) ModelEvaluation(com.google.cloud.aiplatform.v1.ModelEvaluation) ModelServiceSettings(com.google.cloud.aiplatform.v1.ModelServiceSettings) ModelServiceClient(com.google.cloud.aiplatform.v1.ModelServiceClient)

Example 10 with Model

use of com.google.cloud.aiplatform.v1.Model in project java-aiplatform by googleapis.

the class GetModelEvaluationTextSentimentAnalysisSample method getModelEvaluationTextSentimentAnalysisSample.

static void getModelEvaluationTextSentimentAnalysisSample(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);
        ModelEvaluation modelEvaluation = modelServiceClient.getModelEvaluation(modelEvaluationName);
        System.out.println("Get Model Evaluation Text Sentiment Analysis Response");
        System.out.format("\tModel Name: %s\n", modelEvaluation.getName());
        System.out.format("\tMetrics Schema Uri: %s\n", modelEvaluation.getMetricsSchemaUri());
        System.out.format("\tMetrics: %s\n", modelEvaluation.getMetrics());
        System.out.format("\tCreate Time: %s\n", modelEvaluation.getCreateTime());
        System.out.format("\tSlice Dimensions: %s\n", modelEvaluation.getSliceDimensionsList());
    }
}
Also used : ModelEvaluationName(com.google.cloud.aiplatform.v1.ModelEvaluationName) ModelEvaluation(com.google.cloud.aiplatform.v1.ModelEvaluation) ModelServiceSettings(com.google.cloud.aiplatform.v1.ModelServiceSettings) ModelServiceClient(com.google.cloud.aiplatform.v1.ModelServiceClient)

Aggregations

Test (org.junit.Test)52 Model (org.eclipse.xtext.valueconverter.bug250313.Model)30 LocationName (com.google.cloud.aiplatform.v1.LocationName)17 ModelServiceClient (com.google.cloud.aiplatform.v1.ModelServiceClient)17 ModelServiceSettings (com.google.cloud.aiplatform.v1.ModelServiceSettings)17 Model (com.google.cloud.aiplatform.v1.Model)16 AutoMlClient (com.google.cloud.automl.v1.AutoMlClient)16 Model (com.google.cloud.automl.v1.Model)16 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)16 PipelineServiceClient (com.google.cloud.aiplatform.v1.PipelineServiceClient)14 PipelineServiceSettings (com.google.cloud.aiplatform.v1.PipelineServiceSettings)14 TrainingPipeline (com.google.cloud.aiplatform.v1.TrainingPipeline)14 Value (com.google.protobuf.Value)14 InputDataConfig (com.google.cloud.aiplatform.v1.InputDataConfig)13 ModelContainerSpec (com.google.cloud.aiplatform.v1.ModelContainerSpec)13 ArrayList (java.util.ArrayList)12 EndpointName (com.google.cloud.aiplatform.v1.EndpointName)11 FilterSplit (com.google.cloud.aiplatform.v1.FilterSplit)11 FractionSplit (com.google.cloud.aiplatform.v1.FractionSplit)11 PredefinedSplit (com.google.cloud.aiplatform.v1.PredefinedSplit)11