use of com.google.cloud.aiplatform.v1.Dataset in project java-aiplatform by googleapis.
the class ImportDataVideoActionRecognitionSample method importDataVideoActionRecognitionSample.
static void importDataVideoActionRecognitionSample(String project, String datasetId, String gcsSourceUri) throws IOException, ExecutionException, InterruptedException {
DatasetServiceSettings settings = DatasetServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
String location = "us-central1";
// the "close" method on the client to safely clean up any remaining background resources.
try (DatasetServiceClient client = DatasetServiceClient.create(settings)) {
GcsSource gcsSource = GcsSource.newBuilder().addUris(gcsSourceUri).build();
ImportDataConfig importConfig0 = ImportDataConfig.newBuilder().setGcsSource(gcsSource).setImportSchemaUri("gs://google-cloud-aiplatform/schema/dataset/ioformat/" + "video_action_recognition_io_format_1.0.0.yaml").build();
List<ImportDataConfig> importConfigs = new ArrayList<>();
importConfigs.add(importConfig0);
DatasetName name = DatasetName.of(project, location, datasetId);
OperationFuture<ImportDataResponse, ImportDataOperationMetadata> response = client.importDataAsync(name, importConfigs);
// You can use OperationFuture.getInitialFuture to get a future representing the initial
// response to the request, which contains information while the operation is in progress.
System.out.format("Operation name: %s\n", response.getInitialFuture().get().getName());
// OperationFuture.get() will block until the operation is finished.
ImportDataResponse importDataResponse = response.get();
System.out.format("importDataResponse: %s\n", importDataResponse);
}
}
use of com.google.cloud.aiplatform.v1.Dataset in project java-aiplatform by googleapis.
the class ImportDataVideoObjectTrackingSample method importDataVideObjectTracking.
static void importDataVideObjectTracking(String gcsSourceUri, String project, String datasetId) throws IOException, ExecutionException, InterruptedException, TimeoutException {
DatasetServiceSettings datasetServiceSettings = DatasetServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
// the "close" method on the client to safely clean up any remaining background resources.
try (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create(datasetServiceSettings)) {
String location = "us-central1";
String importSchemaUri = "gs://google-cloud-aiplatform/schema/dataset/ioformat/" + "video_object_tracking_io_format_1.0.0.yaml";
GcsSource.Builder gcsSource = GcsSource.newBuilder();
gcsSource.addUris(gcsSourceUri);
DatasetName datasetName = DatasetName.of(project, location, datasetId);
List<ImportDataConfig> importDataConfigs = Collections.singletonList(ImportDataConfig.newBuilder().setGcsSource(gcsSource).setImportSchemaUri(importSchemaUri).build());
OperationFuture<ImportDataResponse, ImportDataOperationMetadata> importDataResponseFuture = datasetServiceClient.importDataAsync(datasetName, importDataConfigs);
System.out.format("Operation name: %s\n", importDataResponseFuture.getInitialFuture().get().getName());
System.out.println("Waiting for operation to finish...");
ImportDataResponse importDataResponse = importDataResponseFuture.get(300, TimeUnit.SECONDS);
System.out.format("Import Data Video Object Tracking Response: %s\n", importDataResponse.toString());
}
}
use of com.google.cloud.aiplatform.v1.Dataset in project java-aiplatform by googleapis.
the class ImportDataImageClassificationSample method importDataImageClassificationSample.
static void importDataImageClassificationSample(String project, String datasetId, String gcsSourceUri) throws IOException, InterruptedException, ExecutionException, TimeoutException {
DatasetServiceSettings datasetServiceSettings = DatasetServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
// the "close" method on the client to safely clean up any remaining background resources.
try (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create(datasetServiceSettings)) {
String location = "us-central1";
String importSchemaUri = "gs://google-cloud-aiplatform/schema/dataset/ioformat/" + "image_classification_single_label_io_format_1.0.0.yaml";
GcsSource.Builder gcsSource = GcsSource.newBuilder();
gcsSource.addUris(gcsSourceUri);
DatasetName datasetName = DatasetName.of(project, location, datasetId);
List<ImportDataConfig> importDataConfigList = Collections.singletonList(ImportDataConfig.newBuilder().setGcsSource(gcsSource).setImportSchemaUri(importSchemaUri).build());
OperationFuture<ImportDataResponse, ImportDataOperationMetadata> importDataResponseFuture = datasetServiceClient.importDataAsync(datasetName, importDataConfigList);
System.out.format("Operation name: %s\n", importDataResponseFuture.getInitialFuture().get().getName());
System.out.println("Waiting for operation to finish...");
ImportDataResponse importDataResponse = importDataResponseFuture.get(300, TimeUnit.SECONDS);
System.out.format("Import Data Image Classification Response: %s\n", importDataResponse.toString());
}
}
use of com.google.cloud.aiplatform.v1.Dataset in project java-aiplatform by googleapis.
the class DatasetServiceClientTest method listDatasetsTest2.
@Test
public void listDatasetsTest2() throws Exception {
Dataset responsesElement = Dataset.newBuilder().build();
ListDatasetsResponse expectedResponse = ListDatasetsResponse.newBuilder().setNextPageToken("").addAllDatasets(Arrays.asList(responsesElement)).build();
mockDatasetService.addResponse(expectedResponse);
String parent = "parent-995424086";
ListDatasetsPagedResponse pagedListResponse = client.listDatasets(parent);
List<Dataset> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getDatasetsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDatasetService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListDatasetsRequest actualRequest = ((ListDatasetsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.aiplatform.v1.Dataset in project java-aiplatform by googleapis.
the class DatasetServiceClientTest method listAnnotationsTest.
@Test
public void listAnnotationsTest() throws Exception {
Annotation responsesElement = Annotation.newBuilder().build();
ListAnnotationsResponse expectedResponse = ListAnnotationsResponse.newBuilder().setNextPageToken("").addAllAnnotations(Arrays.asList(responsesElement)).build();
mockDatasetService.addResponse(expectedResponse);
DataItemName parent = DataItemName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[DATA_ITEM]");
ListAnnotationsPagedResponse pagedListResponse = client.listAnnotations(parent);
List<Annotation> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getAnnotationsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDatasetService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListAnnotationsRequest actualRequest = ((ListAnnotationsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations