use of com.google.cloud.aiplatform.v1beta1.CreateDatasetOperationMetadata in project java-aiplatform by googleapis.
the class CreateDatasetTextSample method createDatasetTextSample.
static void createDatasetTextSample(String project, String datasetDisplayName) 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 metadataSchemaUri = "gs://google-cloud-aiplatform/schema/dataset/metadata/text_1.0.0.yaml";
LocationName locationName = LocationName.of(project, location);
Dataset dataset = Dataset.newBuilder().setDisplayName(datasetDisplayName).setMetadataSchemaUri(metadataSchemaUri).build();
OperationFuture<Dataset, CreateDatasetOperationMetadata> datasetFuture = datasetServiceClient.createDatasetAsync(locationName, dataset);
System.out.format("Operation name: %s\n", datasetFuture.getInitialFuture().get().getName());
System.out.println("Waiting for operation to finish...");
Dataset datasetResponse = datasetFuture.get(180, TimeUnit.SECONDS);
System.out.println("Create Text Dataset Response");
System.out.format("\tName: %s\n", datasetResponse.getName());
System.out.format("\tDisplay Name: %s\n", datasetResponse.getDisplayName());
System.out.format("\tMetadata Schema Uri: %s\n", datasetResponse.getMetadataSchemaUri());
System.out.format("\tMetadata: %s\n", datasetResponse.getMetadata());
System.out.format("\tCreate Time: %s\n", datasetResponse.getCreateTime());
System.out.format("\tUpdate Time: %s\n", datasetResponse.getUpdateTime());
System.out.format("\tLabels: %s\n", datasetResponse.getLabelsMap());
}
}
Aggregations