Search in sources :

Example 6 with LocationName

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

the class ImportDataImageObjectDetectionSampleTest method setUp.

@Before
public void setUp() throws InterruptedException, ExecutionException, TimeoutException, IOException {
    bout = new ByteArrayOutputStream();
    out = new PrintStream(bout);
    originalPrintStream = System.out;
    System.setOut(out);
    // create a temp dataset for importing data
    DatasetServiceSettings datasetServiceSettings = DatasetServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    try (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create(datasetServiceSettings)) {
        String metadataSchemaUri = "gs://google-cloud-aiplatform/schema/dataset/metadata/image_1.0.0.yaml";
        LocationName locationName = LocationName.of(PROJECT, LOCATION);
        Dataset dataset = Dataset.newBuilder().setDisplayName("test_dataset_display_name").setMetadataSchemaUri(metadataSchemaUri).build();
        OperationFuture<Dataset, CreateDatasetOperationMetadata> datasetFuture = datasetServiceClient.createDatasetAsync(locationName, dataset);
        Dataset datasetResponse = datasetFuture.get(120, TimeUnit.SECONDS);
        String[] datasetValues = datasetResponse.getName().split("/");
        datasetId = datasetValues[datasetValues.length - 1];
    }
}
Also used : PrintStream(java.io.PrintStream) DatasetServiceSettings(com.google.cloud.aiplatform.v1beta1.DatasetServiceSettings) CreateDatasetOperationMetadata(com.google.cloud.aiplatform.v1beta1.CreateDatasetOperationMetadata) Dataset(com.google.cloud.aiplatform.v1beta1.Dataset) DatasetServiceClient(com.google.cloud.aiplatform.v1beta1.DatasetServiceClient) ByteArrayOutputStream(java.io.ByteArrayOutputStream) LocationName(com.google.cloud.aiplatform.v1beta1.LocationName) Before(org.junit.Before)

Example 7 with LocationName

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

the class IndexEndpointServiceClientTest method listIndexEndpointsTest.

@Test
public void listIndexEndpointsTest() throws Exception {
    IndexEndpoint responsesElement = IndexEndpoint.newBuilder().build();
    ListIndexEndpointsResponse expectedResponse = ListIndexEndpointsResponse.newBuilder().setNextPageToken("").addAllIndexEndpoints(Arrays.asList(responsesElement)).build();
    mockIndexEndpointService.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListIndexEndpointsPagedResponse pagedListResponse = client.listIndexEndpoints(parent);
    List<IndexEndpoint> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getIndexEndpointsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockIndexEndpointService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListIndexEndpointsRequest actualRequest = ((ListIndexEndpointsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListIndexEndpointsPagedResponse(com.google.cloud.aiplatform.v1.IndexEndpointServiceClient.ListIndexEndpointsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 8 with LocationName

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

the class MetadataServiceClientTest method listMetadataStoresTest.

@Test
public void listMetadataStoresTest() throws Exception {
    MetadataStore responsesElement = MetadataStore.newBuilder().build();
    ListMetadataStoresResponse expectedResponse = ListMetadataStoresResponse.newBuilder().setNextPageToken("").addAllMetadataStores(Arrays.asList(responsesElement)).build();
    mockMetadataService.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListMetadataStoresPagedResponse pagedListResponse = client.listMetadataStores(parent);
    List<MetadataStore> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getMetadataStoresList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockMetadataService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListMetadataStoresRequest actualRequest = ((ListMetadataStoresRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListMetadataStoresPagedResponse(com.google.cloud.aiplatform.v1.MetadataServiceClient.ListMetadataStoresPagedResponse) Test(org.junit.Test)

Example 9 with LocationName

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

the class JobServiceClientTest method listHyperparameterTuningJobsTest.

@Test
public void listHyperparameterTuningJobsTest() throws Exception {
    HyperparameterTuningJob responsesElement = HyperparameterTuningJob.newBuilder().build();
    ListHyperparameterTuningJobsResponse expectedResponse = ListHyperparameterTuningJobsResponse.newBuilder().setNextPageToken("").addAllHyperparameterTuningJobs(Arrays.asList(responsesElement)).build();
    mockJobService.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListHyperparameterTuningJobsPagedResponse pagedListResponse = client.listHyperparameterTuningJobs(parent);
    List<HyperparameterTuningJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getHyperparameterTuningJobsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockJobService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListHyperparameterTuningJobsRequest actualRequest = ((ListHyperparameterTuningJobsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListHyperparameterTuningJobsPagedResponse(com.google.cloud.aiplatform.v1.JobServiceClient.ListHyperparameterTuningJobsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 10 with LocationName

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

the class JobServiceClientTest method listDataLabelingJobsTest.

@Test
public void listDataLabelingJobsTest() throws Exception {
    DataLabelingJob responsesElement = DataLabelingJob.newBuilder().build();
    ListDataLabelingJobsResponse expectedResponse = ListDataLabelingJobsResponse.newBuilder().setNextPageToken("").addAllDataLabelingJobs(Arrays.asList(responsesElement)).build();
    mockJobService.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListDataLabelingJobsPagedResponse pagedListResponse = client.listDataLabelingJobs(parent);
    List<DataLabelingJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getDataLabelingJobsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockJobService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListDataLabelingJobsRequest actualRequest = ((ListDataLabelingJobsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListDataLabelingJobsPagedResponse(com.google.cloud.aiplatform.v1.JobServiceClient.ListDataLabelingJobsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)54 AbstractMessage (com.google.protobuf.AbstractMessage)37 LocationName (com.google.cloud.aiplatform.v1.LocationName)36 LocationName (com.google.privacy.dlp.v2.LocationName)22 OrganizationLocationName (com.google.privacy.dlp.v2.OrganizationLocationName)22 LocationName (com.google.cloud.translate.v3beta1.LocationName)18 TranslationServiceClient (com.google.cloud.translate.v3beta1.TranslationServiceClient)18 AutoMlClient (com.google.cloud.automl.v1.AutoMlClient)17 LocationName (com.google.cloud.automl.v1.LocationName)17 JobServiceClient (com.google.cloud.aiplatform.v1.JobServiceClient)15 JobServiceSettings (com.google.cloud.aiplatform.v1.JobServiceSettings)15 Value (com.google.protobuf.Value)15 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)14 Model (com.google.cloud.aiplatform.v1.Model)14 StatusRuntimeException (io.grpc.StatusRuntimeException)14 PipelineServiceClient (com.google.cloud.aiplatform.v1.PipelineServiceClient)13 PipelineServiceSettings (com.google.cloud.aiplatform.v1.PipelineServiceSettings)13 TrainingPipeline (com.google.cloud.aiplatform.v1.TrainingPipeline)13 LocationName (com.google.cloud.translate.v3.LocationName)13 TranslationServiceClient (com.google.cloud.translate.v3.TranslationServiceClient)13