Search in sources :

Example 21 with DatasetName

use of com.google.cloud.aiplatform.v1beta1.DatasetName in project java-automl by googleapis.

the class VideoObjectTrackingCreateDatasetTest method tearDown.

@After
public void tearDown() throws InterruptedException, ExecutionException, IOException {
    // Delete the created dataset
    try (AutoMlClient client = AutoMlClient.create()) {
        // Get the full path of the dataset.
        DatasetName datasetFullId = DatasetName.of(PROJECT_ID, "us-central1", datasetId);
        client.deleteDatasetAsync(datasetFullId).get();
    }
    System.setOut(originalPrintStream);
}
Also used : DatasetName(com.google.cloud.automl.v1beta1.DatasetName) AutoMlClient(com.google.cloud.automl.v1beta1.AutoMlClient) After(org.junit.After)

Example 22 with DatasetName

use of com.google.cloud.aiplatform.v1beta1.DatasetName in project java-aiplatform by googleapis.

the class ImportDataImageClassificationSampleTest method tearDown.

@After
public void tearDown() throws InterruptedException, ExecutionException, IOException {
    // delete the temp dataset
    DatasetServiceSettings datasetServiceSettings = DatasetServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    try (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create(datasetServiceSettings)) {
        DatasetName datasetName = DatasetName.of(PROJECT, LOCATION, datasetId);
        OperationFuture<Empty, DeleteOperationMetadata> operationFuture = datasetServiceClient.deleteDatasetAsync(datasetName);
        operationFuture.get();
    }
    System.out.flush();
    System.setOut(originalPrintStream);
}
Also used : Empty(com.google.protobuf.Empty) DatasetServiceSettings(com.google.cloud.aiplatform.v1beta1.DatasetServiceSettings) DatasetName(com.google.cloud.aiplatform.v1beta1.DatasetName) DeleteOperationMetadata(com.google.cloud.aiplatform.v1beta1.DeleteOperationMetadata) DatasetServiceClient(com.google.cloud.aiplatform.v1beta1.DatasetServiceClient) After(org.junit.After)

Example 23 with DatasetName

use of com.google.cloud.aiplatform.v1beta1.DatasetName in project java-aiplatform by googleapis.

the class DeleteDatasetSample method deleteDatasetSample.

static void deleteDatasetSample(String project, String datasetId) 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";
        DatasetName datasetName = DatasetName.of(project, location, datasetId);
        OperationFuture<Empty, DeleteOperationMetadata> operationFuture = datasetServiceClient.deleteDatasetAsync(datasetName);
        System.out.format("Operation name: %s\n", operationFuture.getInitialFuture().get().getName());
        System.out.println("Waiting for operation to finish...");
        operationFuture.get(300, TimeUnit.SECONDS);
        System.out.format("Deleted Dataset.");
    }
}
Also used : Empty(com.google.protobuf.Empty) DatasetServiceSettings(com.google.cloud.aiplatform.v1.DatasetServiceSettings) DatasetName(com.google.cloud.aiplatform.v1.DatasetName) DeleteOperationMetadata(com.google.cloud.aiplatform.v1.DeleteOperationMetadata) DatasetServiceClient(com.google.cloud.aiplatform.v1.DatasetServiceClient)

Example 24 with DatasetName

use of com.google.cloud.aiplatform.v1beta1.DatasetName in project java-aiplatform by googleapis.

the class ImportDataTextEntityExtractionSample method importDataTextEntityExtractionSample.

static void importDataTextEntityExtractionSample(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/" + "text_extraction_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 Text Entity Extraction Response: %s\n", importDataResponse.toString());
    }
}
Also used : ImportDataResponse(com.google.cloud.aiplatform.v1.ImportDataResponse) GcsSource(com.google.cloud.aiplatform.v1.GcsSource) ImportDataConfig(com.google.cloud.aiplatform.v1.ImportDataConfig) DatasetServiceSettings(com.google.cloud.aiplatform.v1.DatasetServiceSettings) DatasetName(com.google.cloud.aiplatform.v1.DatasetName) DatasetServiceClient(com.google.cloud.aiplatform.v1.DatasetServiceClient) ImportDataOperationMetadata(com.google.cloud.aiplatform.v1.ImportDataOperationMetadata)

Example 25 with DatasetName

use of com.google.cloud.aiplatform.v1beta1.DatasetName 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);
    }
}
Also used : ImportDataResponse(com.google.cloud.aiplatform.v1.ImportDataResponse) GcsSource(com.google.cloud.aiplatform.v1.GcsSource) ImportDataConfig(com.google.cloud.aiplatform.v1.ImportDataConfig) DatasetServiceSettings(com.google.cloud.aiplatform.v1.DatasetServiceSettings) DatasetName(com.google.cloud.aiplatform.v1.DatasetName) DatasetServiceClient(com.google.cloud.aiplatform.v1.DatasetServiceClient) ArrayList(java.util.ArrayList) ImportDataOperationMetadata(com.google.cloud.aiplatform.v1.ImportDataOperationMetadata)

Aggregations

Empty (com.google.protobuf.Empty)13 DatasetName (com.google.cloud.aiplatform.v1.DatasetName)12 DatasetServiceClient (com.google.cloud.aiplatform.v1.DatasetServiceClient)9 DatasetServiceSettings (com.google.cloud.aiplatform.v1.DatasetServiceSettings)9 GcsSource (com.google.cloud.aiplatform.v1.GcsSource)8 ImportDataConfig (com.google.cloud.aiplatform.v1.ImportDataConfig)8 ImportDataOperationMetadata (com.google.cloud.aiplatform.v1.ImportDataOperationMetadata)8 ImportDataResponse (com.google.cloud.aiplatform.v1.ImportDataResponse)8 After (org.junit.After)7 DatasetName (com.google.cloud.aiplatform.v1beta1.DatasetName)5 DatasetServiceClient (com.google.cloud.aiplatform.v1beta1.DatasetServiceClient)5 DatasetServiceSettings (com.google.cloud.aiplatform.v1beta1.DatasetServiceSettings)5 DeleteOperationMetadata (com.google.cloud.aiplatform.v1beta1.DeleteOperationMetadata)5 AutoMlClient (com.google.cloud.automl.v1.AutoMlClient)5 DatasetName (com.google.cloud.automl.v1.DatasetName)5 AutoMlClient (com.google.cloud.automl.v1beta1.AutoMlClient)5 DatasetName (com.google.cloud.automl.v1beta1.DatasetName)5 DataLabelingJob (com.google.cloud.aiplatform.v1.DataLabelingJob)3 JobServiceClient (com.google.cloud.aiplatform.v1.JobServiceClient)3 JobServiceSettings (com.google.cloud.aiplatform.v1.JobServiceSettings)3