use of com.google.cloud.datalabeling.v1beta1.CreateDatasetRequest in project java-datalabeling by googleapis.
the class CreateDataset method createDataset.
// Create a dataset that is initially empty.
static void createDataset(String projectId, String datasetName) throws IOException {
// String projectId = "YOUR_PROJECT_ID";
// String datasetName = "YOUR_DATASET_DISPLAY_NAME";
// [END datalabeling_create_dataset_beta]
String endpoint = System.getenv("DATALABELING_ENDPOINT");
if (endpoint == null) {
endpoint = DataLabelingServiceSettings.getDefaultEndpoint();
}
// [START datalabeling_create_dataset_beta]
DataLabelingServiceSettings settings = DataLabelingServiceSettings.newBuilder().setEndpoint(endpoint).build();
try (DataLabelingServiceClient dataLabelingServiceClient = DataLabelingServiceClient.create(settings)) {
ProjectName projectName = ProjectName.of(projectId);
Dataset dataset = Dataset.newBuilder().setDisplayName(datasetName).setDescription("YOUR_DESCRIPTION").build();
CreateDatasetRequest createDatasetRequest = CreateDatasetRequest.newBuilder().setParent(projectName.toString()).setDataset(dataset).build();
Dataset createdDataset = dataLabelingServiceClient.createDataset(createDatasetRequest);
System.out.format("Name: %s\n", createdDataset.getName());
System.out.format("DisplayName: %s\n", createdDataset.getDisplayName());
System.out.format("Description: %s\n", createdDataset.getDescription());
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations